SDL_d3dmath.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
  4. This software is provided 'as-is', without any express or implied
  5. warranty. In no event will the authors be held liable for any damages
  6. arising from the use of this software.
  7. Permission is granted to anyone to use this software for any purpose,
  8. including commercial applications, and to alter it and redistribute it
  9. freely, subject to the following restrictions:
  10. 1. The origin of this software must not be misrepresented; you must not
  11. claim that you wrote the original software. If you use this software
  12. in a product, an acknowledgment in the product documentation would be
  13. appreciated but is not required.
  14. 2. Altered source versions must be plainly marked as such, and must not be
  15. misrepresented as being the original software.
  16. 3. This notice may not be removed or altered from any source distribution.
  17. */
  18. #include "SDL_internal.h"
  19. #if (SDL_VIDEO_RENDER_D3D || SDL_VIDEO_RENDER_D3D11 || SDL_VIDEO_RENDER_D3D12)
  20. /* Set up for C function definitions, even when using C++ */
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. /* Direct3D matrix math functions */
  25. typedef struct
  26. {
  27. float x;
  28. float y;
  29. } Float2;
  30. typedef struct
  31. {
  32. float x;
  33. float y;
  34. float z;
  35. } Float3;
  36. typedef struct
  37. {
  38. float x;
  39. float y;
  40. float z;
  41. float w;
  42. } Float4;
  43. typedef struct
  44. {
  45. union
  46. {
  47. struct
  48. {
  49. float _11, _12, _13, _14;
  50. float _21, _22, _23, _24;
  51. float _31, _32, _33, _34;
  52. float _41, _42, _43, _44;
  53. } v;
  54. float m[4][4];
  55. };
  56. } Float4X4;
  57. Float4X4 MatrixIdentity();
  58. Float4X4 MatrixMultiply(Float4X4 M1, Float4X4 M2);
  59. Float4X4 MatrixScaling(float x, float y, float z);
  60. Float4X4 MatrixTranslation(float x, float y, float z);
  61. Float4X4 MatrixRotationX(float r);
  62. Float4X4 MatrixRotationY(float r);
  63. Float4X4 MatrixRotationZ(float r);
  64. /* Ends C function definitions when using C++ */
  65. #ifdef __cplusplus
  66. }
  67. #endif
  68. #endif /* (SDL_VIDEO_RENDER_D3D || SDL_VIDEO_RENDER_D3D11 || SDL_VIDEO_RENDER_D3D12) */