diff --git a/VisualC/SDL/SDL_VS2008.vcproj b/VisualC/SDL/SDL_VS2008.vcproj
index cb4fab624..b28a75b0b 100644
--- a/VisualC/SDL/SDL_VS2008.vcproj
+++ b/VisualC/SDL/SDL_VS2008.vcproj
@@ -415,16 +415,12 @@
RelativePath="..\..\include\SDL_cpuinfo.h"
>
-
-
-
-
+
+
+
+
+
+
@@ -864,6 +872,26 @@
RelativePath="..\..\src\joystick\windows\SDL_dxjoystick.c"
>
+
+
+
+
+
+
+
+
+
+
@@ -1020,18 +1048,22 @@
RelativePath="..\..\src\render\SDL_render.c"
>
-
-
+
+
+
+
@@ -1068,6 +1100,10 @@
RelativePath="..\..\src\render\opengl\SDL_shaders_gl.h"
>
+
+
@@ -1148,10 +1184,6 @@
RelativePath="..\..\src\thread\windows\SDL_systhread.c"
>
-
-
@@ -1168,6 +1200,10 @@
RelativePath="..\..\src\timer\SDL_systimer.h"
>
+
+
@@ -1228,22 +1264,6 @@
RelativePath="..\..\src\core\windows\SDL_windows.h"
>
-
-
-
-
-
-
-
-
@@ -1305,23 +1325,11 @@
>
-
-
-
-
-
-
+
@@ -585,6 +586,7 @@
+
diff --git a/VisualC/SDL/SDL_VS2012.vcxproj b/VisualC/SDL/SDL_VS2012.vcxproj
index 191641a6b..d9971ff27 100644
--- a/VisualC/SDL/SDL_VS2012.vcxproj
+++ b/VisualC/SDL/SDL_VS2012.vcxproj
@@ -283,6 +283,7 @@
+
@@ -376,6 +377,7 @@
+
diff --git a/VisualC/SDL/SDL_VS2013.vcxproj b/VisualC/SDL/SDL_VS2013.vcxproj
index e30f19988..2ca83e431 100644
--- a/VisualC/SDL/SDL_VS2013.vcxproj
+++ b/VisualC/SDL/SDL_VS2013.vcxproj
@@ -286,6 +286,7 @@
+
@@ -380,6 +381,7 @@
+
diff --git a/src/render/SDL_d3dmath.c b/src/render/SDL_d3dmath.c
new file mode 100644
index 000000000..df1dc0ba9
--- /dev/null
+++ b/src/render/SDL_d3dmath.c
@@ -0,0 +1,131 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2014 Sam Lantinga
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+*/
+#include "../SDL_internal.h"
+#include "SDL_stdinc.h"
+
+#include "SDL_d3dmath.h"
+
+/* Direct3D matrix math functions */
+
+Float4X4 MatrixIdentity()
+{
+ Float4X4 m;
+ SDL_zero(m);
+ m._11 = 1.0f;
+ m._22 = 1.0f;
+ m._33 = 1.0f;
+ m._44 = 1.0f;
+ return m;
+}
+
+Float4X4 MatrixMultiply(Float4X4 M1, Float4X4 M2)
+{
+ Float4X4 m;
+ m._11 = M1._11 * M2._11 + M1._12 * M2._21 + M1._13 * M2._31 + M1._14 * M2._41;
+ m._12 = M1._11 * M2._12 + M1._12 * M2._22 + M1._13 * M2._32 + M1._14 * M2._42;
+ m._13 = M1._11 * M2._13 + M1._12 * M2._23 + M1._13 * M2._33 + M1._14 * M2._43;
+ m._14 = M1._11 * M2._14 + M1._12 * M2._24 + M1._13 * M2._34 + M1._14 * M2._44;
+ m._21 = M1._21 * M2._11 + M1._22 * M2._21 + M1._23 * M2._31 + M1._24 * M2._41;
+ m._22 = M1._21 * M2._12 + M1._22 * M2._22 + M1._23 * M2._32 + M1._24 * M2._42;
+ m._23 = M1._21 * M2._13 + M1._22 * M2._23 + M1._23 * M2._33 + M1._24 * M2._43;
+ m._24 = M1._21 * M2._14 + M1._22 * M2._24 + M1._23 * M2._34 + M1._24 * M2._44;
+ m._31 = M1._31 * M2._11 + M1._32 * M2._21 + M1._33 * M2._31 + M1._34 * M2._41;
+ m._32 = M1._31 * M2._12 + M1._32 * M2._22 + M1._33 * M2._32 + M1._34 * M2._42;
+ m._33 = M1._31 * M2._13 + M1._32 * M2._23 + M1._33 * M2._33 + M1._34 * M2._43;
+ m._34 = M1._31 * M2._14 + M1._32 * M2._24 + M1._33 * M2._34 + M1._34 * M2._44;
+ m._41 = M1._41 * M2._11 + M1._42 * M2._21 + M1._43 * M2._31 + M1._44 * M2._41;
+ m._42 = M1._41 * M2._12 + M1._42 * M2._22 + M1._43 * M2._32 + M1._44 * M2._42;
+ m._43 = M1._41 * M2._13 + M1._42 * M2._23 + M1._43 * M2._33 + M1._44 * M2._43;
+ m._44 = M1._41 * M2._14 + M1._42 * M2._24 + M1._43 * M2._34 + M1._44 * M2._44;
+ return m;
+}
+
+Float4X4 MatrixScaling(float x, float y, float z)
+{
+ Float4X4 m;
+ SDL_zero(m);
+ m._11 = x;
+ m._22 = y;
+ m._33 = z;
+ m._44 = 1.0f;
+ return m;
+}
+
+Float4X4 MatrixTranslation(float x, float y, float z)
+{
+ Float4X4 m;
+ SDL_zero(m);
+ m._11 = 1.0f;
+ m._22 = 1.0f;
+ m._33 = 1.0f;
+ m._44 = 1.0f;
+ m._41 = x;
+ m._42 = y;
+ m._43 = z;
+ return m;
+}
+
+Float4X4 MatrixRotationX(float r)
+{
+ float sinR = SDL_sinf(r);
+ float cosR = SDL_cosf(r);
+ Float4X4 m;
+ SDL_zero(m);
+ m._11 = 1.0f;
+ m._22 = cosR;
+ m._23 = sinR;
+ m._32 = -sinR;
+ m._33 = cosR;
+ m._44 = 1.0f;
+ return m;
+}
+
+Float4X4 MatrixRotationY(float r)
+{
+ float sinR = SDL_sinf(r);
+ float cosR = SDL_cosf(r);
+ Float4X4 m;
+ SDL_zero(m);
+ m._11 = cosR;
+ m._13 = -sinR;
+ m._22 = 1.0f;
+ m._31 = sinR;
+ m._33 = cosR;
+ m._44 = 1.0f;
+ return m;
+}
+
+Float4X4 MatrixRotationZ(float r)
+{
+ float sinR = SDL_sinf(r);
+ float cosR = SDL_cosf(r);
+ Float4X4 m;
+ SDL_zero(m);
+ m._11 = cosR;
+ m._12 = sinR;
+ m._21 = -sinR;
+ m._22 = cosR;
+ m._33 = 1.0f;
+ m._44 = 1.0f;
+ return m;
+}
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/render/SDL_d3dmath.h b/src/render/SDL_d3dmath.h
new file mode 100644
index 000000000..206c4350c
--- /dev/null
+++ b/src/render/SDL_d3dmath.h
@@ -0,0 +1,69 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2014 Sam Lantinga
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+*/
+#include "../SDL_internal.h"
+
+
+/* Direct3D matrix math functions */
+
+typedef struct
+{
+ float x;
+ float y;
+} Float2;
+
+typedef struct
+{
+ float x;
+ float y;
+ float z;
+} Float3;
+
+typedef struct
+{
+ float x;
+ float y;
+ float z;
+ float w;
+} Float4;
+
+typedef struct
+{
+ union {
+ struct {
+ float _11, _12, _13, _14;
+ float _21, _22, _23, _24;
+ float _31, _32, _33, _34;
+ float _41, _42, _43, _44;
+ };
+ float m[4][4];
+ };
+} Float4X4;
+
+
+Float4X4 MatrixIdentity();
+Float4X4 MatrixMultiply(Float4X4 M1, Float4X4 M2);
+Float4X4 MatrixScaling(float x, float y, float z);
+Float4X4 MatrixTranslation(float x, float y, float z);
+Float4X4 MatrixRotationX(float r);
+Float4X4 MatrixRotationY(float r);
+Float4X4 MatrixRotationZ(float r);
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c
index 3357ed4ed..1547668f3 100644
--- a/src/render/SDL_render.c
+++ b/src/render/SDL_render.c
@@ -47,12 +47,12 @@
#if !SDL_RENDER_DISABLED
static const SDL_RenderDriver *render_drivers[] = {
-#if SDL_VIDEO_RENDER_D3D11
- &D3D11_RenderDriver,
-#endif
#if SDL_VIDEO_RENDER_D3D
&D3D_RenderDriver,
#endif
+#if SDL_VIDEO_RENDER_D3D11
+ &D3D11_RenderDriver,
+#endif
#if SDL_VIDEO_RENDER_OGL
&GL_RenderDriver,
#endif
diff --git a/src/render/direct3d/SDL_render_d3d.c b/src/render/direct3d/SDL_render_d3d.c
index 3ef6d67e1..24482818d 100644
--- a/src/render/direct3d/SDL_render_d3d.c
+++ b/src/render/direct3d/SDL_render_d3d.c
@@ -31,6 +31,7 @@
#include "SDL_loadso.h"
#include "SDL_syswm.h"
#include "../SDL_sysrender.h"
+#include "../SDL_d3dmath.h"
#include "../../video/windows/SDL_windowsvideo.h"
#if SDL_VIDEO_RENDER_D3D
@@ -39,89 +40,6 @@
#endif
-typedef interface ID3DXMatrixStack *LPD3DXMATRIXSTACK;
-typedef struct _D3DMATRIX D3DXMATRIX, *LPD3DXMATRIX;
-typedef struct _D3DVECTOR D3DXVECTOR3, *LPD3DXVECTOR3;
-
-DEFINE_GUID(IID_ID3DXMatrixStack,
-0xc7885ba7, 0xf990, 0x4fe7, 0x92, 0x2d, 0x85, 0x15, 0xe4, 0x77, 0xdd, 0x85);
-
-#undef INTERFACE
-#define INTERFACE ID3DXMatrixStack
-
-DECLARE_INTERFACE_(ID3DXMatrixStack, IUnknown)
-{
- STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE;
- STDMETHOD_(ULONG,AddRef)(THIS) PURE;
- STDMETHOD_(ULONG,Release)(THIS) PURE;
- STDMETHOD(Pop)(THIS) PURE;
- STDMETHOD(Push)(THIS) PURE;
- STDMETHOD(LoadIdentity)(THIS) PURE;
- STDMETHOD(LoadMatrix)(THIS_ CONST D3DXMATRIX* pM ) PURE;
- STDMETHOD(MultMatrix)(THIS_ CONST D3DXMATRIX* pM ) PURE;
- STDMETHOD(MultMatrixLocal)(THIS_ CONST D3DXMATRIX* pM ) PURE;
- STDMETHOD(RotateAxis)(THIS_ CONST D3DXVECTOR3* pV, FLOAT Angle) PURE;
- STDMETHOD(RotateAxisLocal)(THIS_ CONST D3DXVECTOR3* pV, FLOAT Angle) PURE;
- STDMETHOD(RotateYawPitchRoll)(THIS_ FLOAT Yaw, FLOAT Pitch, FLOAT Roll) PURE;
- STDMETHOD(RotateYawPitchRollLocal)(THIS_ FLOAT Yaw, FLOAT Pitch, FLOAT Roll) PURE;
- STDMETHOD(Scale)(THIS_ FLOAT x, FLOAT y, FLOAT z) PURE;
- STDMETHOD(ScaleLocal)(THIS_ FLOAT x, FLOAT y, FLOAT z) PURE;
- STDMETHOD(Translate)(THIS_ FLOAT x, FLOAT y, FLOAT z ) PURE;
- STDMETHOD(TranslateLocal)(THIS_ FLOAT x, FLOAT y, FLOAT z) PURE;
- STDMETHOD_(D3DXMATRIX*, GetTop)(THIS) PURE;
-};
-
-#undef INTERFACE
-
-#if !defined(__cplusplus) || defined(CINTERFACE)
-#define ID3DXMatrixStack_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
-#define ID3DXMatrixStack_AddRef(p) (p)->lpVtbl->AddRef(p)
-#define ID3DXMatrixStack_Release(p) (p)->lpVtbl->Release(p)
-#define ID3DXMatrixStack_Pop(p) (p)->lpVtbl->Pop(p)
-#define ID3DXMatrixStack_Push(p) (p)->lpVtbl->Push(p)
-#define ID3DXMatrixStack_LoadIdentity(p) (p)->lpVtbl->LoadIdentity(p)
-#define ID3DXMatrixStack_LoadMatrix(p,a) (p)->lpVtbl->LoadMatrix(p,a)
-#define ID3DXMatrixStack_MultMatrix(p,a) (p)->lpVtbl->MultMatrix(p,a)
-#define ID3DXMatrixStack_MultMatrixLocal(p,a) (p)->lpVtbl->MultMatrixLocal(p,a)
-#define ID3DXMatrixStack_RotateAxis(p,a,b) (p)->lpVtbl->RotateAxis(p,a,b)
-#define ID3DXMatrixStack_RotateAxisLocal(p,a,b) (p)->lpVtbl->RotateAxisLocal(p,a,b)
-#define ID3DXMatrixStack_RotateYawPitchRoll(p,a,b,c) (p)->lpVtbl->RotateYawPitchRoll(p,a,b,c)
-#define ID3DXMatrixStack_RotateYawPitchRollLocal(p,a,b,c) (p)->lpVtbl->RotateYawPitchRollLocal(p,a,b,c)
-#define ID3DXMatrixStack_Scale(p,a,b,c) (p)->lpVtbl->Scale(p,a,b,c)
-#define ID3DXMatrixStack_ScaleLocal(p,a,b,c) (p)->lpVtbl->ScaleLocal(p,a,b,c)
-#define ID3DXMatrixStack_Translate(p,a,b,c) (p)->lpVtbl->Translate(p,a,b,c)
-#define ID3DXMatrixStack_TranslateLocal(p,a,b,c) (p)->lpVtbl->TranslateLocal(p,a,b,c)
-#define ID3DXMatrixStack_GetTop(p) (p)->lpVtbl->GetTop(p)
-#else
-#define ID3DXMatrixStack_QueryInterface(p,a,b) (p)->QueryInterface(a,b)
-#define ID3DXMatrixStack_AddRef(p) (p)->AddRef()
-#define ID3DXMatrixStack_Release(p) (p)->Release()
-#define ID3DXMatrixStack_Pop(p) (p)->Pop()
-#define ID3DXMatrixStack_Push(p) (p)->Push()
-#define ID3DXMatrixStack_LoadIdentity(p) (p)->LoadIdentity()
-#define ID3DXMatrixStack_LoadMatrix(p,a) (p)->LoadMatrix(a)
-#define ID3DXMatrixStack_MultMatrix(p,a) (p)->MultMatrix(a)
-#define ID3DXMatrixStack_MultMatrixLocal(p,a) (p)->MultMatrixLocal(a)
-#define ID3DXMatrixStack_RotateAxis(p,a,b) (p)->RotateAxis(a,b)
-#define ID3DXMatrixStack_RotateAxisLocal(p,a,b) (p)->RotateAxisLocal(a,b)
-#define ID3DXMatrixStack_RotateYawPitchRoll(p,a,b,c) (p)->RotateYawPitchRollLocal(a,b,c)
-#define ID3DXMatrixStack_Scale(p,a,b,c) (p)->Scale(a,b,c)
-#define ID3DXMatrixStack_ScaleLocal(p,a,b,c) (p)->ScaleLocal(a,b,c)
-#define ID3DXMatrixStack_Translate(p,a,b,c) (p)->Translate(a,b,c)
-#define ID3DXMatrixStack_TranslateLocal(p,a,b,c) (p)->TranslateLocal(a,b,c)
-#define ID3DXMatrixStack_GetTop(p) (p)->GetTop()
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-HRESULT WINAPI D3DXCreateMatrixStack(DWORD flags, LPD3DXMATRIXSTACK* ppstack);
-
-#ifdef __cplusplus
-}
-#endif
-
#ifdef ASSEMBLE_SHADER
/**************************************************************************
* ID3DXBuffer:
@@ -266,7 +184,6 @@ typedef struct
IDirect3DSurface9 *defaultRenderTarget;
IDirect3DSurface9 *currentRenderTarget;
void* d3dxDLL;
- ID3DXMatrixStack *matrixStack;
LPDIRECT3DPIXELSHADER9 ps_yuv;
} D3D_RenderData;
@@ -582,8 +499,6 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags)
Uint32 window_flags;
int w, h;
SDL_DisplayMode fullscreen_mode;
- int d3dxVersion;
- char d3dxDLLFile[50];
int displayIndex;
renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
@@ -599,29 +514,7 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags)
return NULL;
}
- if (D3D_LoadDLL(&data->d3dDLL, &data->d3d)) {
- for (d3dxVersion=50;d3dxVersion>0;d3dxVersion--) {
- LPTSTR dllName;
- SDL_snprintf(d3dxDLLFile, sizeof(d3dxDLLFile), "D3DX9_%02d.dll", d3dxVersion);
- dllName = WIN_UTF8ToString(d3dxDLLFile);
- data->d3dxDLL = (void *)LoadLibrary(dllName); /* not using SDL_LoadObject() as we want silently fail - no error message */
- SDL_free(dllName);
- if (data->d3dxDLL) {
- HRESULT (WINAPI *D3DXCreateMatrixStack) (DWORD Flags, LPD3DXMATRIXSTACK* ppStack);
- D3DXCreateMatrixStack = (HRESULT (WINAPI *) (DWORD, LPD3DXMATRIXSTACK*)) SDL_LoadFunction(data->d3dxDLL, "D3DXCreateMatrixStack");
- if (D3DXCreateMatrixStack) {
- D3DXCreateMatrixStack(0, &data->matrixStack);
- break;
- }
- }
- }
-
- if (!data->matrixStack) {
- if (data->d3dxDLL) SDL_UnloadObject(data->d3dxDLL);
- }
- }
-
- if (!data->d3d || !data->matrixStack) {
+ if (!D3D_LoadDLL(&data->d3dDLL, &data->d3d)) {
SDL_free(renderer);
SDL_free(data);
SDL_SetError("Unable to create Direct3D interface");
@@ -1697,6 +1590,7 @@ D3D_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture,
float centerx, centery;
DWORD color;
Vertex vertices[4];
+ Float4X4 modelMatrix;
HRESULT result;
if (D3D_ActivateRenderer(renderer) < 0) {
@@ -1768,11 +1662,11 @@ D3D_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture,
D3D_SetBlendMode(data, texture->blendMode);
/* Rotate and translate */
- ID3DXMatrixStack_Push(data->matrixStack);
- ID3DXMatrixStack_LoadIdentity(data->matrixStack);
- ID3DXMatrixStack_RotateYawPitchRoll(data->matrixStack, 0.0, 0.0, (float)(M_PI * (float) angle / 180.0f));
- ID3DXMatrixStack_Translate(data->matrixStack, (float)dstrect->x + centerx, (float)dstrect->y + centery, (float)0.0);
- IDirect3DDevice9_SetTransform(data->device, D3DTS_VIEW, (D3DMATRIX*)ID3DXMatrixStack_GetTop(data->matrixStack));
+ modelMatrix = MatrixMultiply(
+ MatrixRotationZ((float)(M_PI * (float) angle / 180.0f)),
+ MatrixTranslation(dstrect->x + center->x, dstrect->y + center->y, 0)
+ );
+ IDirect3DDevice9_SetTransform(data->device, D3DTS_VIEW, (D3DMATRIX*)&modelMatrix);
D3D_UpdateTextureScaleMode(data, texturedata, 0);
@@ -1822,11 +1716,9 @@ D3D_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture,
return D3D_SetError("SetShader()", result);
}
}
- ID3DXMatrixStack_Pop(data->matrixStack);
- ID3DXMatrixStack_Push(data->matrixStack);
- ID3DXMatrixStack_LoadIdentity(data->matrixStack);
- IDirect3DDevice9_SetTransform(data->device, D3DTS_VIEW, (D3DMATRIX*)ID3DXMatrixStack_GetTop(data->matrixStack));
- ID3DXMatrixStack_Pop(data->matrixStack);
+
+ modelMatrix = MatrixIdentity();
+ IDirect3DDevice9_SetTransform(data->device, D3DTS_VIEW, (D3DMATRIX*)&modelMatrix);
return 0;
}
@@ -1960,7 +1852,6 @@ D3D_DestroyRenderer(SDL_Renderer * renderer)
}
if (data->d3d) {
IDirect3D9_Release(data->d3d);
- ID3DXMatrixStack_Release(data->matrixStack);
SDL_UnloadObject(data->d3dDLL);
}
SDL_free(data);
diff --git a/src/render/direct3d11/SDL_render_d3d11.c b/src/render/direct3d11/SDL_render_d3d11.c
index 548ab1886..b9b3a3c0b 100644
--- a/src/render/direct3d11/SDL_render_d3d11.c
+++ b/src/render/direct3d11/SDL_render_d3d11.c
@@ -40,45 +40,13 @@ using namespace Windows::Graphics::Display;
#include "SDL_loadso.h"
#include "SDL_syswm.h"
#include "../SDL_sysrender.h"
+#include "../SDL_d3dmath.h"
#include
#define SAFE_RELEASE(X) if ((X)) { IUnknown_Release(SDL_static_cast(IUnknown*, X)); X = NULL; }
-typedef struct
-{
- float x;
- float y;
-} Float2;
-
-typedef struct
-{
- float x;
- float y;
- float z;
-} Float3;
-
-typedef struct
-{
- float x;
- float y;
- float z;
- float w;
-} Float4;
-
-typedef struct
-{
- union {
- struct {
- float _11, _12, _13, _14;
- float _21, _22, _23, _24;
- float _31, _32, _33, _34;
- float _41, _42, _43, _44;
- };
- float m[4][4];
- };
-} Float4X4;
/* Vertex shader, common values */
typedef struct
@@ -717,112 +685,6 @@ static const DWORD D3D11_VertexShader[] = {
#error "An appropriate vertex shader is not defined."
#endif
-/* Direct3D matrix math functions */
-
-static Float4X4 MatrixIdentity()
-{
- Float4X4 m;
- SDL_zero(m);
- m._11 = 1.0f;
- m._22 = 1.0f;
- m._33 = 1.0f;
- m._44 = 1.0f;
- return m;
-}
-
-static Float4X4 MatrixMultiply(Float4X4 M1, Float4X4 M2)
-{
- Float4X4 m;
- SDL_zero(m);
- m._11 = M1._11 * M2._11 + M1._12 * M2._21 + M1._13 * M2._31 + M1._14 * M2._41;
- m._12 = M1._11 * M2._12 + M1._12 * M2._22 + M1._13 * M2._32 + M1._14 * M2._42;
- m._13 = M1._11 * M2._13 + M1._12 * M2._23 + M1._13 * M2._33 + M1._14 * M2._43;
- m._14 = M1._11 * M2._14 + M1._12 * M2._24 + M1._13 * M2._34 + M1._14 * M2._44;
- m._21 = M1._21 * M2._11 + M1._22 * M2._21 + M1._23 * M2._31 + M1._24 * M2._41;
- m._22 = M1._21 * M2._12 + M1._22 * M2._22 + M1._23 * M2._32 + M1._24 * M2._42;
- m._23 = M1._21 * M2._13 + M1._22 * M2._23 + M1._23 * M2._33 + M1._24 * M2._43;
- m._24 = M1._21 * M2._14 + M1._22 * M2._24 + M1._23 * M2._34 + M1._24 * M2._44;
- m._31 = M1._31 * M2._11 + M1._32 * M2._21 + M1._33 * M2._31 + M1._34 * M2._41;
- m._32 = M1._31 * M2._12 + M1._32 * M2._22 + M1._33 * M2._32 + M1._34 * M2._42;
- m._33 = M1._31 * M2._13 + M1._32 * M2._23 + M1._33 * M2._33 + M1._34 * M2._43;
- m._34 = M1._31 * M2._14 + M1._32 * M2._24 + M1._33 * M2._34 + M1._34 * M2._44;
- m._41 = M1._41 * M2._11 + M1._42 * M2._21 + M1._43 * M2._31 + M1._44 * M2._41;
- m._42 = M1._41 * M2._12 + M1._42 * M2._22 + M1._43 * M2._32 + M1._44 * M2._42;
- m._43 = M1._41 * M2._13 + M1._42 * M2._23 + M1._43 * M2._33 + M1._44 * M2._43;
- m._44 = M1._41 * M2._14 + M1._42 * M2._24 + M1._43 * M2._34 + M1._44 * M2._44;
- return m;
-}
-
-static Float4X4 MatrixScaling(float x, float y, float z)
-{
- Float4X4 m;
- SDL_zero(m);
- m._11 = x;
- m._22 = y;
- m._33 = z;
- m._44 = 1.0f;
- return m;
-}
-
-static Float4X4 MatrixTranslation(float x, float y, float z)
-{
- Float4X4 m;
- SDL_zero(m);
- m._11 = 1.0f;
- m._22 = 1.0f;
- m._33 = 1.0f;
- m._44 = 1.0f;
- m._41 = x;
- m._42 = y;
- m._43 = z;
- return m;
-}
-
-static Float4X4 MatrixRotationX(float r)
-{
- float sinR = SDL_sinf(r);
- float cosR = SDL_cosf(r);
- Float4X4 m;
- SDL_zero(m);
- m._11 = 1.0f;
- m._22 = cosR;
- m._23 = sinR;
- m._32 = -sinR;
- m._33 = cosR;
- m._44 = 1.0f;
- return m;
-}
-
-static Float4X4 MatrixRotationY(float r)
-{
- float sinR = SDL_sinf(r);
- float cosR = SDL_cosf(r);
- Float4X4 m;
- SDL_zero(m);
- m._11 = cosR;
- m._13 = -sinR;
- m._22 = 1.0f;
- m._31 = sinR;
- m._33 = cosR;
- m._44 = 1.0f;
- return m;
-}
-
-static Float4X4 MatrixRotationZ(float r)
-{
- float sinR = SDL_sinf(r);
- float cosR = SDL_cosf(r);
- Float4X4 m;
- SDL_zero(m);
- m._11 = cosR;
- m._12 = sinR;
- m._21 = -sinR;
- m._22 = cosR;
- m._33 = 1.0f;
- m._44 = 1.0f;
- return m;
-}
-
/* Direct3D 11.1 renderer implementation */
static SDL_Renderer *D3D11_CreateRenderer(SDL_Window * window, Uint32 flags);
@@ -2803,12 +2665,11 @@ D3D11_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture,
minv = tmp;
}
- Float4X4 oldModelMatrix = rendererData->vertexShaderConstantsData.model;
- Float4X4 newModelMatrix = MatrixMultiply(
+ Float4X4 modelMatrix = MatrixMultiply(
MatrixRotationZ((float)(M_PI * (float) angle / 180.0f)),
MatrixTranslation(dstrect->x + center->x, dstrect->y + center->y, 0)
);
- D3D11_SetModelMatrix(renderer, &newModelMatrix);
+ D3D11_SetModelMatrix(renderer, &modelMatrix);
const float minx = -center->x;
const float maxx = dstrect->w - center->x;
@@ -2849,7 +2710,7 @@ D3D11_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture,
D3D11_RenderFinishDrawOp(renderer, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP, sizeof(vertices) / sizeof(VertexPositionColor));
- D3D11_SetModelMatrix(renderer, &oldModelMatrix);
+ D3D11_SetModelMatrix(renderer, NULL);
return 0;
}