author | Sam Lantinga <slouken@libsdl.org> |
Sun, 17 Feb 2013 23:30:47 -0800 | |
changeset 6895 | 031a1fd143ec |
parent 6885 | 700f1b25f77f |
child 6968 | 959d9bbbbea0 |
permissions | -rw-r--r-- |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 |
/* |
5535
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5484
diff
changeset
|
2 |
Simple DirectMedia Layer |
6885 | 3 |
Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org> |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4 |
|
5535
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5484
diff
changeset
|
5 |
This software is provided 'as-is', without any express or implied |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5484
diff
changeset
|
6 |
warranty. In no event will the authors be held liable for any damages |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5484
diff
changeset
|
7 |
arising from the use of this software. |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
8 |
|
5535
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5484
diff
changeset
|
9 |
Permission is granted to anyone to use this software for any purpose, |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5484
diff
changeset
|
10 |
including commercial applications, and to alter it and redistribute it |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5484
diff
changeset
|
11 |
freely, subject to the following restrictions: |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 |
|
5535
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5484
diff
changeset
|
13 |
1. The origin of this software must not be misrepresented; you must not |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5484
diff
changeset
|
14 |
claim that you wrote the original software. If you use this software |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5484
diff
changeset
|
15 |
in a product, an acknowledgment in the product documentation would be |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5484
diff
changeset
|
16 |
appreciated but is not required. |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5484
diff
changeset
|
17 |
2. Altered source versions must be plainly marked as such, and must not be |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5484
diff
changeset
|
18 |
misrepresented as being the original software. |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5484
diff
changeset
|
19 |
3. This notice may not be removed or altered from any source distribution. |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
20 |
*/ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
21 |
#include "SDL_config.h" |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
22 |
|
5226
710d00cb3a6a
Made it possible to disable the rendering subsystem with configure --disable-render
Sam Lantinga <slouken@libsdl.org>
parents:
5224
diff
changeset
|
23 |
#if SDL_VIDEO_RENDER_D3D && !SDL_RENDER_DISABLED |
710d00cb3a6a
Made it possible to disable the rendering subsystem with configure --disable-render
Sam Lantinga <slouken@libsdl.org>
parents:
5224
diff
changeset
|
24 |
|
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
25 |
|
5154
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
5149
diff
changeset
|
26 |
#include "../../core/windows/SDL_windows.h" |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
5149
diff
changeset
|
27 |
|
5484
e20c93bc9122
Added the SDL_HINT_RENDER_SCALE_QUALITY hint, which defaults to nearest pixel sampling.
Sam Lantinga <slouken@libsdl.org>
parents:
5299
diff
changeset
|
28 |
#include "SDL_hints.h" |
5154
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
5149
diff
changeset
|
29 |
#include "SDL_loadso.h" |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
5149
diff
changeset
|
30 |
#include "SDL_syswm.h" |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
5149
diff
changeset
|
31 |
#include "../SDL_sysrender.h" |
6320
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
32 |
#include "stdio.h" |
5154
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
5149
diff
changeset
|
33 |
|
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
5149
diff
changeset
|
34 |
#if SDL_VIDEO_RENDER_D3D |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
5149
diff
changeset
|
35 |
#define D3D_DEBUG_INFO |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
5149
diff
changeset
|
36 |
#include <d3d9.h> |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
5149
diff
changeset
|
37 |
#endif |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
38 |
|
6320
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
39 |
|
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
40 |
typedef interface ID3DXMatrixStack *LPD3DXMATRIXSTACK; |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
41 |
typedef struct _D3DMATRIX D3DXMATRIX, *LPD3DXMATRIX; |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
42 |
typedef struct _D3DVECTOR D3DXVECTOR3, *LPD3DXVECTOR3; |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
43 |
|
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
44 |
DEFINE_GUID(IID_ID3DXMatrixStack, |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
45 |
0xc7885ba7, 0xf990, 0x4fe7, 0x92, 0x2d, 0x85, 0x15, 0xe4, 0x77, 0xdd, 0x85); |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
46 |
|
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
47 |
#undef INTERFACE |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
48 |
#define INTERFACE ID3DXMatrixStack |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
49 |
|
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
50 |
DECLARE_INTERFACE_(ID3DXMatrixStack, IUnknown) |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
51 |
{ |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
52 |
STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
53 |
STDMETHOD_(ULONG,AddRef)(THIS) PURE; |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
54 |
STDMETHOD_(ULONG,Release)(THIS) PURE; |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
55 |
STDMETHOD(Pop)(THIS) PURE; |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
56 |
STDMETHOD(Push)(THIS) PURE; |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
57 |
STDMETHOD(LoadIdentity)(THIS) PURE; |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
58 |
STDMETHOD(LoadMatrix)(THIS_ CONST D3DXMATRIX* pM ) PURE; |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
59 |
STDMETHOD(MultMatrix)(THIS_ CONST D3DXMATRIX* pM ) PURE; |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
60 |
STDMETHOD(MultMatrixLocal)(THIS_ CONST D3DXMATRIX* pM ) PURE; |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
61 |
STDMETHOD(RotateAxis)(THIS_ CONST D3DXVECTOR3* pV, FLOAT Angle) PURE; |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
62 |
STDMETHOD(RotateAxisLocal)(THIS_ CONST D3DXVECTOR3* pV, FLOAT Angle) PURE; |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
63 |
STDMETHOD(RotateYawPitchRoll)(THIS_ FLOAT Yaw, FLOAT Pitch, FLOAT Roll) PURE; |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
64 |
STDMETHOD(RotateYawPitchRollLocal)(THIS_ FLOAT Yaw, FLOAT Pitch, FLOAT Roll) PURE; |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
65 |
STDMETHOD(Scale)(THIS_ FLOAT x, FLOAT y, FLOAT z) PURE; |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
66 |
STDMETHOD(ScaleLocal)(THIS_ FLOAT x, FLOAT y, FLOAT z) PURE; |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
67 |
STDMETHOD(Translate)(THIS_ FLOAT x, FLOAT y, FLOAT z ) PURE; |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
68 |
STDMETHOD(TranslateLocal)(THIS_ FLOAT x, FLOAT y, FLOAT z) PURE; |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
69 |
STDMETHOD_(D3DXMATRIX*, GetTop)(THIS) PURE; |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
70 |
}; |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
71 |
|
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
72 |
#undef INTERFACE |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
73 |
|
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
74 |
#if !defined(__cplusplus) || defined(CINTERFACE) |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
75 |
#define ID3DXMatrixStack_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
76 |
#define ID3DXMatrixStack_AddRef(p) (p)->lpVtbl->AddRef(p) |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
77 |
#define ID3DXMatrixStack_Release(p) (p)->lpVtbl->Release(p) |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
78 |
#define ID3DXMatrixStack_Pop(p) (p)->lpVtbl->Pop(p) |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
79 |
#define ID3DXMatrixStack_Push(p) (p)->lpVtbl->Push(p) |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
80 |
#define ID3DXMatrixStack_LoadIdentity(p) (p)->lpVtbl->LoadIdentity(p) |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
81 |
#define ID3DXMatrixStack_LoadMatrix(p,a) (p)->lpVtbl->LoadMatrix(p,a) |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
82 |
#define ID3DXMatrixStack_MultMatrix(p,a) (p)->lpVtbl->MultMatrix(p,a) |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
83 |
#define ID3DXMatrixStack_MultMatrixLocal(p,a) (p)->lpVtbl->MultMatrixLocal(p,a) |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
84 |
#define ID3DXMatrixStack_RotateAxis(p,a,b) (p)->lpVtbl->RotateAxis(p,a,b) |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
85 |
#define ID3DXMatrixStack_RotateAxisLocal(p,a,b) (p)->lpVtbl->RotateAxisLocal(p,a,b) |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
86 |
#define ID3DXMatrixStack_RotateYawPitchRoll(p,a,b,c) (p)->lpVtbl->RotateYawPitchRoll(p,a,b,c) |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
87 |
#define ID3DXMatrixStack_RotateYawPitchRollLocal(p,a,b,c) (p)->lpVtbl->RotateYawPitchRollLocal(p,a,b,c) |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
88 |
#define ID3DXMatrixStack_Scale(p,a,b,c) (p)->lpVtbl->Scale(p,a,b,c) |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
89 |
#define ID3DXMatrixStack_ScaleLocal(p,a,b,c) (p)->lpVtbl->ScaleLocal(p,a,b,c) |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
90 |
#define ID3DXMatrixStack_Translate(p,a,b,c) (p)->lpVtbl->Translate(p,a,b,c) |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
91 |
#define ID3DXMatrixStack_TranslateLocal(p,a,b,c) (p)->lpVtbl->TranslateLocal(p,a,b,c) |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
92 |
#define ID3DXMatrixStack_GetTop(p) (p)->lpVtbl->GetTop(p) |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
93 |
#else |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
94 |
#define ID3DXMatrixStack_QueryInterface(p,a,b) (p)->QueryInterface(a,b) |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
95 |
#define ID3DXMatrixStack_AddRef(p) (p)->AddRef() |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
96 |
#define ID3DXMatrixStack_Release(p) (p)->Release() |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
97 |
#define ID3DXMatrixStack_Pop(p) (p)->Pop() |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
98 |
#define ID3DXMatrixStack_Push(p) (p)->Push() |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
99 |
#define ID3DXMatrixStack_LoadIdentity(p) (p)->LoadIdentity() |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
100 |
#define ID3DXMatrixStack_LoadMatrix(p,a) (p)->LoadMatrix(a) |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
101 |
#define ID3DXMatrixStack_MultMatrix(p,a) (p)->MultMatrix(a) |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
102 |
#define ID3DXMatrixStack_MultMatrixLocal(p,a) (p)->MultMatrixLocal(a) |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
103 |
#define ID3DXMatrixStack_RotateAxis(p,a,b) (p)->RotateAxis(a,b) |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
104 |
#define ID3DXMatrixStack_RotateAxisLocal(p,a,b) (p)->RotateAxisLocal(a,b) |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
105 |
#define ID3DXMatrixStack_RotateYawPitchRoll(p,a,b,c) (p)->RotateYawPitchRollLocal(a,b,c) |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
106 |
#define ID3DXMatrixStack_Scale(p,a,b,c) (p)->Scale(a,b,c) |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
107 |
#define ID3DXMatrixStack_ScaleLocal(p,a,b,c) (p)->ScaleLocal(a,b,c) |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
108 |
#define ID3DXMatrixStack_Translate(p,a,b,c) (p)->Translate(a,b,c) |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
109 |
#define ID3DXMatrixStack_TranslateLocal(p,a,b,c) (p)->TranslateLocal(a,b,c) |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
110 |
#define ID3DXMatrixStack_GetTop(p) (p)->GetTop() |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
111 |
#endif |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
112 |
|
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
113 |
#ifdef __cplusplus |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
114 |
extern "C" { |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
115 |
#endif |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
116 |
|
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
117 |
HRESULT WINAPI D3DXCreateMatrixStack(DWORD flags, LPD3DXMATRIXSTACK* ppstack); |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
118 |
|
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
119 |
#ifdef __cplusplus |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
120 |
} |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
121 |
#endif |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
122 |
|
3556
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
123 |
#ifdef ASSEMBLE_SHADER |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
124 |
/////////////////////////////////////////////////////////////////////////// |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
125 |
// ID3DXBuffer: |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
126 |
// ------------ |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
127 |
// The buffer object is used by D3DX to return arbitrary size data. |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
128 |
// |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
129 |
// GetBufferPointer - |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
130 |
// Returns a pointer to the beginning of the buffer. |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
131 |
// |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
132 |
// GetBufferSize - |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
133 |
// Returns the size of the buffer, in bytes. |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
134 |
/////////////////////////////////////////////////////////////////////////// |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
135 |
|
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
136 |
typedef interface ID3DXBuffer ID3DXBuffer; |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
137 |
typedef interface ID3DXBuffer *LPD3DXBUFFER; |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
138 |
|
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
139 |
// {8BA5FB08-5195-40e2-AC58-0D989C3A0102} |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
140 |
DEFINE_GUID(IID_ID3DXBuffer, |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
141 |
0x8ba5fb08, 0x5195, 0x40e2, 0xac, 0x58, 0xd, 0x98, 0x9c, 0x3a, 0x1, 0x2); |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
142 |
|
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
143 |
#undef INTERFACE |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
144 |
#define INTERFACE ID3DXBuffer |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
145 |
|
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
146 |
typedef interface ID3DXBuffer { |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
147 |
const struct ID3DXBufferVtbl FAR* lpVtbl; |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
148 |
} ID3DXBuffer; |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
149 |
typedef const struct ID3DXBufferVtbl ID3DXBufferVtbl; |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
150 |
const struct ID3DXBufferVtbl |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
151 |
{ |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
152 |
// IUnknown |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
153 |
STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
154 |
STDMETHOD_(ULONG, AddRef)(THIS) PURE; |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
155 |
STDMETHOD_(ULONG, Release)(THIS) PURE; |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
156 |
|
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
157 |
// ID3DXBuffer |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
158 |
STDMETHOD_(LPVOID, GetBufferPointer)(THIS) PURE; |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
159 |
STDMETHOD_(DWORD, GetBufferSize)(THIS) PURE; |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
160 |
}; |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
161 |
|
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
162 |
HRESULT WINAPI |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
163 |
D3DXAssembleShader( |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
164 |
LPCSTR pSrcData, |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
165 |
UINT SrcDataLen, |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
166 |
CONST LPVOID* pDefines, |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
167 |
LPVOID pInclude, |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
168 |
DWORD Flags, |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
169 |
LPD3DXBUFFER* ppShader, |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
170 |
LPD3DXBUFFER* ppErrorMsgs); |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
171 |
|
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
172 |
#endif /* ASSEMBLE_SHADER */ |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
173 |
|
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
174 |
|
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
175 |
/* Direct3D renderer implementation */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
176 |
|
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
177 |
static SDL_Renderer *D3D_CreateRenderer(SDL_Window * window, Uint32 flags); |
5297
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
178 |
static void D3D_WindowEvent(SDL_Renderer * renderer, |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
179 |
const SDL_WindowEvent *event); |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
180 |
static int D3D_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture); |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
181 |
static int D3D_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
182 |
const SDL_Rect * rect, const void *pixels, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
183 |
int pitch); |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
184 |
static int D3D_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, |
5156
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
185 |
const SDL_Rect * rect, void **pixels, int *pitch); |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
186 |
static void D3D_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture); |
6247
b6212690f78d
Renamed SetTargetTexture() to SetRenderTarget()
Sam Lantinga <slouken@libsdl.org>
parents:
6246
diff
changeset
|
187 |
static int D3D_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture); |
5297
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
188 |
static int D3D_UpdateViewport(SDL_Renderer * renderer); |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
189 |
static int D3D_RenderClear(SDL_Renderer * renderer); |
3599
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
190 |
static int D3D_RenderDrawPoints(SDL_Renderer * renderer, |
6528
e978048ced60
Added SDL_RenderSetScale() and SDL_RenderGetScale()
Sam Lantinga <slouken@libsdl.org>
parents:
6404
diff
changeset
|
191 |
const SDL_FPoint * points, int count); |
3599
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
192 |
static int D3D_RenderDrawLines(SDL_Renderer * renderer, |
6528
e978048ced60
Added SDL_RenderSetScale() and SDL_RenderGetScale()
Sam Lantinga <slouken@libsdl.org>
parents:
6404
diff
changeset
|
193 |
const SDL_FPoint * points, int count); |
3599
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
194 |
static int D3D_RenderFillRects(SDL_Renderer * renderer, |
6528
e978048ced60
Added SDL_RenderSetScale() and SDL_RenderGetScale()
Sam Lantinga <slouken@libsdl.org>
parents:
6404
diff
changeset
|
195 |
const SDL_FRect * rects, int count); |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
196 |
static int D3D_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, |
6528
e978048ced60
Added SDL_RenderSetScale() and SDL_RenderGetScale()
Sam Lantinga <slouken@libsdl.org>
parents:
6404
diff
changeset
|
197 |
const SDL_Rect * srcrect, const SDL_FRect * dstrect); |
6320
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
198 |
static int D3D_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture, |
6528
e978048ced60
Added SDL_RenderSetScale() and SDL_RenderGetScale()
Sam Lantinga <slouken@libsdl.org>
parents:
6404
diff
changeset
|
199 |
const SDL_Rect * srcrect, const SDL_FRect * dstrect, |
e978048ced60
Added SDL_RenderSetScale() and SDL_RenderGetScale()
Sam Lantinga <slouken@libsdl.org>
parents:
6404
diff
changeset
|
200 |
const double angle, const SDL_FPoint * center, const SDL_RendererFlip flip); |
3427
36cf454ba065
Work in progress on implementation of SDL_RenderReadPixels() and SDL_RenderWritePixels(), code untested.
Sam Lantinga <slouken@libsdl.org>
parents:
3279
diff
changeset
|
201 |
static int D3D_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, |
3480
cd763d104465
The Direct3D Read/Write pixels interface is in progress.
Sam Lantinga <slouken@libsdl.org>
parents:
3427
diff
changeset
|
202 |
Uint32 format, void * pixels, int pitch); |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
203 |
static void D3D_RenderPresent(SDL_Renderer * renderer); |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
204 |
static void D3D_DestroyTexture(SDL_Renderer * renderer, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
205 |
SDL_Texture * texture); |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
206 |
static void D3D_DestroyRenderer(SDL_Renderer * renderer); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
207 |
|
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
208 |
|
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
209 |
SDL_RenderDriver D3D_RenderDriver = { |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
210 |
D3D_CreateRenderer, |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
211 |
{ |
5186
97d0480b420c
Updated the name of the Direct3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5184
diff
changeset
|
212 |
"direct3d", |
6237
240f1bced46b
Added a renderer flag to expose whether a renderer supports render to texture.
Sam Lantinga <slouken@libsdl.org>
parents:
6236
diff
changeset
|
213 |
(SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE), |
5156
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
214 |
1, |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
215 |
{SDL_PIXELFORMAT_ARGB8888}, |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
216 |
0, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
217 |
0} |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
218 |
}; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
219 |
|
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
220 |
typedef struct |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
221 |
{ |
5154
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
5149
diff
changeset
|
222 |
void* d3dDLL; |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
223 |
IDirect3D9 *d3d; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
224 |
IDirect3DDevice9 *device; |
3527
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
225 |
UINT adapter; |
1975
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
226 |
D3DPRESENT_PARAMETERS pparams; |
5297
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
227 |
SDL_bool updateSize; |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
228 |
SDL_bool beginScene; |
5484
e20c93bc9122
Added the SDL_HINT_RENDER_SCALE_QUALITY hint, which defaults to nearest pixel sampling.
Sam Lantinga <slouken@libsdl.org>
parents:
5299
diff
changeset
|
229 |
D3DTEXTUREFILTERTYPE scaleMode; |
6232
37e8d0736366
Implementation of render targets, by Mason Wheeler and Gabriel Jacobo
Sam Lantinga <slouken@libsdl.org>
parents:
6138
diff
changeset
|
230 |
IDirect3DSurface9 *defaultRenderTarget; |
37e8d0736366
Implementation of render targets, by Mason Wheeler and Gabriel Jacobo
Sam Lantinga <slouken@libsdl.org>
parents:
6138
diff
changeset
|
231 |
IDirect3DSurface9 *currentRenderTarget; |
6320
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
232 |
void* d3dxDLL; |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
233 |
ID3DXMatrixStack *matrixStack; |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
234 |
} D3D_RenderData; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
235 |
|
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
236 |
typedef struct |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
237 |
{ |
1903
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
238 |
IDirect3DTexture9 *texture; |
5484
e20c93bc9122
Added the SDL_HINT_RENDER_SCALE_QUALITY hint, which defaults to nearest pixel sampling.
Sam Lantinga <slouken@libsdl.org>
parents:
5299
diff
changeset
|
239 |
D3DTEXTUREFILTERTYPE scaleMode; |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
240 |
} D3D_TextureData; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
241 |
|
1903
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
242 |
typedef struct |
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
243 |
{ |
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
244 |
float x, y, z; |
1987
36a08379b3f2
Implemented color modulation in the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
245 |
DWORD color; |
1904
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
246 |
float u, v; |
1903
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
247 |
} Vertex; |
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
248 |
|
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
249 |
static void |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
250 |
D3D_SetError(const char *prefix, HRESULT result) |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
251 |
{ |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
252 |
const char *error; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
253 |
|
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
254 |
switch (result) { |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
255 |
case D3DERR_WRONGTEXTUREFORMAT: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
256 |
error = "WRONGTEXTUREFORMAT"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
257 |
break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
258 |
case D3DERR_UNSUPPORTEDCOLOROPERATION: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
259 |
error = "UNSUPPORTEDCOLOROPERATION"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
260 |
break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
261 |
case D3DERR_UNSUPPORTEDCOLORARG: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
262 |
error = "UNSUPPORTEDCOLORARG"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
263 |
break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
264 |
case D3DERR_UNSUPPORTEDALPHAOPERATION: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
265 |
error = "UNSUPPORTEDALPHAOPERATION"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
266 |
break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
267 |
case D3DERR_UNSUPPORTEDALPHAARG: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
268 |
error = "UNSUPPORTEDALPHAARG"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
269 |
break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
270 |
case D3DERR_TOOMANYOPERATIONS: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
271 |
error = "TOOMANYOPERATIONS"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
272 |
break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
273 |
case D3DERR_CONFLICTINGTEXTUREFILTER: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
274 |
error = "CONFLICTINGTEXTUREFILTER"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
275 |
break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
276 |
case D3DERR_UNSUPPORTEDFACTORVALUE: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
277 |
error = "UNSUPPORTEDFACTORVALUE"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
278 |
break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
279 |
case D3DERR_CONFLICTINGRENDERSTATE: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
280 |
error = "CONFLICTINGRENDERSTATE"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
281 |
break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
282 |
case D3DERR_UNSUPPORTEDTEXTUREFILTER: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
283 |
error = "UNSUPPORTEDTEXTUREFILTER"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
284 |
break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
285 |
case D3DERR_CONFLICTINGTEXTUREPALETTE: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
286 |
error = "CONFLICTINGTEXTUREPALETTE"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
287 |
break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
288 |
case D3DERR_DRIVERINTERNALERROR: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
289 |
error = "DRIVERINTERNALERROR"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
290 |
break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
291 |
case D3DERR_NOTFOUND: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
292 |
error = "NOTFOUND"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
293 |
break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
294 |
case D3DERR_MOREDATA: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
295 |
error = "MOREDATA"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
296 |
break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
297 |
case D3DERR_DEVICELOST: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
298 |
error = "DEVICELOST"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
299 |
break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
300 |
case D3DERR_DEVICENOTRESET: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
301 |
error = "DEVICENOTRESET"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
302 |
break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
303 |
case D3DERR_NOTAVAILABLE: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
304 |
error = "NOTAVAILABLE"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
305 |
break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
306 |
case D3DERR_OUTOFVIDEOMEMORY: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
307 |
error = "OUTOFVIDEOMEMORY"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
308 |
break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
309 |
case D3DERR_INVALIDDEVICE: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
310 |
error = "INVALIDDEVICE"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
311 |
break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
312 |
case D3DERR_INVALIDCALL: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
313 |
error = "INVALIDCALL"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
314 |
break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
315 |
case D3DERR_DRIVERINVALIDCALL: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
316 |
error = "DRIVERINVALIDCALL"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
317 |
break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
318 |
case D3DERR_WASSTILLDRAWING: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
319 |
error = "WASSTILLDRAWING"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
320 |
break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
321 |
default: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
322 |
error = "UNKNOWN"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
323 |
break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
324 |
} |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
325 |
SDL_SetError("%s: %s", prefix, error); |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
326 |
} |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
327 |
|
1903
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
328 |
static D3DFORMAT |
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
329 |
PixelFormatToD3DFMT(Uint32 format) |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
330 |
{ |
1903
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
331 |
switch (format) { |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
332 |
case SDL_PIXELFORMAT_RGB565: |
1903
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
333 |
return D3DFMT_R5G6B5; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
334 |
case SDL_PIXELFORMAT_RGB888: |
1903
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
335 |
return D3DFMT_X8R8G8B8; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
336 |
case SDL_PIXELFORMAT_ARGB8888: |
1903
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
337 |
return D3DFMT_A8R8G8B8; |
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
338 |
default: |
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
339 |
return D3DFMT_UNKNOWN; |
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
340 |
} |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
341 |
} |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
342 |
|
5156
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
343 |
static Uint32 |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
344 |
D3DFMTToPixelFormat(D3DFORMAT format) |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
345 |
{ |
5156
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
346 |
switch (format) { |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
347 |
case D3DFMT_R5G6B5: |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
348 |
return SDL_PIXELFORMAT_RGB565; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
349 |
case D3DFMT_X8R8G8B8: |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
350 |
return SDL_PIXELFORMAT_RGB888; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
351 |
case D3DFMT_A8R8G8B8: |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
352 |
return SDL_PIXELFORMAT_ARGB8888; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
353 |
default: |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
354 |
return SDL_PIXELFORMAT_UNKNOWN; |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
355 |
} |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
356 |
} |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
357 |
|
5297
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
358 |
static int |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
359 |
D3D_Reset(SDL_Renderer * renderer) |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
360 |
{ |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
361 |
D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
362 |
HRESULT result; |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
363 |
|
6860
c16fc4e46ae5
Fixed bug 1491 - Directx3d Crash on resize
Sam Lantinga <slouken@libsdl.org>
parents:
6782
diff
changeset
|
364 |
/* Release the default render target before reset */ |
6895
031a1fd143ec
Fixed bug 1722 - An attempt to release NULL Direct3d surface
Sam Lantinga <slouken@libsdl.org>
parents:
6885
diff
changeset
|
365 |
if (data->defaultRenderTarget) { |
031a1fd143ec
Fixed bug 1722 - An attempt to release NULL Direct3d surface
Sam Lantinga <slouken@libsdl.org>
parents:
6885
diff
changeset
|
366 |
IDirect3DSurface9_Release(data->defaultRenderTarget); |
031a1fd143ec
Fixed bug 1722 - An attempt to release NULL Direct3d surface
Sam Lantinga <slouken@libsdl.org>
parents:
6885
diff
changeset
|
367 |
data->defaultRenderTarget = NULL; |
031a1fd143ec
Fixed bug 1722 - An attempt to release NULL Direct3d surface
Sam Lantinga <slouken@libsdl.org>
parents:
6885
diff
changeset
|
368 |
} |
6860
c16fc4e46ae5
Fixed bug 1491 - Directx3d Crash on resize
Sam Lantinga <slouken@libsdl.org>
parents:
6782
diff
changeset
|
369 |
|
5297
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
370 |
result = IDirect3DDevice9_Reset(data->device, &data->pparams); |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
371 |
if (FAILED(result)) { |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
372 |
if (result == D3DERR_DEVICELOST) { |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
373 |
/* Don't worry about it, we'll reset later... */ |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
374 |
return 0; |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
375 |
} else { |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
376 |
D3D_SetError("Reset()", result); |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
377 |
return -1; |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
378 |
} |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
379 |
} |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
380 |
IDirect3DDevice9_SetVertexShader(data->device, NULL); |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
381 |
IDirect3DDevice9_SetFVF(data->device, |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
382 |
D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1); |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
383 |
IDirect3DDevice9_SetRenderState(data->device, D3DRS_CULLMODE, |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
384 |
D3DCULL_NONE); |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
385 |
IDirect3DDevice9_SetRenderState(data->device, D3DRS_LIGHTING, FALSE); |
6860
c16fc4e46ae5
Fixed bug 1491 - Directx3d Crash on resize
Sam Lantinga <slouken@libsdl.org>
parents:
6782
diff
changeset
|
386 |
IDirect3DDevice9_GetRenderTarget(data->device, 0, &data->defaultRenderTarget); |
5297
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
387 |
return 0; |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
388 |
} |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
389 |
|
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
390 |
static int |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
391 |
D3D_ActivateRenderer(SDL_Renderer * renderer) |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
392 |
{ |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
393 |
D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
394 |
HRESULT result; |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
395 |
|
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
396 |
if (data->updateSize) { |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
397 |
SDL_Window *window = renderer->window; |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
398 |
int w, h; |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
399 |
|
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
400 |
SDL_GetWindowSize(window, &w, &h); |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
401 |
data->pparams.BackBufferWidth = w; |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
402 |
data->pparams.BackBufferHeight = h; |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
403 |
if (SDL_GetWindowFlags(window) & SDL_WINDOW_FULLSCREEN) { |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
404 |
data->pparams.BackBufferFormat = |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
405 |
PixelFormatToD3DFMT(SDL_GetWindowPixelFormat(window)); |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
406 |
} else { |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
407 |
data->pparams.BackBufferFormat = D3DFMT_UNKNOWN; |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
408 |
} |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
409 |
if (D3D_Reset(renderer) < 0) { |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
410 |
return -1; |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
411 |
} |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
412 |
D3D_UpdateViewport(renderer); |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
413 |
|
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
414 |
data->updateSize = SDL_FALSE; |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
415 |
} |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
416 |
if (data->beginScene) { |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
417 |
result = IDirect3DDevice9_BeginScene(data->device); |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
418 |
if (result == D3DERR_DEVICELOST) { |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
419 |
if (D3D_Reset(renderer) < 0) { |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
420 |
return -1; |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
421 |
} |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
422 |
result = IDirect3DDevice9_BeginScene(data->device); |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
423 |
} |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
424 |
if (FAILED(result)) { |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
425 |
D3D_SetError("BeginScene()", result); |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
426 |
return -1; |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
427 |
} |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
428 |
data->beginScene = SDL_FALSE; |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
429 |
} |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
430 |
return 0; |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
431 |
} |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
432 |
|
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
433 |
SDL_Renderer * |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
434 |
D3D_CreateRenderer(SDL_Window * window, Uint32 flags) |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
435 |
{ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
436 |
SDL_Renderer *renderer; |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
437 |
D3D_RenderData *data; |
5154
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
5149
diff
changeset
|
438 |
SDL_SysWMinfo windowinfo; |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
439 |
HRESULT result; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
440 |
D3DPRESENT_PARAMETERS pparams; |
1907
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
441 |
IDirect3DSwapChain9 *chain; |
1925
411bfb37082b
Query the maximum texture size for the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
442 |
D3DCAPS9 caps; |
5156
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
443 |
Uint32 window_flags; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
444 |
int w, h; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
445 |
SDL_DisplayMode fullscreen_mode; |
5297
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
446 |
D3DMATRIX matrix; |
6320
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
447 |
int d3dxVersion; |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
448 |
char d3dxDLLFile[50]; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
449 |
|
1920
8a162bfdc838
Convert SDL_malloc to SDL_calloc if appropriate, slightly faster on operating systems which map the zero page for memory allocations.
Sam Lantinga <slouken@libsdl.org>
parents:
1918
diff
changeset
|
450 |
renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer)); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
451 |
if (!renderer) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
452 |
SDL_OutOfMemory(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
453 |
return NULL; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
454 |
} |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
455 |
|
1920
8a162bfdc838
Convert SDL_malloc to SDL_calloc if appropriate, slightly faster on operating systems which map the zero page for memory allocations.
Sam Lantinga <slouken@libsdl.org>
parents:
1918
diff
changeset
|
456 |
data = (D3D_RenderData *) SDL_calloc(1, sizeof(*data)); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
457 |
if (!data) { |
5154
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
5149
diff
changeset
|
458 |
SDL_free(renderer); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
459 |
SDL_OutOfMemory(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
460 |
return NULL; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
461 |
} |
5154
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
5149
diff
changeset
|
462 |
|
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
5149
diff
changeset
|
463 |
data->d3dDLL = SDL_LoadObject("D3D9.DLL"); |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
5149
diff
changeset
|
464 |
if (data->d3dDLL) { |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
5149
diff
changeset
|
465 |
IDirect3D9 *(WINAPI * D3DCreate) (UINT SDKVersion); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
466 |
|
5154
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
5149
diff
changeset
|
467 |
D3DCreate = |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
5149
diff
changeset
|
468 |
(IDirect3D9 * (WINAPI *) (UINT)) SDL_LoadFunction(data->d3dDLL, |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
5149
diff
changeset
|
469 |
"Direct3DCreate9"); |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
5149
diff
changeset
|
470 |
if (D3DCreate) { |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
5149
diff
changeset
|
471 |
data->d3d = D3DCreate(D3D_SDK_VERSION); |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
5149
diff
changeset
|
472 |
} |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
5149
diff
changeset
|
473 |
if (!data->d3d) { |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
5149
diff
changeset
|
474 |
SDL_UnloadObject(data->d3dDLL); |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
5149
diff
changeset
|
475 |
data->d3dDLL = NULL; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
5149
diff
changeset
|
476 |
} |
6320
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
477 |
|
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
478 |
for (d3dxVersion=50;d3dxVersion>0;d3dxVersion--) { |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
479 |
SDL_snprintf(d3dxDLLFile, 49, "D3DX9_%02d.dll", d3dxVersion); |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
480 |
data->d3dxDLL = SDL_LoadObject(d3dxDLLFile); |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
481 |
if (data->d3dxDLL) { |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
482 |
HRESULT (WINAPI *D3DXCreateMatrixStack) (DWORD Flags, LPD3DXMATRIXSTACK* ppStack); |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
483 |
D3DXCreateMatrixStack = (HRESULT (WINAPI *) (DWORD, LPD3DXMATRIXSTACK*)) SDL_LoadFunction(data->d3dxDLL, "D3DXCreateMatrixStack"); |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
484 |
if (D3DXCreateMatrixStack) { |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
485 |
D3DXCreateMatrixStack(0, &data->matrixStack); |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
486 |
break; |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
487 |
} |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
488 |
} |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
489 |
} |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
490 |
|
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
491 |
if (!data->matrixStack) { |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
492 |
if (data->d3dxDLL) SDL_UnloadObject(data->d3dxDLL); |
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
493 |
} |
5154
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
5149
diff
changeset
|
494 |
} |
6320
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
495 |
|
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
496 |
|
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
497 |
|
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
498 |
if (!data->d3d || !data->matrixStack) { |
5154
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
5149
diff
changeset
|
499 |
SDL_free(renderer); |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
5149
diff
changeset
|
500 |
SDL_free(data); |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
5149
diff
changeset
|
501 |
SDL_SetError("Unable to create Direct3D interface"); |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
5149
diff
changeset
|
502 |
return NULL; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
5149
diff
changeset
|
503 |
} |
4569 | 504 |
|
5297
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
505 |
renderer->WindowEvent = D3D_WindowEvent; |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
506 |
renderer->CreateTexture = D3D_CreateTexture; |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
507 |
renderer->UpdateTexture = D3D_UpdateTexture; |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
508 |
renderer->LockTexture = D3D_LockTexture; |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
509 |
renderer->UnlockTexture = D3D_UnlockTexture; |
6247
b6212690f78d
Renamed SetTargetTexture() to SetRenderTarget()
Sam Lantinga <slouken@libsdl.org>
parents:
6246
diff
changeset
|
510 |
renderer->SetRenderTarget = D3D_SetRenderTarget; |
5297
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
511 |
renderer->UpdateViewport = D3D_UpdateViewport; |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
512 |
renderer->RenderClear = D3D_RenderClear; |
3599
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
513 |
renderer->RenderDrawPoints = D3D_RenderDrawPoints; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
514 |
renderer->RenderDrawLines = D3D_RenderDrawLines; |
3675 | 515 |
renderer->RenderFillRects = D3D_RenderFillRects; |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
516 |
renderer->RenderCopy = D3D_RenderCopy; |
6320
6077a1310907
RenderCopyEx,rotation and flipping for all hardware/software backends (#1308)
Gabriel Jacobo <gabomdq@gmail.com>
parents:
6247
diff
changeset
|
517 |
renderer->RenderCopyEx = D3D_RenderCopyEx; |
3427
36cf454ba065
Work in progress on implementation of SDL_RenderReadPixels() and SDL_RenderWritePixels(), code untested.
Sam Lantinga <slouken@libsdl.org>
parents:
3279
diff
changeset
|
518 |
renderer->RenderReadPixels = D3D_RenderReadPixels; |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
519 |
renderer->RenderPresent = D3D_RenderPresent; |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
520 |
renderer->DestroyTexture = D3D_DestroyTexture; |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
521 |
renderer->DestroyRenderer = D3D_DestroyRenderer; |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
522 |
renderer->info = D3D_RenderDriver.info; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
523 |
renderer->driverdata = data; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
524 |
|
6246
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6242
diff
changeset
|
525 |
renderer->info.flags = SDL_RENDERER_ACCELERATED; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
526 |
|
5154
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
5149
diff
changeset
|
527 |
SDL_VERSION(&windowinfo.version); |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
5149
diff
changeset
|
528 |
SDL_GetWindowWMInfo(window, &windowinfo); |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
5149
diff
changeset
|
529 |
|
5156
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
530 |
window_flags = SDL_GetWindowFlags(window); |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
531 |
SDL_GetWindowSize(window, &w, &h); |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
532 |
SDL_GetWindowDisplayMode(window, &fullscreen_mode); |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
533 |
|
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
534 |
SDL_zero(pparams); |
5154
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
5149
diff
changeset
|
535 |
pparams.hDeviceWindow = windowinfo.info.win.window; |
5156
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
536 |
pparams.BackBufferWidth = w; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
537 |
pparams.BackBufferHeight = h; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
538 |
if (window_flags & SDL_WINDOW_FULLSCREEN) { |
1903
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
539 |
pparams.BackBufferFormat = |
5156
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
540 |
PixelFormatToD3DFMT(fullscreen_mode.format); |
1903
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
541 |
} else { |
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
542 |
pparams.BackBufferFormat = D3DFMT_UNKNOWN; |
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
543 |
} |
5142
c8e049de174c
Making the API simpler, the renderer present semantics are always having a backbuffer and then discarding it. This is best for hardware accelerated rendering.
Sam Lantinga <slouken@libsdl.org>
parents:
5141
diff
changeset
|
544 |
pparams.BackBufferCount = 1; |
c8e049de174c
Making the API simpler, the renderer present semantics are always having a backbuffer and then discarding it. This is best for hardware accelerated rendering.
Sam Lantinga <slouken@libsdl.org>
parents:
5141
diff
changeset
|
545 |
pparams.SwapEffect = D3DSWAPEFFECT_DISCARD; |
c8e049de174c
Making the API simpler, the renderer present semantics are always having a backbuffer and then discarding it. This is best for hardware accelerated rendering.
Sam Lantinga <slouken@libsdl.org>
parents:
5141
diff
changeset
|
546 |
|
5156
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
547 |
if (window_flags & SDL_WINDOW_FULLSCREEN) { |
6782
582d35419e8a
Improvements from Alfred:
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
548 |
if ( ( window_flags & SDL_WINDOW_FULLSCREEN_DESKTOP ) == SDL_WINDOW_FULLSCREEN_DESKTOP ) { |
582d35419e8a
Improvements from Alfred:
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
549 |
pparams.Windowed = TRUE; |
582d35419e8a
Improvements from Alfred:
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
550 |
pparams.FullScreen_RefreshRateInHz = 0; |
582d35419e8a
Improvements from Alfred:
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
551 |
} else { |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
552 |
pparams.Windowed = FALSE; |
1903
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
553 |
pparams.FullScreen_RefreshRateInHz = |
5156
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
554 |
fullscreen_mode.refresh_rate; |
6782
582d35419e8a
Improvements from Alfred:
Sam Lantinga <slouken@libsdl.org>
parents:
6528
diff
changeset
|
555 |
} |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
556 |
} else { |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
557 |
pparams.Windowed = TRUE; |
1903
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
558 |
pparams.FullScreen_RefreshRateInHz = 0; |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
559 |
} |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
560 |
if (flags & SDL_RENDERER_PRESENTVSYNC) { |
1907
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
561 |
pparams.PresentationInterval = D3DPRESENT_INTERVAL_ONE; |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
562 |
} else { |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
563 |
pparams.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
564 |
} |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
565 |
|
5154
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
5149
diff
changeset
|
566 |
/* FIXME: Which adapter? */ |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
5149
diff
changeset
|
567 |
data->adapter = D3DADAPTER_DEFAULT; |
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
5149
diff
changeset
|
568 |
IDirect3D9_GetDeviceCaps(data->d3d, data->adapter, D3DDEVTYPE_HAL, &caps); |
3197 | 569 |
|
5154
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
5149
diff
changeset
|
570 |
result = IDirect3D9_CreateDevice(data->d3d, data->adapter, |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
571 |
D3DDEVTYPE_HAL, |
5154
fb424691cfc7
Moved the rendering code out to a separate directory in the hope that it can someday be completely decoupled from the rest of the library and be expanded to an awesome 2D on 3D library.
Sam Lantinga <slouken@libsdl.org>
parents:
5149
diff
changeset
|
572 |
pparams.hDeviceWindow, |
6115
d4621a7e0faa
Fixed bug 1338 - Direct3D renderer should set D3DCREATE_FPU_PRESERVE for not behaving vastly different on doubles (causes 3rd party lib crashes!)
Sam Lantinga <slouken@libsdl.org>
parents:
6076
diff
changeset
|
573 |
D3DCREATE_FPU_PRESERVE | ((caps. |
3197 | 574 |
DevCaps & |
575 |
D3DDEVCAPS_HWTRANSFORMANDLIGHT) ? |
|
576 |
D3DCREATE_HARDWARE_VERTEXPROCESSING : |
|
6115
d4621a7e0faa
Fixed bug 1338 - Direct3D renderer should set D3DCREATE_FPU_PRESERVE for not behaving vastly different on doubles (causes 3rd party lib crashes!)
Sam Lantinga <slouken@libsdl.org>
parents:
6076
diff
changeset
|
577 |
D3DCREATE_SOFTWARE_VERTEXPROCESSING), |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
578 |
&pparams, &data->device); |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
579 |
if (FAILED(result)) { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
580 |
D3D_DestroyRenderer(renderer); |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
581 |
D3D_SetError("CreateDevice()", result); |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
582 |
return NULL; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
583 |
} |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
584 |
data->beginScene = SDL_TRUE; |
5484
e20c93bc9122
Added the SDL_HINT_RENDER_SCALE_QUALITY hint, which defaults to nearest pixel sampling.
Sam Lantinga <slouken@libsdl.org>
parents:
5299
diff
changeset
|
585 |
data->scaleMode = D3DTEXF_FORCE_DWORD; |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
586 |
|
1907
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
587 |
/* Get presentation parameters to fill info */ |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
588 |
result = IDirect3DDevice9_GetSwapChain(data->device, 0, &chain); |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
589 |
if (FAILED(result)) { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
590 |
D3D_DestroyRenderer(renderer); |
1907
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
591 |
D3D_SetError("GetSwapChain()", result); |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
592 |
return NULL; |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
593 |
} |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
594 |
result = IDirect3DSwapChain9_GetPresentParameters(chain, &pparams); |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
595 |
if (FAILED(result)) { |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
596 |
IDirect3DSwapChain9_Release(chain); |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
597 |
D3D_DestroyRenderer(renderer); |
1907
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
598 |
D3D_SetError("GetPresentParameters()", result); |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
599 |
return NULL; |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
600 |
} |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
601 |
IDirect3DSwapChain9_Release(chain); |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
602 |
if (pparams.PresentationInterval == D3DPRESENT_INTERVAL_ONE) { |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
603 |
renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC; |
1907
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
604 |
} |
1975
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
605 |
data->pparams = pparams; |
1907
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
606 |
|
1925
411bfb37082b
Query the maximum texture size for the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
607 |
IDirect3DDevice9_GetDeviceCaps(data->device, &caps); |
411bfb37082b
Query the maximum texture size for the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
608 |
renderer->info.max_texture_width = caps.MaxTextureWidth; |
411bfb37082b
Query the maximum texture size for the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
609 |
renderer->info.max_texture_height = caps.MaxTextureHeight; |
6246
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6242
diff
changeset
|
610 |
if (caps.NumSimultaneousRTs >= 2) { |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6242
diff
changeset
|
611 |
renderer->info.flags |= SDL_RENDERER_TARGETTEXTURE; |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6242
diff
changeset
|
612 |
} |
1918
092bd3a019c5
Starting on the OpenGL renderer...
Sam Lantinga <slouken@libsdl.org>
parents:
1917
diff
changeset
|
613 |
|
1903
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
614 |
/* Set up parameters for rendering */ |
1904
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
615 |
IDirect3DDevice9_SetVertexShader(data->device, NULL); |
1987
36a08379b3f2
Implemented color modulation in the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
616 |
IDirect3DDevice9_SetFVF(data->device, |
5297
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
617 |
D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1); |
1988
1ee02169bbb0
Figured out how texture stages work, thanks to this:
Sam Lantinga <slouken@libsdl.org>
parents:
1987
diff
changeset
|
618 |
IDirect3DDevice9_SetRenderState(data->device, D3DRS_ZENABLE, D3DZB_FALSE); |
1903
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
619 |
IDirect3DDevice9_SetRenderState(data->device, D3DRS_CULLMODE, |
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
620 |
D3DCULL_NONE); |
1904
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
621 |
IDirect3DDevice9_SetRenderState(data->device, D3DRS_LIGHTING, FALSE); |
1988
1ee02169bbb0
Figured out how texture stages work, thanks to this:
Sam Lantinga <slouken@libsdl.org>
parents:
1987
diff
changeset
|
622 |
/* Enable color modulation by diffuse color */ |
1ee02169bbb0
Figured out how texture stages work, thanks to this:
Sam Lantinga <slouken@libsdl.org>
parents:
1987
diff
changeset
|
623 |
IDirect3DDevice9_SetTextureStageState(data->device, 0, D3DTSS_COLOROP, |
1ee02169bbb0
Figured out how texture stages work, thanks to this:
Sam Lantinga <slouken@libsdl.org>
parents:
1987
diff
changeset
|
624 |
D3DTOP_MODULATE); |
1ee02169bbb0
Figured out how texture stages work, thanks to this:
Sam Lantinga <slouken@libsdl.org>
parents:
1987
diff
changeset
|
625 |
IDirect3DDevice9_SetTextureStageState(data->device, 0, D3DTSS_COLORARG1, |
1ee02169bbb0
Figured out how texture stages work, thanks to this:
Sam Lantinga <slouken@libsdl.org>
parents:
1987
diff
changeset
|
626 |
D3DTA_TEXTURE); |
1ee02169bbb0
Figured out how texture stages work, thanks to this:
Sam Lantinga <slouken@libsdl.org>
parents:
1987
diff
changeset
|
627 |
IDirect3DDevice9_SetTextureStageState(data->device, 0, D3DTSS_COLORARG2, |
1ee02169bbb0
Figured out how texture stages work, thanks to this:
Sam Lantinga <slouken@libsdl.org>
parents:
1987
diff
changeset
|
628 |
D3DTA_DIFFUSE); |
1ee02169bbb0
Figured out how texture stages work, thanks to this:
Sam Lantinga <slouken@libsdl.org>
parents:
1987
diff
changeset
|
629 |
/* Enable alpha modulation by diffuse alpha */ |
1ee02169bbb0
Figured out how texture stages work, thanks to this:
Sam Lantinga <slouken@libsdl.org>
parents:
1987
diff
changeset
|
630 |
IDirect3DDevice9_SetTextureStageState(data->device, 0, D3DTSS_ALPHAOP, |
1ee02169bbb0
Figured out how texture stages work, thanks to this:
Sam Lantinga <slouken@libsdl.org>
parents:
1987
diff
changeset
|
631 |
D3DTOP_MODULATE); |
1ee02169bbb0
Figured out how texture stages work, thanks to this:
Sam Lantinga <slouken@libsdl.org>
parents:
1987
diff
changeset
|
632 |
IDirect3DDevice9_SetTextureStageState(data->device, 0, D3DTSS_ALPHAARG1, |
1ee02169bbb0
Figured out how texture stages work, thanks to this:
Sam Lantinga <slouken@libsdl.org>
parents:
1987
diff
changeset
|
633 |
D3DTA_TEXTURE); |
1ee02169bbb0
Figured out how texture stages work, thanks to this:
Sam Lantinga <slouken@libsdl.org>
parents:
1987
diff
changeset
|
634 |
IDirect3DDevice9_SetTextureStageState(data->device, 0, D3DTSS_ALPHAARG2, |
1ee02169bbb0
Figured out how texture stages work, thanks to this:
Sam Lantinga <slouken@libsdl.org>
parents:
1987
diff
changeset
|
635 |
D3DTA_DIFFUSE); |
1991
3863ba81c1d6
Clear the second texture stage explicitly
Sam Lantinga <slouken@libsdl.org>
parents:
1988
diff
changeset
|
636 |
/* Disable second texture stage, since we're done */ |
3863ba81c1d6
Clear the second texture stage explicitly
Sam Lantinga <slouken@libsdl.org>
parents:
1988
diff
changeset
|
637 |
IDirect3DDevice9_SetTextureStageState(data->device, 1, D3DTSS_COLOROP, |
3863ba81c1d6
Clear the second texture stage explicitly
Sam Lantinga <slouken@libsdl.org>
parents:
1988
diff
changeset
|
638 |
D3DTOP_DISABLE); |
3863ba81c1d6
Clear the second texture stage explicitly
Sam Lantinga <slouken@libsdl.org>
parents:
1988
diff
changeset
|
639 |
IDirect3DDevice9_SetTextureStageState(data->device, 1, D3DTSS_ALPHAOP, |
3863ba81c1d6
Clear the second texture stage explicitly
Sam Lantinga <slouken@libsdl.org>
parents:
1988
diff
changeset
|
640 |
D3DTOP_DISABLE); |
1903
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
641 |
|
6232
37e8d0736366
Implementation of render targets, by Mason Wheeler and Gabriel Jacobo
Sam Lantinga <slouken@libsdl.org>
parents:
6138
diff
changeset
|
642 |
/* Store the default render target */ |
37e8d0736366
Implementation of render targets, by Mason Wheeler and Gabriel Jacobo
Sam Lantinga <slouken@libsdl.org>
parents:
6138
diff
changeset
|
643 |
IDirect3DDevice9_GetRenderTarget(data->device, 0, &data->defaultRenderTarget ); |
37e8d0736366
Implementation of render targets, by Mason Wheeler and Gabriel Jacobo
Sam Lantinga <slouken@libsdl.org>
parents:
6138
diff
changeset
|
644 |
data->currentRenderTarget = NULL; |
37e8d0736366
Implementation of render targets, by Mason Wheeler and Gabriel Jacobo
Sam Lantinga <slouken@libsdl.org>
parents:
6138
diff
changeset
|
645 |
|
5297
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
646 |
/* Set an identity world and view matrix */ |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
647 |
matrix.m[0][0] = 1.0f; |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
648 |
matrix.m[0][1] = 0.0f; |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
649 |
matrix.m[0][2] = 0.0f; |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
650 |
matrix.m[0][3] = 0.0f; |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
651 |
matrix.m[1][0] = 0.0f; |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
652 |
matrix.m[1][1] = 1.0f; |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
653 |
matrix.m[1][2] = 0.0f; |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
654 |
matrix.m[1][3] = 0.0f; |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
655 |
matrix.m[2][0] = 0.0f; |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
656 |
matrix.m[2][1] = 0.0f; |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
657 |
matrix.m[2][2] = 1.0f; |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
658 |
matrix.m[2][3] = 0.0f; |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
659 |
matrix.m[3][0] = 0.0f; |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
660 |
matrix.m[3][1] = 0.0f; |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
661 |
matrix.m[3][2] = 0.0f; |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
662 |
matrix.m[3][3] = 1.0f; |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
663 |
IDirect3DDevice9_SetTransform(data->device, D3DTS_WORLD, &matrix); |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
664 |
IDirect3DDevice9_SetTransform(data->device, D3DTS_VIEW, &matrix); |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
665 |
|
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
666 |
return renderer; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
667 |
} |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
668 |
|
5297
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
669 |
static void |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
670 |
D3D_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event) |
1975
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
671 |
{ |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
672 |
D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
673 |
|
5297
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
674 |
if (event->event == SDL_WINDOWEVENT_SIZE_CHANGED) { |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
675 |
data->updateSize = SDL_TRUE; |
1975
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
676 |
} |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
677 |
} |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
678 |
|
5484
e20c93bc9122
Added the SDL_HINT_RENDER_SCALE_QUALITY hint, which defaults to nearest pixel sampling.
Sam Lantinga <slouken@libsdl.org>
parents:
5299
diff
changeset
|
679 |
static D3DTEXTUREFILTERTYPE |
e20c93bc9122
Added the SDL_HINT_RENDER_SCALE_QUALITY hint, which defaults to nearest pixel sampling.
Sam Lantinga <slouken@libsdl.org>
parents:
5299
diff
changeset
|
680 |
GetScaleQuality(void) |
e20c93bc9122
Added the SDL_HINT_RENDER_SCALE_QUALITY hint, which defaults to nearest pixel sampling.
Sam Lantinga <slouken@libsdl.org>
parents:
5299
diff
changeset
|
681 |
{ |
e20c93bc9122
Added the SDL_HINT_RENDER_SCALE_QUALITY hint, which defaults to nearest pixel sampling.
Sam Lantinga <slouken@libsdl.org>
parents:
5299
diff
changeset
|
682 |
const char *hint = SDL_GetHint(SDL_HINT_RENDER_SCALE_QUALITY); |
e20c93bc9122
Added the SDL_HINT_RENDER_SCALE_QUALITY hint, which defaults to nearest pixel sampling.
Sam Lantinga <slouken@libsdl.org>
parents:
5299
diff
changeset
|
683 |
|
e20c93bc9122
Added the SDL_HINT_RENDER_SCALE_QUALITY hint, which defaults to nearest pixel sampling.
Sam Lantinga <slouken@libsdl.org>
parents:
5299
diff
changeset
|
684 |
if (!hint || *hint == '0' || SDL_strcasecmp(hint, "nearest") == 0) { |
e20c93bc9122
Added the SDL_HINT_RENDER_SCALE_QUALITY hint, which defaults to nearest pixel sampling.
Sam Lantinga <slouken@libsdl.org>
parents:
5299
diff
changeset
|
685 |
return D3DTEXF_POINT; |
e20c93bc9122
Added the SDL_HINT_RENDER_SCALE_QUALITY hint, which defaults to nearest pixel sampling.
Sam Lantinga <slouken@libsdl.org>
parents:
5299
diff
changeset
|
686 |
} else if (*hint == '1' || SDL_strcasecmp(hint, "linear") == 0) { |
e20c93bc9122
Added the SDL_HINT_RENDER_SCALE_QUALITY hint, which defaults to nearest pixel sampling.
Sam Lantinga <slouken@libsdl.org>
parents:
5299
diff
changeset
|
687 |
return D3DTEXF_LINEAR; |
e20c93bc9122
Added the SDL_HINT_RENDER_SCALE_QUALITY hint, which defaults to nearest pixel sampling.
Sam Lantinga <slouken@libsdl.org>
parents:
5299
diff
changeset
|
688 |
} else { |
e20c93bc9122
Added the SDL_HINT_RENDER_SCALE_QUALITY hint, which defaults to nearest pixel sampling.
Sam Lantinga <slouken@libsdl.org>
parents:
5299
diff
changeset
|
689 |
return D3DTEXF_ANISOTROPIC; |
e20c93bc9122
Added the SDL_HINT_RENDER_SCALE_QUALITY hint, which defaults to nearest pixel sampling.
Sam Lantinga <slouken@libsdl.org>
parents:
5299
diff
changeset
|
690 |
} |
e20c93bc9122
Added the SDL_HINT_RENDER_SCALE_QUALITY hint, which defaults to nearest pixel sampling.
Sam Lantinga <slouken@libsdl.org>
parents:
5299
diff
changeset
|
691 |
} |
e20c93bc9122
Added the SDL_HINT_RENDER_SCALE_QUALITY hint, which defaults to nearest pixel sampling.
Sam Lantinga <slouken@libsdl.org>
parents:
5299
diff
changeset
|
692 |
|
1975
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
693 |
static int |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
694 |
D3D_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
695 |
{ |
6404
724e1fba7933
Whoops, removed wrong variable.
Ryan C. Gordon <icculus@icculus.org>
parents:
6403
diff
changeset
|
696 |
D3D_RenderData *renderdata = (D3D_RenderData *) renderer->driverdata; |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
697 |
D3D_TextureData *data; |
5173
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
698 |
D3DPOOL pool; |
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
699 |
DWORD usage; |
1903
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
700 |
HRESULT result; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
701 |
|
1920
8a162bfdc838
Convert SDL_malloc to SDL_calloc if appropriate, slightly faster on operating systems which map the zero page for memory allocations.
Sam Lantinga <slouken@libsdl.org>
parents:
1918
diff
changeset
|
702 |
data = (D3D_TextureData *) SDL_calloc(1, sizeof(*data)); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
703 |
if (!data) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
704 |
SDL_OutOfMemory(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
705 |
return -1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
706 |
} |
5484
e20c93bc9122
Added the SDL_HINT_RENDER_SCALE_QUALITY hint, which defaults to nearest pixel sampling.
Sam Lantinga <slouken@libsdl.org>
parents:
5299
diff
changeset
|
707 |
data->scaleMode = GetScaleQuality(); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
708 |
|
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
709 |
texture->driverdata = data; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
710 |
|
5173
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
711 |
#ifdef USE_DYNAMIC_TEXTURE |
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
712 |
if (texture->access == SDL_TEXTUREACCESS_STREAMING) { |
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
713 |
pool = D3DPOOL_DEFAULT; |
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
714 |
usage = D3DUSAGE_DYNAMIC; |
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
715 |
} else |
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
716 |
#endif |
6232
37e8d0736366
Implementation of render targets, by Mason Wheeler and Gabriel Jacobo
Sam Lantinga <slouken@libsdl.org>
parents:
6138
diff
changeset
|
717 |
if (texture->access == SDL_TEXTUREACCESS_TARGET) { |
6246
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6242
diff
changeset
|
718 |
/* D3DPOOL_MANAGED does not work with D3DUSAGE_RENDERTARGET */ |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6242
diff
changeset
|
719 |
pool = D3DPOOL_DEFAULT; |
6232
37e8d0736366
Implementation of render targets, by Mason Wheeler and Gabriel Jacobo
Sam Lantinga <slouken@libsdl.org>
parents:
6138
diff
changeset
|
720 |
usage = D3DUSAGE_RENDERTARGET; |
6246
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6242
diff
changeset
|
721 |
} else { |
5173
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
722 |
pool = D3DPOOL_MANAGED; |
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
723 |
usage = 0; |
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
724 |
} |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
725 |
|
1903
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
726 |
result = |
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
727 |
IDirect3DDevice9_CreateTexture(renderdata->device, texture->w, |
5173
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
728 |
texture->h, 1, usage, |
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
729 |
PixelFormatToD3DFMT(texture->format), |
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
730 |
pool, &data->texture, NULL); |
1903
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
731 |
if (FAILED(result)) { |
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
732 |
D3D_SetError("CreateTexture()", result); |
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
733 |
return -1; |
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
734 |
} |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
735 |
|
1903
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
736 |
return 0; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
737 |
} |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
738 |
|
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
739 |
static int |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
740 |
D3D_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
741 |
const SDL_Rect * rect, const void *pixels, int pitch) |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
742 |
{ |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
743 |
D3D_TextureData *data = (D3D_TextureData *) texture->driverdata; |
5156
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
744 |
RECT d3drect; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
745 |
D3DLOCKED_RECT locked; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
746 |
const Uint8 *src; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
747 |
Uint8 *dst; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
748 |
int row, length; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
749 |
HRESULT result; |
1903
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
750 |
|
5173
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
751 |
#ifdef USE_DYNAMIC_TEXTURE |
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
752 |
if (texture->access == SDL_TEXTUREACCESS_STREAMING && |
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
753 |
rect->x == 0 && rect->y == 0 && |
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
754 |
rect->w == texture->w && rect->h == texture->h) { |
5194 | 755 |
result = IDirect3DTexture9_LockRect(data->texture, 0, &locked, NULL, D3DLOCK_DISCARD); |
5173
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
756 |
} else |
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
757 |
#endif |
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
758 |
{ |
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
759 |
d3drect.left = rect->x; |
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
760 |
d3drect.right = rect->x + rect->w; |
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
761 |
d3drect.top = rect->y; |
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
762 |
d3drect.bottom = rect->y + rect->h; |
5194 | 763 |
result = IDirect3DTexture9_LockRect(data->texture, 0, &locked, &d3drect, 0); |
5156
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
764 |
} |
1903
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
765 |
|
5156
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
766 |
if (FAILED(result)) { |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
767 |
D3D_SetError("LockRect()", result); |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
768 |
return -1; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
769 |
} |
2783
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
770 |
|
5156
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
771 |
src = pixels; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
772 |
dst = locked.pBits; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
773 |
length = rect->w * SDL_BYTESPERPIXEL(texture->format); |
5173
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
774 |
if (length == pitch && length == locked.Pitch) { |
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
775 |
SDL_memcpy(dst, src, length*rect->h); |
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
776 |
} else { |
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
777 |
for (row = 0; row < rect->h; ++row) { |
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
778 |
SDL_memcpy(dst, src, length); |
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
779 |
src += pitch; |
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
780 |
dst += locked.Pitch; |
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
781 |
} |
5156
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
782 |
} |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
783 |
IDirect3DTexture9_UnlockRect(data->texture, 0); |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
784 |
|
5156
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
785 |
return 0; |
2783
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
786 |
} |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
787 |
|
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
788 |
static int |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
789 |
D3D_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, |
5156
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
790 |
const SDL_Rect * rect, void **pixels, int *pitch) |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
791 |
{ |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
792 |
D3D_TextureData *data = (D3D_TextureData *) texture->driverdata; |
5156
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
793 |
RECT d3drect; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
794 |
D3DLOCKED_RECT locked; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
795 |
HRESULT result; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
796 |
|
5156
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
797 |
d3drect.left = rect->x; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
798 |
d3drect.right = rect->x + rect->w; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
799 |
d3drect.top = rect->y; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
800 |
d3drect.bottom = rect->y + rect->h; |
1903
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
801 |
|
5156
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
802 |
result = IDirect3DTexture9_LockRect(data->texture, 0, &locked, &d3drect, 0); |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
803 |
if (FAILED(result)) { |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
804 |
D3D_SetError("LockRect()", result); |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
805 |
return -1; |
1903
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
806 |
} |
5156
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
807 |
*pixels = locked.pBits; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
808 |
*pitch = locked.Pitch; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
809 |
return 0; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
810 |
} |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
811 |
|
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
812 |
static void |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
813 |
D3D_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture) |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
814 |
{ |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
815 |
D3D_TextureData *data = (D3D_TextureData *) texture->driverdata; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
816 |
|
5156
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5154
diff
changeset
|
817 |
IDirect3DTexture9_UnlockRect(data->texture, 0); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
818 |
} |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
819 |
|
5297
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
820 |
static int |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
821 |
D3D_UpdateViewport(SDL_Renderer * renderer) |
5224
2178ffe17222
Added function SDL_RenderSetClipRect()
Sam Lantinga <slouken@libsdl.org>
parents:
5203
diff
changeset
|
822 |
{ |
2178ffe17222
Added function SDL_RenderSetClipRect()
Sam Lantinga <slouken@libsdl.org>
parents:
5203
diff
changeset
|
823 |
D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; |
5297
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
824 |
D3DVIEWPORT9 viewport; |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
825 |
D3DMATRIX matrix; |
5224
2178ffe17222
Added function SDL_RenderSetClipRect()
Sam Lantinga <slouken@libsdl.org>
parents:
5203
diff
changeset
|
826 |
|
5297
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
827 |
/* Set the viewport */ |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
828 |
viewport.X = renderer->viewport.x; |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
829 |
viewport.Y = renderer->viewport.y; |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
830 |
viewport.Width = renderer->viewport.w; |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
831 |
viewport.Height = renderer->viewport.h; |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
832 |
viewport.MinZ = 0.0f; |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
833 |
viewport.MaxZ = 1.0f; |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
834 |
IDirect3DDevice9_SetViewport(data->device, &viewport); |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
835 |
|
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
836 |
/* Set an orthographic projection matrix */ |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
837 |
matrix.m[0][0] = 2.0f / renderer->viewport.w; |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
838 |
matrix.m[0][1] = 0.0f; |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
839 |
matrix.m[0][2] = 0.0f; |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
840 |
matrix.m[0][3] = 0.0f; |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
841 |
matrix.m[1][0] = 0.0f; |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
842 |
matrix.m[1][1] = -2.0f / renderer->viewport.h; |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
843 |
matrix.m[1][2] = 0.0f; |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
844 |
matrix.m[1][3] = 0.0f; |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
845 |
matrix.m[2][0] = 0.0f; |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
846 |
matrix.m[2][1] = 0.0f; |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
847 |
matrix.m[2][2] = 1.0f; |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
848 |
matrix.m[2][3] = 0.0f; |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
849 |
matrix.m[3][0] = -1.0f; |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
850 |
matrix.m[3][1] = 1.0f; |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
851 |
matrix.m[3][2] = 0.0f; |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
852 |
matrix.m[3][3] = 1.0f; |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
853 |
IDirect3DDevice9_SetTransform(data->device, D3DTS_PROJECTION, &matrix); |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
854 |
|
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
855 |
return 0; |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
856 |
} |
5224
2178ffe17222
Added function SDL_RenderSetClipRect()
Sam Lantinga <slouken@libsdl.org>
parents:
5203
diff
changeset
|
857 |
|
5297
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
858 |
static int |
6247
b6212690f78d
Renamed SetTargetTexture() to SetRenderTarget()
Sam Lantinga <slouken@libsdl.org>
parents:
6246
diff
changeset
|
859 |
D3D_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture) |
6246
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6242
diff
changeset
|
860 |
{ |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6242
diff
changeset
|
861 |
D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6242
diff
changeset
|
862 |
D3D_TextureData *texturedata; |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6242
diff
changeset
|
863 |
HRESULT result; |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6242
diff
changeset
|
864 |
|
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6242
diff
changeset
|
865 |
D3D_ActivateRenderer(renderer); |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6242
diff
changeset
|
866 |
|
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6242
diff
changeset
|
867 |
/* Release the previous render target if it wasn't the default one */ |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6242
diff
changeset
|
868 |
if (data->currentRenderTarget != NULL) { |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6242
diff
changeset
|
869 |
IDirect3DSurface9_Release(data->currentRenderTarget); |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6242
diff
changeset
|
870 |
data->currentRenderTarget = NULL; |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6242
diff
changeset
|
871 |
} |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6242
diff
changeset
|
872 |
|
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6242
diff
changeset
|
873 |
if (texture == NULL) { |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6242
diff
changeset
|
874 |
IDirect3DDevice9_SetRenderTarget(data->device, 0, data->defaultRenderTarget); |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6242
diff
changeset
|
875 |
return 0; |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6242
diff
changeset
|
876 |
} |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6242
diff
changeset
|
877 |
|
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6242
diff
changeset
|
878 |
texturedata = (D3D_TextureData *) texture->driverdata; |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6242
diff
changeset
|
879 |
result = IDirect3DTexture9_GetSurfaceLevel(texturedata->texture, 0, &data->currentRenderTarget); |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6242
diff
changeset
|
880 |
if(FAILED(result)) { |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6242
diff
changeset
|
881 |
D3D_SetError("GetSurfaceLevel()", result); |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6242
diff
changeset
|
882 |
return -1; |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6242
diff
changeset
|
883 |
} |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6242
diff
changeset
|
884 |
result = IDirect3DDevice9_SetRenderTarget(data->device, 0, data->currentRenderTarget); |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6242
diff
changeset
|
885 |
if(FAILED(result)) { |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6242
diff
changeset
|
886 |
D3D_SetError("SetRenderTarget()", result); |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6242
diff
changeset
|
887 |
return -1; |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6242
diff
changeset
|
888 |
} |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6242
diff
changeset
|
889 |
|
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6242
diff
changeset
|
890 |
return 0; |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6242
diff
changeset
|
891 |
} |
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6242
diff
changeset
|
892 |
|
c70ec935a4bb
Reorganized the render target code, moving the viewport handling to the general code and adding software implementation.
Sam Lantinga <slouken@libsdl.org>
parents:
6242
diff
changeset
|
893 |
static int |
5297
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
894 |
D3D_RenderClear(SDL_Renderer * renderer) |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
895 |
{ |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
896 |
D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
897 |
DWORD color; |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
898 |
HRESULT result; |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
899 |
|
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
900 |
if (D3D_ActivateRenderer(renderer) < 0) { |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
901 |
return -1; |
5224
2178ffe17222
Added function SDL_RenderSetClipRect()
Sam Lantinga <slouken@libsdl.org>
parents:
5203
diff
changeset
|
902 |
} |
5297
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
903 |
|
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
904 |
color = D3DCOLOR_ARGB(renderer->a, renderer->r, renderer->g, renderer->b); |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
905 |
|
5299
33987021a1ed
Don't reset the viewport unless you have to.
Sam Lantinga <slouken@libsdl.org>
parents:
5297
diff
changeset
|
906 |
/* Don't reset the viewport if we don't have to! */ |
33987021a1ed
Don't reset the viewport unless you have to.
Sam Lantinga <slouken@libsdl.org>
parents:
5297
diff
changeset
|
907 |
if (!renderer->viewport.x && !renderer->viewport.y && |
33987021a1ed
Don't reset the viewport unless you have to.
Sam Lantinga <slouken@libsdl.org>
parents:
5297
diff
changeset
|
908 |
renderer->viewport.w == data->pparams.BackBufferWidth && |
33987021a1ed
Don't reset the viewport unless you have to.
Sam Lantinga <slouken@libsdl.org>
parents:
5297
diff
changeset
|
909 |
renderer->viewport.h == data->pparams.BackBufferHeight) { |
33987021a1ed
Don't reset the viewport unless you have to.
Sam Lantinga <slouken@libsdl.org>
parents:
5297
diff
changeset
|
910 |
result = IDirect3DDevice9_Clear(data->device, 0, NULL, D3DCLEAR_TARGET, color, 0.0f, 0); |
33987021a1ed
Don't reset the viewport unless you have to.
Sam Lantinga <slouken@libsdl.org>
parents:
5297
diff
changeset
|
911 |
} else { |
33987021a1ed
Don't reset the viewport unless you have to.
Sam Lantinga <slouken@libsdl.org>
parents:
5297
diff
changeset
|
912 |
D3DVIEWPORT9 viewport; |
5297
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
913 |
|
5299
33987021a1ed
Don't reset the viewport unless you have to.
Sam Lantinga <slouken@libsdl.org>
parents:
5297
diff
changeset
|
914 |
/* Clear is defined to clear the entire render target */ |
33987021a1ed
Don't reset the viewport unless you have to.
Sam Lantinga <slouken@libsdl.org>
parents:
5297
diff
changeset
|
915 |
viewport.X = 0; |
33987021a1ed
Don't reset the viewport unless you have to.
Sam Lantinga <slouken@libsdl.org>
parents:
5297
diff
changeset
|
916 |
viewport.Y = 0; |
33987021a1ed
Don't reset the viewport unless you have to.
Sam Lantinga <slouken@libsdl.org>
parents:
5297
diff
changeset
|
917 |
viewport.Width = data->pparams.BackBufferWidth; |
33987021a1ed
Don't reset the viewport unless you have to.
Sam Lantinga <slouken@libsdl.org>
parents:
5297
diff
changeset
|
918 |
viewport.Height = data->pparams.BackBufferHeight; |
33987021a1ed
Don't reset the viewport unless you have to.
Sam Lantinga <slouken@libsdl.org>
parents:
5297
diff
changeset
|
919 |
viewport.MinZ = 0.0f; |
33987021a1ed
Don't reset the viewport unless you have to.
Sam Lantinga <slouken@libsdl.org>
parents:
5297
diff
changeset
|
920 |
viewport.MaxZ = 1.0f; |
33987021a1ed
Don't reset the viewport unless you have to.
Sam Lantinga <slouken@libsdl.org>
parents:
5297
diff
changeset
|
921 |
IDirect3DDevice9_SetViewport(data->device, &viewport); |
33987021a1ed
Don't reset the viewport unless you have to.
Sam Lantinga <slouken@libsdl.org>
parents:
5297
diff
changeset
|
922 |
|
33987021a1ed
Don't reset the viewport unless you have to.
Sam Lantinga <slouken@libsdl.org>
parents:
5297
diff
changeset
|
923 |
result = IDirect3DDevice9_Clear(data->device, 0, NULL, D3DCLEAR_TARGET, color, 0.0f, 0); |
33987021a1ed
Don't reset the viewport unless you have to.
Sam Lantinga <slouken@libsdl.org>
parents:
5297
diff
changeset
|
924 |
|
33987021a1ed
Don't reset the viewport unless you have to.
Sam Lantinga <slouken@libsdl.org>
parents:
5297
diff
changeset
|
925 |
/* Reset the viewport */ |
33987021a1ed
Don't reset the viewport unless you have to.
Sam Lantinga <slouken@libsdl.org>
parents:
5297
diff
changeset
|
926 |
viewport.X = renderer->viewport.x; |
33987021a1ed
Don't reset the viewport unless you have to.
Sam Lantinga <slouken@libsdl.org>
parents:
5297
diff
changeset
|
927 |
viewport.Y = renderer->viewport.y; |
33987021a1ed
Don't reset the viewport unless you have to.
Sam Lantinga <slouken@libsdl.org>
parents:
5297
diff
changeset
|
928 |
viewport.Width = renderer->viewport.w; |
33987021a1ed
Don't reset the viewport unless you have to.
Sam Lantinga <slouken@libsdl.org>
parents:
5297
diff
changeset
|
929 |
viewport.Height = renderer->viewport.h; |
33987021a1ed
Don't reset the viewport unless you have to.
Sam Lantinga <slouken@libsdl.org>
parents:
5297
diff
changeset
|
930 |
viewport.MinZ = 0.0f; |
33987021a1ed
Don't reset the viewport unless you have to.
Sam Lantinga <slouken@libsdl.org>
parents:
5297
diff
changeset
|
931 |
viewport.MaxZ = 1.0f; |
33987021a1ed
Don't reset the viewport unless you have to.
Sam Lantinga <slouken@libsdl.org>
parents:
5297
diff
changeset
|
932 |
IDirect3DDevice9_SetViewport(data->device, &viewport); |
33987021a1ed
Don't reset the viewport unless you have to.
Sam Lantinga <slouken@libsdl.org>
parents:
5297
diff
changeset
|
933 |
} |
5297
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
934 |
|
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
935 |
if (FAILED(result)) { |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
936 |
D3D_SetError("Clear()", result); |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
937 |
return -1; |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
938 |
} |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
939 |
return 0; |
5224
2178ffe17222
Added function SDL_RenderSetClipRect()
Sam Lantinga <slouken@libsdl.org>
parents:
5203
diff
changeset
|
940 |
} |
2178ffe17222
Added function SDL_RenderSetClipRect()
Sam Lantinga <slouken@libsdl.org>
parents:
5203
diff
changeset
|
941 |
|
2178ffe17222
Added function SDL_RenderSetClipRect()
Sam Lantinga <slouken@libsdl.org>
parents:
5203
diff
changeset
|
942 |
static void |
2933 | 943 |
D3D_SetBlendMode(D3D_RenderData * data, int blendMode) |
2932
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
944 |
{ |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
945 |
switch (blendMode) { |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
946 |
case SDL_BLENDMODE_NONE: |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
947 |
IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE, |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
948 |
FALSE); |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
949 |
break; |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
950 |
case SDL_BLENDMODE_BLEND: |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
951 |
IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE, |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
952 |
TRUE); |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
953 |
IDirect3DDevice9_SetRenderState(data->device, D3DRS_SRCBLEND, |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
954 |
D3DBLEND_SRCALPHA); |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
955 |
IDirect3DDevice9_SetRenderState(data->device, D3DRS_DESTBLEND, |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
956 |
D3DBLEND_INVSRCALPHA); |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
957 |
break; |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
958 |
case SDL_BLENDMODE_ADD: |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
959 |
IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE, |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
960 |
TRUE); |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
961 |
IDirect3DDevice9_SetRenderState(data->device, D3DRS_SRCBLEND, |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
962 |
D3DBLEND_SRCALPHA); |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
963 |
IDirect3DDevice9_SetRenderState(data->device, D3DRS_DESTBLEND, |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
964 |
D3DBLEND_ONE); |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
965 |
break; |
5184
d976b67150c5
Restored SDL_BLENDMODE_MOD for MAME
Sam Lantinga <slouken@libsdl.org>
parents:
5173
diff
changeset
|
966 |
case SDL_BLENDMODE_MOD: |
d976b67150c5
Restored SDL_BLENDMODE_MOD for MAME
Sam Lantinga <slouken@libsdl.org>
parents:
5173
diff
changeset
|
967 |
IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE, |
d976b67150c5
Restored SDL_BLENDMODE_MOD for MAME
Sam Lantinga <slouken@libsdl.org>
parents:
5173
diff
changeset
|
968 |
TRUE); |
d976b67150c5
Restored SDL_BLENDMODE_MOD for MAME
Sam Lantinga <slouken@libsdl.org>
parents:
5173
diff
changeset
|
969 |
IDirect3DDevice9_SetRenderState(data->device, D3DRS_SRCBLEND, |
d976b67150c5
Restored SDL_BLENDMODE_MOD for MAME
Sam Lantinga <slouken@libsdl.org>
parents:
5173
diff
changeset
|
970 |
D3DBLEND_ZERO); |
d976b67150c5
Restored SDL_BLENDMODE_MOD for MAME
Sam Lantinga <slouken@libsdl.org>
parents:
5173
diff
changeset
|
971 |
IDirect3DDevice9_SetRenderState(data->device, D3DRS_DESTBLEND, |
d976b67150c5
Restored SDL_BLENDMODE_MOD for MAME
Sam Lantinga <slouken@libsdl.org>
parents:
5173
diff
changeset
|
972 |
D3DBLEND_SRCCOLOR); |
d976b67150c5
Restored SDL_BLENDMODE_MOD for MAME
Sam Lantinga <slouken@libsdl.org>
parents:
5173
diff
changeset
|
973 |
break; |
2932
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
974 |
} |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
975 |
} |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
976 |
|
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
977 |
static int |
6528
e978048ced60
Added SDL_RenderSetScale() and SDL_RenderGetScale()
Sam Lantinga <slouken@libsdl.org>
parents:
6404
diff
changeset
|
978 |
D3D_RenderDrawPoints(SDL_Renderer * renderer, const SDL_FPoint * points, |
3599
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
979 |
int count) |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
980 |
{ |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
981 |
D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; |
2932
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
982 |
DWORD color; |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
983 |
Vertex *vertices; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
984 |
int i; |
2932
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
985 |
HRESULT result; |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
986 |
|
5297
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
987 |
if (D3D_ActivateRenderer(renderer) < 0) { |
1800dc39b74c
Changed the concept of a render clip rect to a render viewport.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
988 |
return -1; |
2932
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
989 |
} |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
990 |
|
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
991 |
D3D_SetBlendMode(data, renderer->blendMode); |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
992 |
|
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
993 |
result = |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
994 |
IDirect3DDevice9_SetTexture(data->device, 0, |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
995 |
(IDirect3DBaseTexture9 *) 0); |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
996 |
if (FAILED(result)) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
997 |
D3D_SetError("SetTexture()", result); |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
998 |
return -1; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
999 |
} |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
di |