mirror of
https://github.com/love2d/megasource.git
synced 2026-08-19 04:05:09 +02:00
Upgrade to SDL2.0.3.
This commit is contained in:
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
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: */
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
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: */
|
||||
@@ -50,6 +50,9 @@ static const SDL_RenderDriver *render_drivers[] = {
|
||||
#if SDL_VIDEO_RENDER_D3D
|
||||
&D3D_RenderDriver,
|
||||
#endif
|
||||
#if SDL_VIDEO_RENDER_D3D11
|
||||
&D3D11_RenderDriver,
|
||||
#endif
|
||||
#if SDL_VIDEO_RENDER_OGL
|
||||
&GL_RenderDriver,
|
||||
#endif
|
||||
|
||||
@@ -171,6 +171,9 @@ struct SDL_RenderDriver
|
||||
#if SDL_VIDEO_RENDER_D3D
|
||||
extern SDL_RenderDriver D3D_RenderDriver;
|
||||
#endif
|
||||
#if SDL_VIDEO_RENDER_D3D11
|
||||
extern SDL_RenderDriver D3D11_RenderDriver;
|
||||
#endif
|
||||
#if SDL_VIDEO_RENDER_OGL
|
||||
extern SDL_RenderDriver GL_RenderDriver;
|
||||
#endif
|
||||
|
||||
@@ -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");
|
||||
@@ -648,10 +541,9 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||
renderer->DestroyTexture = D3D_DestroyTexture;
|
||||
renderer->DestroyRenderer = D3D_DestroyRenderer;
|
||||
renderer->info = D3D_RenderDriver.info;
|
||||
renderer->info.flags = (SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE);
|
||||
renderer->driverdata = data;
|
||||
|
||||
renderer->info.flags = SDL_RENDERER_ACCELERATED;
|
||||
|
||||
SDL_VERSION(&windowinfo.version);
|
||||
SDL_GetWindowWMInfo(window, &windowinfo);
|
||||
|
||||
@@ -1698,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) {
|
||||
@@ -1769,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);
|
||||
|
||||
@@ -1823,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;
|
||||
}
|
||||
|
||||
@@ -1961,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);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
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"
|
||||
|
||||
#if SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED
|
||||
|
||||
#include "SDL_syswm.h"
|
||||
extern "C" {
|
||||
#include "../SDL_sysrender.h"
|
||||
}
|
||||
|
||||
#include <windows.ui.core.h>
|
||||
#include <windows.graphics.display.h>
|
||||
|
||||
#if WINAPI_FAMILY == WINAPI_FAMILY_APP
|
||||
#include <windows.ui.xaml.media.dxinterop.h>
|
||||
#endif
|
||||
|
||||
using namespace Windows::UI::Core;
|
||||
using namespace Windows::Graphics::Display;
|
||||
|
||||
#include <DXGI.h>
|
||||
|
||||
#include "SDL_render_winrt.h"
|
||||
|
||||
|
||||
extern "C" void *
|
||||
D3D11_GetCoreWindowFromSDLRenderer(SDL_Renderer * renderer)
|
||||
{
|
||||
SDL_Window * sdlWindow = renderer->window;
|
||||
if ( ! renderer->window ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SDL_SysWMinfo sdlWindowInfo;
|
||||
SDL_VERSION(&sdlWindowInfo.version);
|
||||
if ( ! SDL_GetWindowWMInfo(sdlWindow, &sdlWindowInfo) ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (sdlWindowInfo.subsystem != SDL_SYSWM_WINRT) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!sdlWindowInfo.info.winrt.window) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ABI::Windows::UI::Core::ICoreWindow *coreWindow = NULL;
|
||||
if (FAILED(sdlWindowInfo.info.winrt.window->QueryInterface(&coreWindow))) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
IUnknown *coreWindowAsIUnknown = NULL;
|
||||
coreWindow->QueryInterface(&coreWindowAsIUnknown);
|
||||
coreWindow->Release();
|
||||
|
||||
return coreWindowAsIUnknown;
|
||||
}
|
||||
|
||||
extern "C" DXGI_MODE_ROTATION
|
||||
D3D11_GetCurrentRotation()
|
||||
{
|
||||
#if NTDDI_VERSION > NTDDI_WIN8
|
||||
const DisplayOrientations currentOrientation = DisplayInformation::GetForCurrentView()->CurrentOrientation;
|
||||
#else
|
||||
const DisplayOrientations currentOrientation = DisplayProperties::CurrentOrientation;
|
||||
#endif
|
||||
|
||||
switch (currentOrientation) {
|
||||
|
||||
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
|
||||
/* Windows Phone rotations */
|
||||
case DisplayOrientations::Landscape:
|
||||
return DXGI_MODE_ROTATION_ROTATE90;
|
||||
case DisplayOrientations::Portrait:
|
||||
return DXGI_MODE_ROTATION_IDENTITY;
|
||||
case DisplayOrientations::LandscapeFlipped:
|
||||
return DXGI_MODE_ROTATION_ROTATE270;
|
||||
case DisplayOrientations::PortraitFlipped:
|
||||
return DXGI_MODE_ROTATION_ROTATE180;
|
||||
#else
|
||||
/* Non-Windows-Phone rotations (ex: Windows 8, Windows RT) */
|
||||
case DisplayOrientations::Landscape:
|
||||
return DXGI_MODE_ROTATION_IDENTITY;
|
||||
case DisplayOrientations::Portrait:
|
||||
return DXGI_MODE_ROTATION_ROTATE270;
|
||||
case DisplayOrientations::LandscapeFlipped:
|
||||
return DXGI_MODE_ROTATION_ROTATE180;
|
||||
case DisplayOrientations::PortraitFlipped:
|
||||
return DXGI_MODE_ROTATION_ROTATE90;
|
||||
#endif /* WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP */
|
||||
}
|
||||
|
||||
return DXGI_MODE_ROTATION_IDENTITY;
|
||||
}
|
||||
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
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"
|
||||
|
||||
#if SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED
|
||||
|
||||
#include "SDL_render.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void * D3D11_GetCoreWindowFromSDLRenderer(SDL_Renderer * renderer);
|
||||
DXGI_MODE_ROTATION D3D11_GetCurrentRotation();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
@@ -1,3 +1,24 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
/* list of OpenGL functions sorted alphabetically
|
||||
If you need to use a GL function from the SDL video subsystem,
|
||||
change its entry from SDL_PROC_UNUSED to SDL_PROC and rebuild.
|
||||
|
||||
@@ -447,7 +447,7 @@ GL_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||
renderer->GL_BindTexture = GL_BindTexture;
|
||||
renderer->GL_UnbindTexture = GL_UnbindTexture;
|
||||
renderer->info = GL_RenderDriver.info;
|
||||
renderer->info.flags = SDL_RENDERER_ACCELERATED;
|
||||
renderer->info.flags = (SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE);
|
||||
renderer->driverdata = data;
|
||||
renderer->window = window;
|
||||
|
||||
|
||||
@@ -1,3 +1,24 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
SDL_PROC(void, glBindTexture, (GLenum, GLuint))
|
||||
SDL_PROC(void, glBlendFunc, (GLenum, GLenum))
|
||||
SDL_PROC_OES(void, glBlendFuncSeparateOES, (GLenum, GLenum, GLenum, GLenum))
|
||||
|
||||
@@ -103,7 +103,7 @@ SDL_RenderDriver GLES_RenderDriver = {
|
||||
GLES_CreateRenderer,
|
||||
{
|
||||
"opengles",
|
||||
(SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC ),
|
||||
(SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC),
|
||||
1,
|
||||
{SDL_PIXELFORMAT_ABGR8888},
|
||||
0,
|
||||
|
||||
@@ -1,3 +1,24 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
SDL_PROC(void, glActiveTexture, (GLenum))
|
||||
SDL_PROC(void, glAttachShader, (GLuint, GLuint))
|
||||
SDL_PROC(void, glBindAttribLocation, (GLuint, GLuint, const char *))
|
||||
@@ -47,4 +68,4 @@ SDL_PROC(void, glFramebufferTexture2D, (GLenum, GLenum, GLenum, GLuint, GLint))
|
||||
SDL_PROC(GLenum, glCheckFramebufferStatus, (GLenum))
|
||||
SDL_PROC(void, glDeleteFramebuffers, (GLsizei, const GLuint *))
|
||||
SDL_PROC(GLint, glGetAttribLocation, (GLuint, const GLchar *))
|
||||
|
||||
|
||||
|
||||
@@ -1784,7 +1784,7 @@ GLES2_CreateRenderer(SDL_Window *window, Uint32 flags)
|
||||
return NULL;
|
||||
}
|
||||
renderer->info = GLES2_RenderDriver.info;
|
||||
renderer->info.flags = SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE;
|
||||
renderer->info.flags = (SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE);
|
||||
renderer->driverdata = data;
|
||||
renderer->window = window;
|
||||
|
||||
@@ -1805,6 +1805,14 @@ GLES2_CreateRenderer(SDL_Window *window, Uint32 flags)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#if __WINRT__
|
||||
/* DLudwig, 2013-11-29: ANGLE for WinRT doesn't seem to work unless VSync
|
||||
* is turned on. Not doing so will freeze the screen's contents to that
|
||||
* of the first drawn frame.
|
||||
*/
|
||||
flags |= SDL_RENDERER_PRESENTVSYNC;
|
||||
#endif
|
||||
|
||||
if (flags & SDL_RENDERER_PRESENTVSYNC) {
|
||||
SDL_GL_SetSwapInterval(1);
|
||||
} else {
|
||||
|
||||
@@ -375,7 +375,7 @@ PSP_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||
renderer->DestroyTexture = PSP_DestroyTexture;
|
||||
renderer->DestroyRenderer = PSP_DestroyRenderer;
|
||||
renderer->info = PSP_RenderDriver.info;
|
||||
renderer->info.flags = SDL_RENDERER_ACCELERATED;
|
||||
renderer->info.flags = (SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE);
|
||||
renderer->driverdata = data;
|
||||
renderer->window = window;
|
||||
|
||||
|
||||
@@ -1,3 +1,24 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user