Mercurial > sdl-ios-xcode
annotate src/render/direct3d/SDL_d3drender.c @ 5157: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.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Wed, 02 Feb 2011 14:34:54 -0800 |
parents | src/video/windows/SDL_d3drender.c@be02be2ea897 |
children | 307ccc9c135e |
rev | line source |
---|---|
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 /* |
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
|
2 SDL - Simple DirectMedia Layer |
3697 | 3 Copyright (C) 1997-2010 Sam Lantinga |
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 |
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
|
5 This library is free software; you can redistribute it and/or |
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
|
6 modify it under the terms of the GNU Lesser General Public |
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
|
7 License as published by the Free Software Foundation; either |
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 version 2.1 of the License, or (at your option) any later version. |
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
|
9 |
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
|
10 This library is distributed in the hope that it will be useful, |
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
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
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 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
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
|
13 Lesser General Public License for more details. |
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
|
14 |
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
|
15 You should have received a copy of the GNU Lesser General Public |
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
|
16 License along with this library; if not, write to the Free Software |
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
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
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
|
18 |
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
|
19 Sam Lantinga |
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 slouken@libsdl.org |
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 */ |
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 #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
|
23 |
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
|
24 #if SDL_VIDEO_RENDER_D3D |
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 |
5157
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:
5152
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:
5152
diff
changeset
|
27 |
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:
5152
diff
changeset
|
28 #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:
5152
diff
changeset
|
29 #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:
5152
diff
changeset
|
30 #include "../SDL_sysrender.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:
5152
diff
changeset
|
31 #include "../../video/SDL_yuv_sw_c.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:
5152
diff
changeset
|
32 |
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:
5152
diff
changeset
|
33 #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:
5152
diff
changeset
|
34 #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:
5152
diff
changeset
|
35 #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:
5152
diff
changeset
|
36 #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
|
37 |
3556
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
38 #ifdef ASSEMBLE_SHADER |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
39 /////////////////////////////////////////////////////////////////////////// |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
40 // ID3DXBuffer: |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
41 // ------------ |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
42 // 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
|
43 // |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
44 // GetBufferPointer - |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
45 // 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
|
46 // |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
47 // GetBufferSize - |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
48 // 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
|
49 /////////////////////////////////////////////////////////////////////////// |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
50 |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
51 typedef interface ID3DXBuffer ID3DXBuffer; |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
52 typedef interface ID3DXBuffer *LPD3DXBUFFER; |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
53 |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
54 // {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
|
55 DEFINE_GUID(IID_ID3DXBuffer, |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
56 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
|
57 |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
58 #undef INTERFACE |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
59 #define INTERFACE ID3DXBuffer |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
60 |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
61 typedef interface ID3DXBuffer { |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
62 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
|
63 } ID3DXBuffer; |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
64 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
|
65 const struct ID3DXBufferVtbl |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
66 { |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
67 // IUnknown |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
68 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
|
69 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
|
70 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
|
71 |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
72 // ID3DXBuffer |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
73 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
|
74 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
|
75 }; |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
76 |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
77 HRESULT WINAPI |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
78 D3DXAssembleShader( |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
79 LPCSTR pSrcData, |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
80 UINT SrcDataLen, |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
81 CONST LPVOID* pDefines, |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
82 LPVOID pInclude, |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
83 DWORD Flags, |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
84 LPD3DXBUFFER* ppShader, |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
85 LPD3DXBUFFER* ppErrorMsgs); |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
86 |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
87 #endif /* ASSEMBLE_SHADER */ |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
88 |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
89 |
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
|
90 /* 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
|
91 |
2786 | 92 #if 1 /* This takes more memory but you won't lose your texture data */ |
2932
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
93 #define D3DPOOL_SDL D3DPOOL_MANAGED |
2783
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
94 #define SDL_MEMORY_POOL_MANAGED |
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
95 #else |
2932
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
96 #define D3DPOOL_SDL D3DPOOL_DEFAULT |
2783
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
97 #define SDL_MEMORY_POOL_DEFAULT |
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
98 #endif |
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
99 |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
100 static SDL_Renderer *D3D_CreateRenderer(SDL_Window * window, Uint32 flags); |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
101 static int D3D_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture); |
2990 | 102 static int D3D_QueryTexturePixels(SDL_Renderer * renderer, |
103 SDL_Texture * texture, void **pixels, | |
104 int *pitch); | |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
105 static int D3D_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
106 const SDL_Rect * rect, const void *pixels, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
107 int pitch); |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
108 static int D3D_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
109 const SDL_Rect * rect, int markDirty, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
110 void **pixels, int *pitch); |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
111 static void D3D_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture); |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
112 static void D3D_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
113 int numrects, const SDL_Rect * rects); |
3599
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
114 static int D3D_RenderDrawPoints(SDL_Renderer * renderer, |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
115 const SDL_Point * points, int count); |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
116 static int D3D_RenderDrawLines(SDL_Renderer * renderer, |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
117 const SDL_Point * points, int count); |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
118 static int D3D_RenderFillRects(SDL_Renderer * renderer, |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
119 const SDL_Rect ** rects, int count); |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
120 static int D3D_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
121 const SDL_Rect * srcrect, const SDL_Rect * dstrect); |
3427
36cf454ba065
Work in progress on implementation of SDL_RenderReadPixels() and SDL_RenderWritePixels(), code untested.
Sam Lantinga <slouken@libsdl.org>
parents:
3279
diff
changeset
|
122 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
|
123 Uint32 format, void * pixels, int pitch); |
cd763d104465
The Direct3D Read/Write pixels interface is in progress.
Sam Lantinga <slouken@libsdl.org>
parents:
3427
diff
changeset
|
124 static int D3D_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect, |
cd763d104465
The Direct3D Read/Write pixels interface is in progress.
Sam Lantinga <slouken@libsdl.org>
parents:
3427
diff
changeset
|
125 Uint32 format, const void * pixels, int pitch); |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
126 static void D3D_RenderPresent(SDL_Renderer * renderer); |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
127 static void D3D_DestroyTexture(SDL_Renderer * renderer, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
128 SDL_Texture * texture); |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
129 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
|
130 |
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
|
131 |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
132 SDL_RenderDriver D3D_RenderDriver = { |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
133 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
|
134 { |
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
|
135 "d3d", |
5145
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:
5144
diff
changeset
|
136 (SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED), |
2972
0a4b70368372
Query available formats before advertising them.
Sam Lantinga <slouken@libsdl.org>
parents:
2933
diff
changeset
|
137 0, |
0a4b70368372
Query available formats before advertising them.
Sam Lantinga <slouken@libsdl.org>
parents:
2933
diff
changeset
|
138 {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
|
139 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
|
140 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
|
141 }; |
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
|
142 |
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
|
143 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
|
144 { |
5157
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:
5152
diff
changeset
|
145 void* d3dDLL; |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
146 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
|
147 IDirect3DDevice9 *device; |
3527
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
148 UINT adapter; |
1975
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
149 D3DPRESENT_PARAMETERS pparams; |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
150 SDL_bool beginScene; |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
151 } 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
|
152 |
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
|
153 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
|
154 { |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
155 SDL_SW_YUVTexture *yuv; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
156 Uint32 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
|
157 IDirect3DTexture9 *texture; |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
158 } 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
|
159 |
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
|
160 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
|
161 { |
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
|
162 float x, y, z; |
1904
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
163 float rhw; |
1987
36a08379b3f2
Implemented color modulation in the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
164 DWORD color; |
1904
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
165 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
|
166 } 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
|
167 |
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
|
168 static void |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
169 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
|
170 { |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
171 const char *error; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
172 |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
173 switch (result) { |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
174 case D3DERR_WRONGTEXTUREFORMAT: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
175 error = "WRONGTEXTUREFORMAT"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
176 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
177 case D3DERR_UNSUPPORTEDCOLOROPERATION: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
178 error = "UNSUPPORTEDCOLOROPERATION"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
179 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
180 case D3DERR_UNSUPPORTEDCOLORARG: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
181 error = "UNSUPPORTEDCOLORARG"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
182 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
183 case D3DERR_UNSUPPORTEDALPHAOPERATION: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
184 error = "UNSUPPORTEDALPHAOPERATION"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
185 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
186 case D3DERR_UNSUPPORTEDALPHAARG: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
187 error = "UNSUPPORTEDALPHAARG"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
188 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
189 case D3DERR_TOOMANYOPERATIONS: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
190 error = "TOOMANYOPERATIONS"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
191 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
192 case D3DERR_CONFLICTINGTEXTUREFILTER: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
193 error = "CONFLICTINGTEXTUREFILTER"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
194 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
195 case D3DERR_UNSUPPORTEDFACTORVALUE: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
196 error = "UNSUPPORTEDFACTORVALUE"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
197 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
198 case D3DERR_CONFLICTINGRENDERSTATE: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
199 error = "CONFLICTINGRENDERSTATE"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
200 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
201 case D3DERR_UNSUPPORTEDTEXTUREFILTER: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
202 error = "UNSUPPORTEDTEXTUREFILTER"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
203 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
204 case D3DERR_CONFLICTINGTEXTUREPALETTE: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
205 error = "CONFLICTINGTEXTUREPALETTE"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
206 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
207 case D3DERR_DRIVERINTERNALERROR: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
208 error = "DRIVERINTERNALERROR"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
209 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
210 case D3DERR_NOTFOUND: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
211 error = "NOTFOUND"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
212 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
213 case D3DERR_MOREDATA: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
214 error = "MOREDATA"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
215 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
216 case D3DERR_DEVICELOST: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
217 error = "DEVICELOST"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
218 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
219 case D3DERR_DEVICENOTRESET: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
220 error = "DEVICENOTRESET"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
221 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
222 case D3DERR_NOTAVAILABLE: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
223 error = "NOTAVAILABLE"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
224 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
225 case D3DERR_OUTOFVIDEOMEMORY: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
226 error = "OUTOFVIDEOMEMORY"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
227 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
228 case D3DERR_INVALIDDEVICE: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
229 error = "INVALIDDEVICE"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
230 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
231 case D3DERR_INVALIDCALL: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
232 error = "INVALIDCALL"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
233 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
234 case D3DERR_DRIVERINVALIDCALL: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
235 error = "DRIVERINVALIDCALL"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
236 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
237 case D3DERR_WASSTILLDRAWING: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
238 error = "WASSTILLDRAWING"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
239 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
240 default: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
241 error = "UNKNOWN"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
242 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
243 } |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
244 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
|
245 } |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
246 |
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 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
|
248 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
|
249 { |
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
|
250 switch (format) { |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
251 case SDL_PIXELFORMAT_INDEX8: |
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
|
252 return D3DFMT_P8; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
253 case SDL_PIXELFORMAT_RGB332: |
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
|
254 return D3DFMT_R3G3B2; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
255 case SDL_PIXELFORMAT_RGB444: |
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
|
256 return D3DFMT_X4R4G4B4; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
257 case SDL_PIXELFORMAT_RGB555: |
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
|
258 return D3DFMT_X1R5G5B5; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
259 case SDL_PIXELFORMAT_ARGB4444: |
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
|
260 return D3DFMT_A4R4G4B4; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
261 case SDL_PIXELFORMAT_ARGB1555: |
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
|
262 return D3DFMT_A1R5G5B5; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
263 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
|
264 return D3DFMT_R5G6B5; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
265 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
|
266 return D3DFMT_X8R8G8B8; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
267 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
|
268 return D3DFMT_A8R8G8B8; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
269 case SDL_PIXELFORMAT_ARGB2101010: |
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
|
270 return D3DFMT_A2R10G10B10; |
3495 | 271 case SDL_PIXELFORMAT_YV12: |
272 return MAKEFOURCC('Y','V','1','2'); | |
273 case SDL_PIXELFORMAT_IYUV: | |
274 return MAKEFOURCC('I','4','2','0'); | |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
275 case SDL_PIXELFORMAT_UYVY: |
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
|
276 return D3DFMT_UYVY; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
277 case SDL_PIXELFORMAT_YUY2: |
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
|
278 return D3DFMT_YUY2; |
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
|
279 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
|
280 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
|
281 } |
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
|
282 } |
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
|
283 |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
284 static SDL_bool |
3527
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
285 D3D_IsTextureFormatAvailable(IDirect3D9 * d3d, UINT adapter, |
5157
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:
5152
diff
changeset
|
286 D3DFORMAT display_format, |
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:
5152
diff
changeset
|
287 D3DFORMAT texture_format) |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
288 { |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
289 HRESULT result; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
290 |
3527
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
291 result = IDirect3D9_CheckDeviceFormat(d3d, adapter, |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
292 D3DDEVTYPE_HAL, |
5157
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:
5152
diff
changeset
|
293 display_format, |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
294 0, |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
295 D3DRTYPE_TEXTURE, |
5157
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:
5152
diff
changeset
|
296 texture_format); |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
297 return FAILED(result) ? SDL_FALSE : SDL_TRUE; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
298 } |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
299 |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
300 static void |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
301 UpdateYUVTextureData(SDL_Texture * texture) |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
302 { |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
303 D3D_TextureData *data = (D3D_TextureData *) texture->driverdata; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
304 SDL_Rect rect; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
305 RECT d3drect; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
306 D3DLOCKED_RECT locked; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
307 HRESULT result; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
308 |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
309 d3drect.left = 0; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
310 d3drect.right = texture->w; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
311 d3drect.top = 0; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
312 d3drect.bottom = texture->h; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
313 |
2990 | 314 result = |
315 IDirect3DTexture9_LockRect(data->texture, 0, &locked, &d3drect, 0); | |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
316 if (FAILED(result)) { |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
317 return; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
318 } |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
319 |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
320 rect.x = 0; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
321 rect.y = 0; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
322 rect.w = texture->w; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
323 rect.h = texture->h; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
324 SDL_SW_CopyYUVToRGB(data->yuv, &rect, data->format, texture->w, |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
325 texture->h, locked.pBits, locked.Pitch); |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
326 |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
327 IDirect3DTexture9_UnlockRect(data->texture, 0); |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
328 } |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
329 |
5157
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:
5152
diff
changeset
|
330 static void |
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:
5152
diff
changeset
|
331 D3D_AddTextureFormats(D3D_RenderData *data, SDL_RendererInfo *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
|
332 { |
5157
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:
5152
diff
changeset
|
333 int i; |
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:
5152
diff
changeset
|
334 int formats[] = { |
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:
5152
diff
changeset
|
335 SDL_PIXELFORMAT_RGB332, |
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:
5152
diff
changeset
|
336 SDL_PIXELFORMAT_RGB444, |
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:
5152
diff
changeset
|
337 SDL_PIXELFORMAT_RGB555, |
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:
5152
diff
changeset
|
338 SDL_PIXELFORMAT_ARGB4444, |
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:
5152
diff
changeset
|
339 SDL_PIXELFORMAT_ARGB1555, |
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:
5152
diff
changeset
|
340 SDL_PIXELFORMAT_RGB565, |
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:
5152
diff
changeset
|
341 SDL_PIXELFORMAT_RGB888, |
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:
5152
diff
changeset
|
342 SDL_PIXELFORMAT_ARGB8888, |
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:
5152
diff
changeset
|
343 SDL_PIXELFORMAT_ARGB2101010, |
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:
5152
diff
changeset
|
344 }; |
2972
0a4b70368372
Query available formats before advertising them.
Sam Lantinga <slouken@libsdl.org>
parents:
2933
diff
changeset
|
345 |
5157
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:
5152
diff
changeset
|
346 info->num_texture_formats = 0; |
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:
5152
diff
changeset
|
347 for (i = 0; i < SDL_arraysize(formats); ++i) { |
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:
5152
diff
changeset
|
348 if (D3D_IsTextureFormatAvailable |
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:
5152
diff
changeset
|
349 (data->d3d, data->adapter, data->pparams.BackBufferFormat, PixelFormatToD3DFMT(formats[i]))) { |
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:
5152
diff
changeset
|
350 info->texture_formats[info->num_texture_formats++] = formats[i]; |
3520
83518f8fcd61
Fixed calls to SDL_AddRenderDriver()
Sam Lantinga <slouken@libsdl.org>
parents:
3519
diff
changeset
|
351 } |
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
|
352 } |
5157
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:
5152
diff
changeset
|
353 info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_YV12; |
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:
5152
diff
changeset
|
354 info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_IYUV; |
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:
5152
diff
changeset
|
355 info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_YUY2; |
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:
5152
diff
changeset
|
356 info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_UYVY; |
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:
5152
diff
changeset
|
357 info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_YVYU; |
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
|
358 } |
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
|
359 |
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
|
360 SDL_Renderer * |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
361 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
|
362 { |
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
|
363 SDL_Renderer *renderer; |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
364 D3D_RenderData *data; |
5157
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:
5152
diff
changeset
|
365 SDL_SysWMinfo windowinfo; |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
366 HRESULT result; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
367 D3DPRESENT_PARAMETERS pparams; |
1907
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
368 IDirect3DSwapChain9 *chain; |
1925
411bfb37082b
Query the maximum texture size for the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
369 D3DCAPS9 caps; |
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
|
370 |
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
|
371 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
|
372 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
|
373 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
|
374 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
|
375 } |
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
|
376 |
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
|
377 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
|
378 if (!data) { |
5157
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:
5152
diff
changeset
|
379 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
|
380 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
|
381 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
|
382 } |
5157
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:
5152
diff
changeset
|
383 |
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:
5152
diff
changeset
|
384 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:
5152
diff
changeset
|
385 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:
5152
diff
changeset
|
386 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
|
387 |
5157
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:
5152
diff
changeset
|
388 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:
5152
diff
changeset
|
389 (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:
5152
diff
changeset
|
390 "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:
5152
diff
changeset
|
391 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:
5152
diff
changeset
|
392 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:
5152
diff
changeset
|
393 } |
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:
5152
diff
changeset
|
394 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:
5152
diff
changeset
|
395 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:
5152
diff
changeset
|
396 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:
5152
diff
changeset
|
397 } |
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:
5152
diff
changeset
|
398 } |
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:
5152
diff
changeset
|
399 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:
5152
diff
changeset
|
400 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:
5152
diff
changeset
|
401 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:
5152
diff
changeset
|
402 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:
5152
diff
changeset
|
403 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:
5152
diff
changeset
|
404 } |
4569 | 405 |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
406 renderer->CreateTexture = D3D_CreateTexture; |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
407 renderer->QueryTexturePixels = D3D_QueryTexturePixels; |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
408 renderer->UpdateTexture = D3D_UpdateTexture; |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
409 renderer->LockTexture = D3D_LockTexture; |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
410 renderer->UnlockTexture = D3D_UnlockTexture; |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
411 renderer->DirtyTexture = D3D_DirtyTexture; |
3599
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
412 renderer->RenderDrawPoints = D3D_RenderDrawPoints; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
413 renderer->RenderDrawLines = D3D_RenderDrawLines; |
3675 | 414 renderer->RenderFillRects = D3D_RenderFillRects; |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
415 renderer->RenderCopy = D3D_RenderCopy; |
3427
36cf454ba065
Work in progress on implementation of SDL_RenderReadPixels() and SDL_RenderWritePixels(), code untested.
Sam Lantinga <slouken@libsdl.org>
parents:
3279
diff
changeset
|
416 renderer->RenderReadPixels = D3D_RenderReadPixels; |
3480
cd763d104465
The Direct3D Read/Write pixels interface is in progress.
Sam Lantinga <slouken@libsdl.org>
parents:
3427
diff
changeset
|
417 renderer->RenderWritePixels = D3D_RenderWritePixels; |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
418 renderer->RenderPresent = D3D_RenderPresent; |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
419 renderer->DestroyTexture = D3D_DestroyTexture; |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
420 renderer->DestroyRenderer = D3D_DestroyRenderer; |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
421 renderer->info = D3D_RenderDriver.info; |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3675
diff
changeset
|
422 renderer->window = window; |
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
|
423 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
|
424 |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
425 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
|
426 |
5157
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:
5152
diff
changeset
|
427 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:
5152
diff
changeset
|
428 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:
5152
diff
changeset
|
429 |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
430 SDL_zero(pparams); |
5157
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:
5152
diff
changeset
|
431 pparams.hDeviceWindow = windowinfo.info.win.window; |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
432 pparams.BackBufferWidth = window->w; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
433 pparams.BackBufferHeight = window->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
|
434 if (window->flags & SDL_WINDOW_FULLSCREEN) { |
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
|
435 pparams.BackBufferFormat = |
3519
1374f9275de9
Fixed compiling the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3495
diff
changeset
|
436 PixelFormatToD3DFMT(window->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
|
437 } 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
|
438 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
|
439 } |
5145
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:
5144
diff
changeset
|
440 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:
5144
diff
changeset
|
441 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:
5144
diff
changeset
|
442 |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
443 if (window->flags & SDL_WINDOW_FULLSCREEN) { |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
444 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
|
445 pparams.FullScreen_RefreshRateInHz = |
3519
1374f9275de9
Fixed compiling the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3495
diff
changeset
|
446 window->fullscreen_mode.refresh_rate; |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
447 } else { |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
448 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
|
449 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
|
450 } |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
451 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
|
452 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
|
453 } else { |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
454 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
|
455 } |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
456 |
5157
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:
5152
diff
changeset
|
457 /* 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:
5152
diff
changeset
|
458 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:
5152
diff
changeset
|
459 IDirect3D9_GetDeviceCaps(data->d3d, data->adapter, D3DDEVTYPE_HAL, &caps); |
3197 | 460 |
5157
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:
5152
diff
changeset
|
461 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
|
462 D3DDEVTYPE_HAL, |
5157
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:
5152
diff
changeset
|
463 pparams.hDeviceWindow, |
3197 | 464 (caps. |
465 DevCaps & | |
466 D3DDEVCAPS_HWTRANSFORMANDLIGHT) ? | |
467 D3DCREATE_HARDWARE_VERTEXPROCESSING : | |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
468 D3DCREATE_SOFTWARE_VERTEXPROCESSING, |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
469 &pparams, &data->device); |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
470 if (FAILED(result)) { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
471 D3D_DestroyRenderer(renderer); |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
472 D3D_SetError("CreateDevice()", result); |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
473 return NULL; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
474 } |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
475 data->beginScene = SDL_TRUE; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
476 |
1907
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
477 /* 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
|
478 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
|
479 if (FAILED(result)) { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
480 D3D_DestroyRenderer(renderer); |
1907
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
481 D3D_SetError("GetSwapChain()", result); |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
482 return NULL; |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
483 } |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
484 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
|
485 if (FAILED(result)) { |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
486 IDirect3DSwapChain9_Release(chain); |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
487 D3D_DestroyRenderer(renderer); |
1907
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
488 D3D_SetError("GetPresentParameters()", result); |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
489 return NULL; |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
490 } |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
491 IDirect3DSwapChain9_Release(chain); |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
492 if (pparams.PresentationInterval == D3DPRESENT_INTERVAL_ONE) { |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
493 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
|
494 } |
1975
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
495 data->pparams = pparams; |
1907
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
496 |
5157
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:
5152
diff
changeset
|
497 D3D_AddTextureFormats(data, &renderer->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:
5152
diff
changeset
|
498 |
1925
411bfb37082b
Query the maximum texture size for the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
499 IDirect3DDevice9_GetDeviceCaps(data->device, &caps); |
411bfb37082b
Query the maximum texture size for the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
500 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
|
501 renderer->info.max_texture_height = caps.MaxTextureHeight; |
1918
092bd3a019c5
Starting on the OpenGL renderer...
Sam Lantinga <slouken@libsdl.org>
parents:
1917
diff
changeset
|
502 |
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
|
503 /* Set up parameters for rendering */ |
1904
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
504 IDirect3DDevice9_SetVertexShader(data->device, NULL); |
1987
36a08379b3f2
Implemented color modulation in the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
505 IDirect3DDevice9_SetFVF(data->device, |
36a08379b3f2
Implemented color modulation in the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
506 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1); |
1988
1ee02169bbb0
Figured out how texture stages work, thanks to this:
Sam Lantinga <slouken@libsdl.org>
parents:
1987
diff
changeset
|
507 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
|
508 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
|
509 D3DCULL_NONE); |
1904
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
510 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
|
511 /* 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
|
512 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
|
513 D3DTOP_MODULATE); |
1ee02169bbb0
Figured out how texture stages work, thanks to this:
Sam Lantinga <slouken@libsdl.org>
parents:
1987
diff
changeset
|
514 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
|
515 D3DTA_TEXTURE); |
1ee02169bbb0
Figured out how texture stages work, thanks to this:
Sam Lantinga <slouken@libsdl.org>
parents:
1987
diff
changeset
|
516 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
|
517 D3DTA_DIFFUSE); |
1ee02169bbb0
Figured out how texture stages work, thanks to this:
Sam Lantinga <slouken@libsdl.org>
parents:
1987
diff
changeset
|
518 /* 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
|
519 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
|
520 D3DTOP_MODULATE); |
1ee02169bbb0
Figured out how texture stages work, thanks to this:
Sam Lantinga <slouken@libsdl.org>
parents:
1987
diff
changeset
|
521 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
|
522 D3DTA_TEXTURE); |
1ee02169bbb0
Figured out how texture stages work, thanks to this:
Sam Lantinga <slouken@libsdl.org>
parents:
1987
diff
changeset
|
523 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
|
524 D3DTA_DIFFUSE); |
1991
3863ba81c1d6
Clear the second texture stage explicitly
Sam Lantinga <slouken@libsdl.org>
parents:
1988
diff
changeset
|
525 /* Disable second texture stage, since we're done */ |
3863ba81c1d6
Clear the second texture stage explicitly
Sam Lantinga <slouken@libsdl.org>
parents:
1988
diff
changeset
|
526 IDirect3DDevice9_SetTextureStageState(data->device, 1, D3DTSS_COLOROP, |
3863ba81c1d6
Clear the second texture stage explicitly
Sam Lantinga <slouken@libsdl.org>
parents:
1988
diff
changeset
|
527 D3DTOP_DISABLE); |
3863ba81c1d6
Clear the second texture stage explicitly
Sam Lantinga <slouken@libsdl.org>
parents:
1988
diff
changeset
|
528 IDirect3DDevice9_SetTextureStageState(data->device, 1, D3DTSS_ALPHAOP, |
3863ba81c1d6
Clear the second texture stage explicitly
Sam Lantinga <slouken@libsdl.org>
parents:
1988
diff
changeset
|
529 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
|
530 |
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
|
531 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
|
532 } |
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
|
533 |
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
|
534 static int |
1975
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
535 D3D_Reset(SDL_Renderer * renderer) |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
536 { |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
537 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
|
538 HRESULT result; |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
539 |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
540 result = IDirect3DDevice9_Reset(data->device, &data->pparams); |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
541 if (FAILED(result)) { |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
542 if (result == D3DERR_DEVICELOST) { |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
543 /* Don't worry about it, we'll reset later... */ |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
544 return 0; |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
545 } else { |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
546 D3D_SetError("Reset()", result); |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
547 return -1; |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
548 } |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
549 } |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
550 IDirect3DDevice9_SetVertexShader(data->device, NULL); |
1987
36a08379b3f2
Implemented color modulation in the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
551 IDirect3DDevice9_SetFVF(data->device, |
36a08379b3f2
Implemented color modulation in the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
552 D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1); |
1975
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
553 IDirect3DDevice9_SetRenderState(data->device, D3DRS_CULLMODE, |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
554 D3DCULL_NONE); |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
555 IDirect3DDevice9_SetRenderState(data->device, D3DRS_LIGHTING, FALSE); |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
556 return 0; |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
557 } |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
558 |
5157
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:
5152
diff
changeset
|
559 /* FIXME: This needs to be called... when? */ |
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:
5152
diff
changeset
|
560 #if 0 |
1975
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
561 static int |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
562 D3D_DisplayModeChanged(SDL_Renderer * renderer) |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
563 { |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
564 D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3675
diff
changeset
|
565 SDL_Window *window = renderer->window; |
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3675
diff
changeset
|
566 SDL_VideoDisplay *display = window->display; |
1975
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
567 |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
568 data->pparams.BackBufferWidth = window->w; |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
569 data->pparams.BackBufferHeight = window->h; |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
570 if (window->flags & SDL_WINDOW_FULLSCREEN) { |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
571 data->pparams.BackBufferFormat = |
3519
1374f9275de9
Fixed compiling the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3495
diff
changeset
|
572 PixelFormatToD3DFMT(window->fullscreen_mode.format); |
1975
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
573 } else { |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
574 data->pparams.BackBufferFormat = D3DFMT_UNKNOWN; |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
575 } |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
576 return D3D_Reset(renderer); |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
577 } |
5157
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:
5152
diff
changeset
|
578 #endif |
1975
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
579 |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
580 static int |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
581 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
|
582 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
583 D3D_RenderData *renderdata = (D3D_RenderData *) renderer->driverdata; |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3675
diff
changeset
|
584 SDL_Window *window = renderer->window; |
5157
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:
5152
diff
changeset
|
585 D3DFORMAT display_format = renderdata->pparams.BackBufferFormat; |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
586 D3D_TextureData *data; |
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
|
587 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
|
588 |
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
|
589 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
|
590 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
|
591 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
|
592 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
|
593 } |
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
|
594 |
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
|
595 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
|
596 |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
597 if (SDL_ISPIXELFORMAT_FOURCC(texture->format) && |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
598 (texture->format != SDL_PIXELFORMAT_YUY2 || |
3527
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
599 !D3D_IsTextureFormatAvailable(renderdata->d3d, renderdata->adapter, |
5157
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:
5152
diff
changeset
|
600 display_format, PixelFormatToD3DFMT(texture->format))) |
2990 | 601 && (texture->format != SDL_PIXELFORMAT_YVYU |
3527
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
602 || !D3D_IsTextureFormatAvailable(renderdata->d3d, renderdata->adapter, |
5157
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:
5152
diff
changeset
|
603 display_format, PixelFormatToD3DFMT(texture->format)))) { |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
604 data->yuv = |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
605 SDL_SW_CreateYUVTexture(texture->format, texture->w, texture->h); |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
606 if (!data->yuv) { |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
607 return -1; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
608 } |
5157
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:
5152
diff
changeset
|
609 data->format = SDL_GetWindowPixelFormat(window); |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
610 } else { |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
611 data->format = texture->format; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
612 } |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
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 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
|
615 IDirect3DDevice9_CreateTexture(renderdata->device, texture->w, |
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
|
616 texture->h, 1, 0, |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
617 PixelFormatToD3DFMT(data->format), |
2783
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
618 D3DPOOL_SDL, &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
|
619 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
|
620 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
|
621 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
|
622 } |
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
|
623 |
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
|
624 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
|
625 } |
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
|
626 |
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
|
627 static int |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
628 D3D_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture, |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
629 void **pixels, int *pitch) |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
630 { |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
631 D3D_TextureData *data = (D3D_TextureData *) texture->driverdata; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
632 |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
633 if (data->yuv) { |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
634 return SDL_SW_QueryYUVTexturePixels(data->yuv, pixels, pitch); |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
635 } else { |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
636 /* D3D textures don't have their pixels hanging out */ |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
637 return -1; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
638 } |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
639 } |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
640 |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
641 static int |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
642 D3D_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
643 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
|
644 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
645 D3D_TextureData *data = (D3D_TextureData *) texture->driverdata; |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
646 D3D_RenderData *renderdata = (D3D_RenderData *) renderer->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
|
647 |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
648 if (data->yuv) { |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
649 if (SDL_SW_UpdateYUVTexture(data->yuv, rect, pixels, pitch) < 0) { |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
650 return -1; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
651 } |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
652 UpdateYUVTextureData(texture); |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
653 return 0; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
654 } else { |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
655 #ifdef SDL_MEMORY_POOL_DEFAULT |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
656 IDirect3DTexture9 *temp; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
657 RECT d3drect; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
658 D3DLOCKED_RECT locked; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
659 const Uint8 *src; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
660 Uint8 *dst; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
661 int row, length; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
662 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
|
663 |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
664 result = |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
665 IDirect3DDevice9_CreateTexture(renderdata->device, texture->w, |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
666 texture->h, 1, 0, |
3013
8cc00819c8d6
Reverted Bob's indent checkin
Sam Lantinga <slouken@libsdl.org>
parents:
3011
diff
changeset
|
667 PixelFormatToD3DFMT(texture-> |
8cc00819c8d6
Reverted Bob's indent checkin
Sam Lantinga <slouken@libsdl.org>
parents:
3011
diff
changeset
|
668 format), |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
669 D3DPOOL_SYSTEMMEM, &temp, NULL); |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
670 if (FAILED(result)) { |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
671 D3D_SetError("CreateTexture()", result); |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
672 return -1; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
673 } |
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
|
674 |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
675 d3drect.left = rect->x; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
676 d3drect.right = rect->x + rect->w; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
677 d3drect.top = rect->y; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
678 d3drect.bottom = rect->y + rect->h; |
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
|
679 |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
680 result = IDirect3DTexture9_LockRect(temp, 0, &locked, &d3drect, 0); |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
681 if (FAILED(result)) { |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
682 IDirect3DTexture9_Release(temp); |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
683 D3D_SetError("LockRect()", result); |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
684 return -1; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
685 } |
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
|
686 |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
687 src = pixels; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
688 dst = locked.pBits; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
689 length = rect->w * SDL_BYTESPERPIXEL(texture->format); |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
690 for (row = 0; row < rect->h; ++row) { |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
691 SDL_memcpy(dst, src, length); |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
692 src += pitch; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
693 dst += locked.Pitch; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
694 } |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
695 IDirect3DTexture9_UnlockRect(temp, 0); |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
696 |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
697 result = |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
698 IDirect3DDevice9_UpdateTexture(renderdata->device, |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
699 (IDirect3DBaseTexture9 *) temp, |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
700 (IDirect3DBaseTexture9 *) |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
701 data->texture); |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
702 IDirect3DTexture9_Release(temp); |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
703 if (FAILED(result)) { |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
704 D3D_SetError("UpdateTexture()", result); |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
705 return -1; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
706 } |
2783
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
707 #else |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
708 RECT d3drect; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
709 D3DLOCKED_RECT locked; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
710 const Uint8 *src; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
711 Uint8 *dst; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
712 int row, length; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
713 HRESULT result; |
2783
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
714 |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
715 d3drect.left = rect->x; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
716 d3drect.right = rect->x + rect->w; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
717 d3drect.top = rect->y; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
718 d3drect.bottom = rect->y + rect->h; |
2783
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
719 |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
720 result = |
2990 | 721 IDirect3DTexture9_LockRect(data->texture, 0, &locked, &d3drect, |
722 0); | |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
723 if (FAILED(result)) { |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
724 D3D_SetError("LockRect()", result); |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
725 return -1; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
726 } |
2783
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
727 |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
728 src = pixels; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
729 dst = locked.pBits; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
730 length = rect->w * SDL_BYTESPERPIXEL(texture->format); |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
731 for (row = 0; row < rect->h; ++row) { |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
732 SDL_memcpy(dst, src, length); |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
733 src += pitch; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
734 dst += locked.Pitch; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
735 } |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
736 IDirect3DTexture9_UnlockRect(data->texture, 0); |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
737 #endif // SDL_MEMORY_POOL_DEFAULT |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
738 |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
739 return 0; |
2783
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
740 } |
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
741 } |
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 |
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
|
743 static int |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
744 D3D_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
745 const SDL_Rect * rect, int markDirty, void **pixels, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
746 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
|
747 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
748 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
|
749 |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
750 if (data->yuv) { |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
751 return SDL_SW_LockYUVTexture(data->yuv, rect, markDirty, pixels, |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
752 pitch); |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
753 } else { |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
754 RECT d3drect; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
755 D3DLOCKED_RECT locked; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
756 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
|
757 |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
758 d3drect.left = rect->x; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
759 d3drect.right = rect->x + rect->w; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
760 d3drect.top = rect->y; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
761 d3drect.bottom = rect->y + rect->h; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
762 |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
763 result = |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
764 IDirect3DTexture9_LockRect(data->texture, 0, &locked, &d3drect, |
2990 | 765 markDirty ? 0 : |
766 D3DLOCK_NO_DIRTY_UPDATE); | |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
767 if (FAILED(result)) { |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
768 D3D_SetError("LockRect()", result); |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
769 return -1; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
770 } |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
771 *pixels = locked.pBits; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
772 *pitch = locked.Pitch; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
773 return 0; |
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
|
774 } |
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
|
775 } |
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
|
776 |
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
|
777 static void |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
778 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
|
779 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
780 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
|
781 |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
782 if (data->yuv) { |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
783 SDL_SW_UnlockYUVTexture(data->yuv); |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
784 UpdateYUVTextureData(texture); |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
785 } else { |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
786 IDirect3DTexture9_UnlockRect(data->texture, 0); |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
787 } |
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
|
788 } |
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
|
789 |
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
|
790 static void |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
791 D3D_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture, int numrects, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
792 const SDL_Rect * rects) |
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
|
793 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
794 D3D_TextureData *data = (D3D_TextureData *) texture->driverdata; |
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
|
795 RECT d3drect; |
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
|
796 int i; |
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
|
797 |
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
|
798 for (i = 0; i < numrects; ++i) { |
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
|
799 const SDL_Rect *rect = &rects[i]; |
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
|
800 |
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 d3drect.left = rect->x; |
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
|
802 d3drect.right = rect->x + rect->w; |
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
|
803 d3drect.top = rect->y; |
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
|
804 d3drect.bottom = rect->y + rect->h; |
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
|
805 |
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 IDirect3DTexture9_AddDirtyRect(data->texture, &d3drect); |
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
|
807 } |
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
|
808 } |
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
|
809 |
2932
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
810 static void |
2933 | 811 D3D_SetBlendMode(D3D_RenderData * data, int blendMode) |
2932
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
812 { |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
813 switch (blendMode) { |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
814 case SDL_BLENDMODE_NONE: |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
815 IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE, |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
816 FALSE); |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
817 break; |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
818 case SDL_BLENDMODE_BLEND: |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
819 IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE, |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
820 TRUE); |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
821 IDirect3DDevice9_SetRenderState(data->device, D3DRS_SRCBLEND, |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
822 D3DBLEND_SRCALPHA); |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
823 IDirect3DDevice9_SetRenderState(data->device, D3DRS_DESTBLEND, |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
824 D3DBLEND_INVSRCALPHA); |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
825 break; |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
826 case SDL_BLENDMODE_ADD: |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
827 IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE, |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
828 TRUE); |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
829 IDirect3DDevice9_SetRenderState(data->device, D3DRS_SRCBLEND, |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
830 D3DBLEND_SRCALPHA); |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
831 IDirect3DDevice9_SetRenderState(data->device, D3DRS_DESTBLEND, |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
832 D3DBLEND_ONE); |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
833 break; |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
834 } |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
835 } |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
836 |
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
|
837 static int |
3599
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
838 D3D_RenderDrawPoints(SDL_Renderer * renderer, const SDL_Point * points, |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
839 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
|
840 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
841 D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; |
2932
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
842 DWORD color; |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
843 Vertex *vertices; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
844 int i; |
2932
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
845 HRESULT result; |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
846 |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
847 if (data->beginScene) { |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
848 IDirect3DDevice9_BeginScene(data->device); |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
849 data->beginScene = SDL_FALSE; |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
850 } |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
851 |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
852 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
|
853 |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
854 result = |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
855 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
|
856 (IDirect3DBaseTexture9 *) 0); |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
857 if (FAILED(result)) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
858 D3D_SetError("SetTexture()", result); |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
859 return -1; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
860 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
861 |
2932
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
862 color = D3DCOLOR_ARGB(renderer->a, renderer->r, renderer->g, renderer->b); |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
863 |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
864 vertices = SDL_stack_alloc(Vertex, count); |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
865 for (i = 0; i < count; ++i) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
866 vertices[i].x = (float) points[i].x; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
867 vertices[i].y = (float) points[i].y; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
868 vertices[i].z = 0.0f; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
869 vertices[i].rhw = 1.0f; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
870 vertices[i].color = color; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
871 vertices[i].u = 0.0f; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
872 vertices[i].v = 0.0f; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
873 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
874 result = |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
875 IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_POINTLIST, count, |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
876 vertices, sizeof(*vertices)); |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
877 SDL_stack_free(vertices); |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
878 if (FAILED(result)) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
879 D3D_SetError("DrawPrimitiveUP()", result); |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
880 return -1; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
881 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
882 return 0; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
883 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
884 |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
885 static int |
3599
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
886 D3D_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points, |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
887 int count) |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
888 { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
889 D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
890 DWORD color; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
891 Vertex *vertices; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
892 int i; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
893 HRESULT result; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
894 |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
895 if (data->beginScene) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
896 IDirect3DDevice9_BeginScene(data->device); |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
897 data->beginScene = SDL_FALSE; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
898 } |
2932
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
899 |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
900 D3D_SetBlendMode(data, renderer->blendMode); |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
901 |
2933 | 902 result = |
903 IDirect3DDevice9_SetTexture(data->device, 0, | |
904 (IDirect3DBaseTexture9 *) 0); | |
2932
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
905 if (FAILED(result)) { |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
906 D3D_SetError("SetTexture()", result); |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
907 return -1; |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
908 } |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
909 |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
910 color = D3DCOLOR_ARGB(renderer->a, renderer->r, renderer->g, renderer->b); |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
911 |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
912 vertices = SDL_stack_alloc(Vertex, count); |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
913 for (i = 0; i < count; ++i) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
914 vertices[i].x = (float) points[i].x; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
915 vertices[i].y = (float) points[i].y; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
916 vertices[i].z = 0.0f; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
917 vertices[i].rhw = 1.0f; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
918 vertices[i].color = color; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
919 vertices[i].u = 0.0f; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
920 vertices[i].v = 0.0f; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
921 } |
2932
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
922 result = |
3551
4a39f28cd935
Fixed line drawing for D3D
Sam Lantinga <slouken@libsdl.org>
parents:
3549
diff
changeset
|
923 IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_LINESTRIP, count-1, |
2932
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
924 vertices, sizeof(*vertices)); |
3551
4a39f28cd935
Fixed line drawing for D3D
Sam Lantinga <slouken@libsdl.org>
parents:
3549
diff
changeset
|
925 |
4a39f28cd935
Fixed line drawing for D3D
Sam Lantinga <slouken@libsdl.org>
parents:
3549
diff
changeset
|
926 /* DirectX 9 has the same line rasterization semantics as GDI, |
4a39f28cd935
Fixed line drawing for D3D
Sam Lantinga <slouken@libsdl.org>
parents:
3549
diff
changeset
|
927 so we need to close the endpoint of the line */ |
4a39f28cd935
Fixed line drawing for D3D
Sam Lantinga <slouken@libsdl.org>
parents:
3549
diff
changeset
|
928 if (points[0].x != points[count-1].x || points[0].y != points[count-1].y) { |
4a39f28cd935
Fixed line drawing for D3D
Sam Lantinga <slouken@libsdl.org>
parents:
3549
diff
changeset
|
929 vertices[0].x = (float) points[count-1].x; |
4a39f28cd935
Fixed line drawing for D3D
Sam Lantinga <slouken@libsdl.org>
parents:
3549
diff
changeset
|
930 vertices[0].y = (float) points[count-1].y; |
4a39f28cd935
Fixed line drawing for D3D
Sam Lantinga <slouken@libsdl.org>
parents:
3549
diff
changeset
|
931 result = IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_POINTLIST, 1, vertices, sizeof(*vertices)); |
4a39f28cd935
Fixed line drawing for D3D
Sam Lantinga <slouken@libsdl.org>
parents:
3549
diff
changeset
|
932 } |
4a39f28cd935
Fixed line drawing for D3D
Sam Lantinga <slouken@libsdl.org>
parents:
3549
diff
changeset
|
933 |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
934 SDL_stack_free(vertices); |
2932
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
935 if (FAILED(result)) { |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
936 D3D_SetError("DrawPrimitiveUP()", result); |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
937 return -1; |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
938 } |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
939 return 0; |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
940 } |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
941 |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
942 static int |
3599
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
943 D3D_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects, |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
944 int count) |
2932
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
945 { |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
946 D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
947 DWORD color; |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
948 int i; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
949 float minx, miny, maxx, maxy; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
950 Vertex vertices[4]; |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
951 HRESULT result; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
952 |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
953 if (data->beginScene) { |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
954 IDirect3DDevice9_BeginScene(data->device); |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
955 data->beginScene = SDL_FALSE; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
956 } |
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
|
957 |
2932
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
958 D3D_SetBlendMode(data, renderer->blendMode); |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
959 |
2933 | 960 result = |
961 IDirect3DDevice9_SetTexture(data->device, 0, | |
962 (IDirect3DBaseTexture9 *) 0); | |
2932
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
963 if (FAILED(result)) { |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
964 D3D_SetError("SetTexture()", result); |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
965 return -1; |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
966 } |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
967 |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
968 color = D3DCOLOR_ARGB(renderer->a, renderer->r, renderer->g, renderer->b); |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
969 |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
970 for (i = 0; i < count; ++i) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
971 const SDL_Rect *rect = rects[i]; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
972 |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
973 minx = (float) rect->x; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
974 miny = (float) rect->y; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
975 maxx = (float) rect->x + rect->w; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
976 maxy = (float) rect->y + rect->h; |
2932
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
977 |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
978 vertices[0].x = minx; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
979 vertices[0].y = miny; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
980 vertices[0].z = 0.0f; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
981 vertices[0].rhw = 1.0f; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
982 vertices[0].color = color; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
983 vertices[0].u = 0.0f; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
984 vertices[0].v = 0.0f; |
2932
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
985 |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
986 vertices[1].x = maxx; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
987 vertices[1].y = miny; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
988 vertices[1].z = 0.0f; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
989 vertices[1].rhw = 1.0f; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
990 vertices[1].color = color; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
991 vertices[1].u = 0.0f; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
992 vertices[1].v = 0.0f; |
2932
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
993 |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
994 vertices[2].x = maxx; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
995 vertices[2].y = maxy; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
996 vertices[2].z = 0.0f; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
997 vertices[2].rhw = 1.0f; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
998 vertices[2].color = color; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
999 vertices[2].u = 0.0f; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1000 vertices[2].v = 0.0f; |
2932
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
1001 |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1002 vertices[3].x = minx; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1003 vertices[3].y = maxy; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1004 vertices[3].z = 0.0f; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1005 vertices[3].rhw = 1.0f; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1006 vertices[3].color = color; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1007 vertices[3].u = 0.0f; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1008 vertices[3].v = 0.0f; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1009 |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1010 result = |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1011 IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_TRIANGLEFAN, |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1012 2, vertices, sizeof(*vertices)); |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1013 if (FAILED(result)) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1014 D3D_SetError("DrawPrimitiveUP()", result); |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1015 return -1; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1016 } |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
1017 } |
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
|
1018 return 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
|
1019 } |
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
|
1020 |
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
|
1021 static int |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
1022 D3D_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
1023 const SDL_Rect * srcrect, const SDL_Rect * dstrect) |
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
|
1024 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
1025 D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
1026 D3D_TextureData *texturedata = (D3D_TextureData *) texture->driverdata; |
3556
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
1027 LPDIRECT3DPIXELSHADER9 shader = 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
|
1028 float minx, miny, maxx, maxy; |
1904
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
1029 float minu, maxu, minv, maxv; |
1987
36a08379b3f2
Implemented color modulation in the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1030 DWORD color; |
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
|
1031 Vertex vertices[4]; |
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
|
1032 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
|
1033 |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
1034 if (data->beginScene) { |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
1035 IDirect3DDevice9_BeginScene(data->device); |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
1036 data->beginScene = SDL_FALSE; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
1037 } |
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
|
1038 |
3279
fd207dce9f94
I think this fixes the texture pixel alignment
Sam Lantinga <slouken@libsdl.org>
parents:
3267
diff
changeset
|
1039 minx = (float) dstrect->x - 0.5f; |
fd207dce9f94
I think this fixes the texture pixel alignment
Sam Lantinga <slouken@libsdl.org>
parents:
3267
diff
changeset
|
1040 miny = (float) dstrect->y - 0.5f; |
fd207dce9f94
I think this fixes the texture pixel alignment
Sam Lantinga <slouken@libsdl.org>
parents:
3267
diff
changeset
|
1041 maxx = (float) dstrect->x + dstrect->w - 0.5f; |
fd207dce9f94
I think this fixes the texture pixel alignment
Sam Lantinga <slouken@libsdl.org>
parents:
3267
diff
changeset
|
1042 maxy = (float) dstrect->y + dstrect->h - 0.5f; |
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
|
1043 |
1904
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
1044 minu = (float) srcrect->x / texture->w; |
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
1045 maxu = (float) (srcrect->x + srcrect->w) / texture->w; |
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
1046 minv = (float) srcrect->y / texture->h; |
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
1047 maxv = (float) (srcrect->y + srcrect->h) / texture->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
|
1048 |
1987
36a08379b3f2
Implemented color modulation in the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1049 color = D3DCOLOR_ARGB(texture->a, texture->r, texture->g, texture->b); |
36a08379b3f2
Implemented color modulation in the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1050 |
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
|
1051 vertices[0].x = minx; |
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
|
1052 vertices[0].y = miny; |
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
|
1053 vertices[0].z = 0.0f; |
1904
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
1054 vertices[0].rhw = 1.0f; |
1987
36a08379b3f2
Implemented color modulation in the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1055 vertices[0].color = color; |
1904
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
1056 vertices[0].u = minu; |
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
1057 vertices[0].v = minv; |
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
1058 |
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
|
1059 vertices[1].x = maxx; |
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
|
1060 vertices[1].y = miny; |
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
|
1061 vertices[1].z = 0.0f; |
1904
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
1062 vertices[1].rhw = 1.0f; |
1987
36a08379b3f2
Implemented color modulation in the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1063 vertices[1].color = color; |
1904
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
1064 vertices[1].u = maxu; |
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
1065 vertices[1].v = minv; |
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
1066 |
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
|
1067 vertices[2].x = maxx; |
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
|
1068 vertices[2].y = maxy; |
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
|
1069 vertices[2].z = 0.0f; |
1904
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
1070 vertices[2].rhw = 1.0f; |
1987
36a08379b3f2
Implemented color modulation in the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1071 vertices[2].color = color; |
1904
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
1072 vertices[2].u = maxu; |
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
1073 vertices[2].v = maxv; |
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
1074 |
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
|
1075 vertices[3].x = minx; |
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
|
1076 vertices[3].y = maxy; |
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
|
1077 vertices[3].z = 0.0f; |
1904
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
1078 vertices[3].rhw = 1.0f; |
1987
36a08379b3f2
Implemented color modulation in the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1079 vertices[3].color = color; |
1904
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
1080 vertices[3].u = minu; |
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
1081 vertices[3].v = maxv; |
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
|
1082 |
2932
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
1083 D3D_SetBlendMode(data, texture->blendMode); |
1916
c773b0c0ac89
Implemented blend modes in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1913
diff
changeset
|
1084 |
5141
da10636e5eca
Making the API simpler, scaling is always defined as linear interpolation and should be supported as much as possible on all renderers.
Sam Lantinga <slouken@libsdl.org>
parents:
5062
diff
changeset
|
1085 IDirect3DDevice9_SetSamplerState(data->device, 0, D3DSAMP_MINFILTER, |
da10636e5eca
Making the API simpler, scaling is always defined as linear interpolation and should be supported as much as possible on all renderers.
Sam Lantinga <slouken@libsdl.org>
parents:
5062
diff
changeset
|
1086 D3DTEXF_LINEAR); |
da10636e5eca
Making the API simpler, scaling is always defined as linear interpolation and should be supported as much as possible on all renderers.
Sam Lantinga <slouken@libsdl.org>
parents:
5062
diff
changeset
|
1087 IDirect3DDevice9_SetSamplerState(data->device, 0, D3DSAMP_MAGFILTER, |
da10636e5eca
Making the API simpler, scaling is always defined as linear interpolation and should be supported as much as possible on all renderers.
Sam Lantinga <slouken@libsdl.org>
parents:
5062
diff
changeset
|
1088 D3DTEXF_LINEAR); |
1917
3f54b3ec5a07
Implemented scaling in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1916
diff
changeset
|
1089 |
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
|
1090 result = |
2735
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2222
diff
changeset
|
1091 IDirect3DDevice9_SetTexture(data->device, 0, (IDirect3DBaseTexture9 *) |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2222
diff
changeset
|
1092 texturedata->texture); |
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
|
1093 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
|
1094 D3D_SetError("SetTexture()", 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
|
1095 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
|
1096 } |
3556
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
1097 if (shader) { |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
1098 result = IDirect3DDevice9_SetPixelShader(data->device, shader); |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
1099 if (FAILED(result)) { |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
1100 D3D_SetError("SetShader()", result); |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
1101 return -1; |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
1102 } |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
1103 } |
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
|
1104 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
|
1105 IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_TRIANGLEFAN, 2, |
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
|
1106 vertices, sizeof(*vertices)); |
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
|
1107 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
|
1108 D3D_SetError("DrawPrimitiveUP()", 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
|
1109 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
|
1110 } |
3556
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
1111 if (shader) { |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
1112 result = IDirect3DDevice9_SetPixelShader(data->device, NULL); |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
1113 if (FAILED(result)) { |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
1114 D3D_SetError("SetShader()", result); |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
1115 return -1; |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
1116 } |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
1117 } |
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
|
1118 return 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
|
1119 } |
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
|
1120 |
3427
36cf454ba065
Work in progress on implementation of SDL_RenderReadPixels() and SDL_RenderWritePixels(), code untested.
Sam Lantinga <slouken@libsdl.org>
parents:
3279
diff
changeset
|
1121 static int |
36cf454ba065
Work in progress on implementation of SDL_RenderReadPixels() and SDL_RenderWritePixels(), code untested.
Sam Lantinga <slouken@libsdl.org>
parents:
3279
diff
changeset
|
1122 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
|
1123 Uint32 format, void * pixels, int pitch) |
3427
36cf454ba065
Work in progress on implementation of SDL_RenderReadPixels() and SDL_RenderWritePixels(), code untested.
Sam Lantinga <slouken@libsdl.org>
parents:
3279
diff
changeset
|
1124 { |
3549
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1125 D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3675
diff
changeset
|
1126 SDL_Window *window = renderer->window; |
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3675
diff
changeset
|
1127 SDL_VideoDisplay *display = window->display; |
3549
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1128 D3DSURFACE_DESC desc; |
3427
36cf454ba065
Work in progress on implementation of SDL_RenderReadPixels() and SDL_RenderWritePixels(), code untested.
Sam Lantinga <slouken@libsdl.org>
parents:
3279
diff
changeset
|
1129 LPDIRECT3DSURFACE9 backBuffer; |
3549
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1130 LPDIRECT3DSURFACE9 surface; |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1131 RECT d3drect; |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1132 D3DLOCKED_RECT locked; |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1133 HRESULT result; |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1134 |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1135 result = IDirect3DDevice9_GetBackBuffer(data->device, 0, 0, D3DBACKBUFFER_TYPE_MONO, &backBuffer); |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1136 if (FAILED(result)) { |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1137 D3D_SetError("GetBackBuffer()", result); |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1138 return -1; |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1139 } |
3427
36cf454ba065
Work in progress on implementation of SDL_RenderReadPixels() and SDL_RenderWritePixels(), code untested.
Sam Lantinga <slouken@libsdl.org>
parents:
3279
diff
changeset
|
1140 |
3549
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1141 result = IDirect3DSurface9_GetDesc(backBuffer, &desc); |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1142 if (FAILED(result)) { |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1143 D3D_SetError("GetDesc()", result); |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1144 IDirect3DSurface9_Release(backBuffer); |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1145 return -1; |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1146 } |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1147 |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1148 result = IDirect3DDevice9_CreateOffscreenPlainSurface(data->device, desc.Width, desc.Height, desc.Format, D3DPOOL_SYSTEMMEM, &surface, NULL); |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1149 if (FAILED(result)) { |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1150 D3D_SetError("CreateOffscreenPlainSurface()", result); |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1151 IDirect3DSurface9_Release(backBuffer); |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1152 return -1; |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1153 } |
3427
36cf454ba065
Work in progress on implementation of SDL_RenderReadPixels() and SDL_RenderWritePixels(), code untested.
Sam Lantinga <slouken@libsdl.org>
parents:
3279
diff
changeset
|
1154 |
3549
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1155 result = IDirect3DDevice9_GetRenderTargetData(data->device, backBuffer, surface); |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1156 if (FAILED(result)) { |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1157 D3D_SetError("GetRenderTargetData()", result); |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1158 IDirect3DSurface9_Release(surface); |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1159 IDirect3DSurface9_Release(backBuffer); |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1160 return -1; |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1161 } |
3427
36cf454ba065
Work in progress on implementation of SDL_RenderReadPixels() and SDL_RenderWritePixels(), code untested.
Sam Lantinga <slouken@libsdl.org>
parents:
3279
diff
changeset
|
1162 |
3549
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1163 d3drect.left = rect->x; |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1164 d3drect.right = rect->x + rect->w; |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1165 d3drect.top = rect->y; |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1166 d3drect.bottom = rect->y + rect->h; |
3427
36cf454ba065
Work in progress on implementation of SDL_RenderReadPixels() and SDL_RenderWritePixels(), code untested.
Sam Lantinga <slouken@libsdl.org>
parents:
3279
diff
changeset
|
1167 |
3549
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1168 result = IDirect3DSurface9_LockRect(surface, &locked, &d3drect, D3DLOCK_READONLY); |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1169 if (FAILED(result)) { |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1170 D3D_SetError("LockRect()", result); |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1171 IDirect3DSurface9_Release(surface); |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1172 IDirect3DSurface9_Release(backBuffer); |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1173 return -1; |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1174 } |
3427
36cf454ba065
Work in progress on implementation of SDL_RenderReadPixels() and SDL_RenderWritePixels(), code untested.
Sam Lantinga <slouken@libsdl.org>
parents:
3279
diff
changeset
|
1175 |
3549
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1176 SDL_ConvertPixels(rect->w, rect->h, |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1177 display->current_mode.format, locked.pBits, locked.Pitch, |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1178 format, pixels, pitch); |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1179 |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1180 IDirect3DSurface9_UnlockRect(surface); |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1181 |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1182 IDirect3DSurface9_Release(surface); |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1183 IDirect3DSurface9_Release(backBuffer); |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1184 |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1185 return 0; |
3427
36cf454ba065
Work in progress on implementation of SDL_RenderReadPixels() and SDL_RenderWritePixels(), code untested.
Sam Lantinga <slouken@libsdl.org>
parents:
3279
diff
changeset
|
1186 } |
36cf454ba065
Work in progress on implementation of SDL_RenderReadPixels() and SDL_RenderWritePixels(), code untested.
Sam Lantinga <slouken@libsdl.org>
parents:
3279
diff
changeset
|
1187 |
3480
cd763d104465
The Direct3D Read/Write pixels interface is in progress.
Sam Lantinga <slouken@libsdl.org>
parents:
3427
diff
changeset
|
1188 static int |
cd763d104465
The Direct3D Read/Write pixels interface is in progress.
Sam Lantinga <slouken@libsdl.org>
parents:
3427
diff
changeset
|
1189 D3D_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect, |
cd763d104465
The Direct3D Read/Write pixels interface is in progress.
Sam Lantinga <slouken@libsdl.org>
parents:
3427
diff
changeset
|
1190 Uint32 format, const void * pixels, int pitch) |
cd763d104465
The Direct3D Read/Write pixels interface is in progress.
Sam Lantinga <slouken@libsdl.org>
parents:
3427
diff
changeset
|
1191 { |
cd763d104465
The Direct3D Read/Write pixels interface is in progress.
Sam Lantinga <slouken@libsdl.org>
parents:
3427
diff
changeset
|
1192 /* Work in progress */ |
3553
a579694613fd
Note that the WritePixels call is unsupported right now.
Sam Lantinga <slouken@libsdl.org>
parents:
3551
diff
changeset
|
1193 SDL_Unsupported(); |
3480
cd763d104465
The Direct3D Read/Write pixels interface is in progress.
Sam Lantinga <slouken@libsdl.org>
parents:
3427
diff
changeset
|
1194 return -1; |
cd763d104465
The Direct3D Read/Write pixels interface is in progress.
Sam Lantinga <slouken@libsdl.org>
parents:
3427
diff
changeset
|
1195 } |
cd763d104465
The Direct3D Read/Write pixels interface is in progress.
Sam Lantinga <slouken@libsdl.org>
parents:
3427
diff
changeset
|
1196 |
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
|
1197 static void |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
1198 D3D_RenderPresent(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
|
1199 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
1200 D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
1201 HRESULT result; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
1202 |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
1203 if (!data->beginScene) { |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
1204 IDirect3DDevice9_EndScene(data->device); |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
1205 data->beginScene = SDL_TRUE; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
1206 } |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
1207 |
1975
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
1208 result = IDirect3DDevice9_TestCooperativeLevel(data->device); |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
1209 if (result == D3DERR_DEVICELOST) { |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
1210 /* We'll reset later */ |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
1211 return; |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
1212 } |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
1213 if (result == D3DERR_DEVICENOTRESET) { |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
1214 D3D_Reset(renderer); |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
1215 } |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
1216 result = IDirect3DDevice9_Present(data->device, NULL, NULL, NULL, NULL); |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
1217 if (FAILED(result)) { |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
1218 D3D_SetError("Present()", result); |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
1219 } |
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
|
1220 } |
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
|
1221 |
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
|
1222 static void |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
1223 D3D_DestroyTexture(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
|
1224 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
1225 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
|
1226 |
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
|
1227 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
|
1228 return; |
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
|
1229 } |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
1230 if (data->yuv) { |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
1231 SDL_SW_DestroyYUVTexture(data->yuv); |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
1232 } |
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
|
1233 if (data->texture) { |
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
|
1234 IDirect3DTexture9_Release(data->texture); |
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
|
1235 } |
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
|
1236 SDL_free(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
|
1237 texture->driverdata = 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
|
1238 } |
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
|
1239 |
1975
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
1240 static void |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
1241 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
|
1242 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
1243 D3D_RenderData *data = (D3D_RenderData *) renderer->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
|
1244 |
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
|
1245 if (data) { |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
1246 if (data->device) { |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
1247 IDirect3DDevice9_Release(data->device); |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
1248 } |
5157
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:
5152
diff
changeset
|
1249 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:
5152
diff
changeset
|
1250 IDirect3D9_Release(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:
5152
diff
changeset
|
1251 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:
5152
diff
changeset
|
1252 } |
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
|
1253 SDL_free(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
|
1254 } |
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
|
1255 SDL_free(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
|
1256 } |
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
|
1257 |
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
|
1258 #endif /* SDL_VIDEO_RENDER_D3D */ |
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
|
1259 |
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
|
1260 /* vi: set ts=4 sw=4 expandtab: */ |