Mercurial > sdl-ios-xcode
annotate src/render/direct3d/SDL_d3drender.c @ 5176:ebfedf3787b1
Standardized on using the managed texture pool.
Also experimented with dynamic textures, but didn't get any speed increase with them. More research and testing is needed.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Fri, 04 Feb 2011 12:25:26 -0800 |
parents | 4d39eeaad00b |
children | d976b67150c5 |
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 |
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 #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
|
33 #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
|
34 #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
|
35 #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
|
36 |
3556
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
37 #ifdef ASSEMBLE_SHADER |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
38 /////////////////////////////////////////////////////////////////////////// |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
39 // ID3DXBuffer: |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
40 // ------------ |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
41 // 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
|
42 // |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
43 // GetBufferPointer - |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
44 // 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
|
45 // |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
46 // GetBufferSize - |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
47 // 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
|
48 /////////////////////////////////////////////////////////////////////////// |
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 typedef interface ID3DXBuffer ID3DXBuffer; |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
51 typedef interface ID3DXBuffer *LPD3DXBUFFER; |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
52 |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
53 // {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
|
54 DEFINE_GUID(IID_ID3DXBuffer, |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
55 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
|
56 |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
57 #undef INTERFACE |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
58 #define INTERFACE ID3DXBuffer |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
59 |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
60 typedef interface ID3DXBuffer { |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
61 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
|
62 } ID3DXBuffer; |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
63 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
|
64 const struct ID3DXBufferVtbl |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
65 { |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
66 // IUnknown |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
67 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
|
68 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
|
69 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
|
70 |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
71 // ID3DXBuffer |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
72 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
|
73 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
|
74 }; |
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 HRESULT WINAPI |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
77 D3DXAssembleShader( |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
78 LPCSTR pSrcData, |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
79 UINT SrcDataLen, |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
80 CONST LPVOID* pDefines, |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
81 LPVOID pInclude, |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
82 DWORD Flags, |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
83 LPD3DXBUFFER* ppShader, |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
84 LPD3DXBUFFER* ppErrorMsgs); |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
85 |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
86 #endif /* ASSEMBLE_SHADER */ |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
87 |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
88 |
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
|
89 /* 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
|
90 |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
91 static SDL_Renderer *D3D_CreateRenderer(SDL_Window * window, Uint32 flags); |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
92 static int D3D_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture); |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
93 static int D3D_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
94 const SDL_Rect * rect, const void *pixels, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
95 int pitch); |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
96 static int D3D_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, |
5159
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
97 const SDL_Rect * rect, void **pixels, int *pitch); |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
98 static void D3D_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture); |
3599
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
99 static int D3D_RenderDrawPoints(SDL_Renderer * renderer, |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
100 const SDL_Point * points, int count); |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
101 static int D3D_RenderDrawLines(SDL_Renderer * renderer, |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
102 const SDL_Point * points, int count); |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
103 static int D3D_RenderFillRects(SDL_Renderer * renderer, |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
104 const SDL_Rect ** rects, int count); |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
105 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
|
106 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
|
107 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
|
108 Uint32 format, void * pixels, int pitch); |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
109 static void D3D_RenderPresent(SDL_Renderer * renderer); |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
110 static void D3D_DestroyTexture(SDL_Renderer * renderer, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
111 SDL_Texture * texture); |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
112 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
|
113 |
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
|
114 |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
115 SDL_RenderDriver D3D_RenderDriver = { |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
116 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
|
117 { |
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
|
118 "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
|
119 (SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED), |
5159
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
120 1, |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
121 {SDL_PIXELFORMAT_ARGB8888}, |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
122 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
|
123 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
|
124 }; |
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
|
125 |
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
|
126 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
|
127 { |
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
|
128 void* d3dDLL; |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
129 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
|
130 IDirect3DDevice9 *device; |
3527
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
131 UINT adapter; |
1975
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
132 D3DPRESENT_PARAMETERS pparams; |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
133 SDL_bool beginScene; |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
134 } 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
|
135 |
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
|
136 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
|
137 { |
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
|
138 IDirect3DTexture9 *texture; |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
139 } 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
|
140 |
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
|
141 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
|
142 { |
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
|
143 float x, y, z; |
1904
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
144 float rhw; |
1987
36a08379b3f2
Implemented color modulation in the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
145 DWORD color; |
1904
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
146 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
|
147 } 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
|
148 |
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
|
149 static void |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
150 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
|
151 { |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
152 const char *error; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
153 |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
154 switch (result) { |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
155 case D3DERR_WRONGTEXTUREFORMAT: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
156 error = "WRONGTEXTUREFORMAT"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
157 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
158 case D3DERR_UNSUPPORTEDCOLOROPERATION: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
159 error = "UNSUPPORTEDCOLOROPERATION"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
160 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
161 case D3DERR_UNSUPPORTEDCOLORARG: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
162 error = "UNSUPPORTEDCOLORARG"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
163 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
164 case D3DERR_UNSUPPORTEDALPHAOPERATION: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
165 error = "UNSUPPORTEDALPHAOPERATION"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
166 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
167 case D3DERR_UNSUPPORTEDALPHAARG: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
168 error = "UNSUPPORTEDALPHAARG"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
169 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
170 case D3DERR_TOOMANYOPERATIONS: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
171 error = "TOOMANYOPERATIONS"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
172 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
173 case D3DERR_CONFLICTINGTEXTUREFILTER: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
174 error = "CONFLICTINGTEXTUREFILTER"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
175 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
176 case D3DERR_UNSUPPORTEDFACTORVALUE: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
177 error = "UNSUPPORTEDFACTORVALUE"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
178 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
179 case D3DERR_CONFLICTINGRENDERSTATE: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
180 error = "CONFLICTINGRENDERSTATE"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
181 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
182 case D3DERR_UNSUPPORTEDTEXTUREFILTER: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
183 error = "UNSUPPORTEDTEXTUREFILTER"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
184 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
185 case D3DERR_CONFLICTINGTEXTUREPALETTE: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
186 error = "CONFLICTINGTEXTUREPALETTE"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
187 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
188 case D3DERR_DRIVERINTERNALERROR: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
189 error = "DRIVERINTERNALERROR"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
190 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
191 case D3DERR_NOTFOUND: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
192 error = "NOTFOUND"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
193 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
194 case D3DERR_MOREDATA: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
195 error = "MOREDATA"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
196 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
197 case D3DERR_DEVICELOST: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
198 error = "DEVICELOST"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
199 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
200 case D3DERR_DEVICENOTRESET: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
201 error = "DEVICENOTRESET"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
202 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
203 case D3DERR_NOTAVAILABLE: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
204 error = "NOTAVAILABLE"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
205 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
206 case D3DERR_OUTOFVIDEOMEMORY: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
207 error = "OUTOFVIDEOMEMORY"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
208 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
209 case D3DERR_INVALIDDEVICE: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
210 error = "INVALIDDEVICE"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
211 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
212 case D3DERR_INVALIDCALL: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
213 error = "INVALIDCALL"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
214 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
215 case D3DERR_DRIVERINVALIDCALL: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
216 error = "DRIVERINVALIDCALL"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
217 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
218 case D3DERR_WASSTILLDRAWING: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
219 error = "WASSTILLDRAWING"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
220 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
221 default: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
222 error = "UNKNOWN"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
223 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
224 } |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
225 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
|
226 } |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
227 |
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
|
228 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
|
229 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
|
230 { |
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
|
231 switch (format) { |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
232 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
|
233 return D3DFMT_R5G6B5; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
234 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
|
235 return D3DFMT_X8R8G8B8; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
236 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
|
237 return D3DFMT_A8R8G8B8; |
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
238 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
|
239 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
|
240 } |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
241 } |
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
|
242 |
5159
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
243 static Uint32 |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
244 D3DFMTToPixelFormat(D3DFORMAT format) |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
245 { |
5159
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
246 switch (format) { |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
247 case D3DFMT_R5G6B5: |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
248 return SDL_PIXELFORMAT_RGB565; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
249 case D3DFMT_X8R8G8B8: |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
250 return SDL_PIXELFORMAT_RGB888; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
251 case D3DFMT_A8R8G8B8: |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
252 return SDL_PIXELFORMAT_ARGB8888; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
253 default: |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
254 return SDL_PIXELFORMAT_UNKNOWN; |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
255 } |
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
|
256 } |
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
|
257 |
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
|
258 SDL_Renderer * |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
259 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
|
260 { |
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
|
261 SDL_Renderer *renderer; |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
262 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
|
263 SDL_SysWMinfo windowinfo; |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
264 HRESULT result; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
265 D3DPRESENT_PARAMETERS pparams; |
1907
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
266 IDirect3DSwapChain9 *chain; |
1925
411bfb37082b
Query the maximum texture size for the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
267 D3DCAPS9 caps; |
5159
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
268 Uint32 window_flags; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
269 int w, h; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
270 SDL_DisplayMode fullscreen_mode; |
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
|
271 |
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
|
272 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
|
273 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
|
274 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
|
275 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
|
276 } |
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
|
277 |
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
|
278 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
|
279 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
|
280 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
|
281 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
|
282 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
|
283 } |
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
|
284 |
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
|
285 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
|
286 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
|
287 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
|
288 |
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
|
289 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
|
290 (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
|
291 "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
|
292 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
|
293 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
|
294 } |
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
|
295 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
|
296 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
|
297 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
|
298 } |
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
|
299 } |
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
|
300 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
|
301 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
|
302 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
|
303 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
|
304 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
|
305 } |
4569 | 306 |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
307 renderer->CreateTexture = D3D_CreateTexture; |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
308 renderer->UpdateTexture = D3D_UpdateTexture; |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
309 renderer->LockTexture = D3D_LockTexture; |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
310 renderer->UnlockTexture = D3D_UnlockTexture; |
3599
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
311 renderer->RenderDrawPoints = D3D_RenderDrawPoints; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
312 renderer->RenderDrawLines = D3D_RenderDrawLines; |
3675 | 313 renderer->RenderFillRects = D3D_RenderFillRects; |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
314 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
|
315 renderer->RenderReadPixels = D3D_RenderReadPixels; |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
316 renderer->RenderPresent = D3D_RenderPresent; |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
317 renderer->DestroyTexture = D3D_DestroyTexture; |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
318 renderer->DestroyRenderer = D3D_DestroyRenderer; |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
319 renderer->info = D3D_RenderDriver.info; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
320 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
|
321 |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
322 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
|
323 |
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
|
324 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
|
325 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
|
326 |
5159
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
327 window_flags = SDL_GetWindowFlags(window); |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
328 SDL_GetWindowSize(window, &w, &h); |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
329 SDL_GetWindowDisplayMode(window, &fullscreen_mode); |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
330 |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
331 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
|
332 pparams.hDeviceWindow = windowinfo.info.win.window; |
5159
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
333 pparams.BackBufferWidth = w; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
334 pparams.BackBufferHeight = h; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
335 if (window_flags & SDL_WINDOW_FULLSCREEN) { |
1903
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
336 pparams.BackBufferFormat = |
5159
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
337 PixelFormatToD3DFMT(fullscreen_mode.format); |
1903
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
338 } 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
|
339 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
|
340 } |
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
|
341 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
|
342 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
|
343 |
5159
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
344 if (window_flags & SDL_WINDOW_FULLSCREEN) { |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
345 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
|
346 pparams.FullScreen_RefreshRateInHz = |
5159
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
347 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
|
348 } else { |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
349 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
|
350 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
|
351 } |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
352 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
|
353 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
|
354 } else { |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
355 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
|
356 } |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
357 |
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
|
358 /* 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
|
359 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
|
360 IDirect3D9_GetDeviceCaps(data->d3d, data->adapter, D3DDEVTYPE_HAL, &caps); |
3197 | 361 |
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
|
362 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
|
363 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
|
364 pparams.hDeviceWindow, |
3197 | 365 (caps. |
366 DevCaps & | |
367 D3DDEVCAPS_HWTRANSFORMANDLIGHT) ? | |
368 D3DCREATE_HARDWARE_VERTEXPROCESSING : | |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
369 D3DCREATE_SOFTWARE_VERTEXPROCESSING, |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
370 &pparams, &data->device); |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
371 if (FAILED(result)) { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
372 D3D_DestroyRenderer(renderer); |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
373 D3D_SetError("CreateDevice()", result); |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
374 return NULL; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
375 } |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
376 data->beginScene = SDL_TRUE; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
377 |
1907
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
378 /* 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
|
379 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
|
380 if (FAILED(result)) { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
381 D3D_DestroyRenderer(renderer); |
1907
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
382 D3D_SetError("GetSwapChain()", result); |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
383 return NULL; |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
384 } |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
385 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
|
386 if (FAILED(result)) { |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
387 IDirect3DSwapChain9_Release(chain); |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
388 D3D_DestroyRenderer(renderer); |
1907
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
389 D3D_SetError("GetPresentParameters()", result); |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
390 return NULL; |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
391 } |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
392 IDirect3DSwapChain9_Release(chain); |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
393 if (pparams.PresentationInterval == D3DPRESENT_INTERVAL_ONE) { |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
394 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
|
395 } |
1975
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
396 data->pparams = pparams; |
1907
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
397 |
1925
411bfb37082b
Query the maximum texture size for the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
398 IDirect3DDevice9_GetDeviceCaps(data->device, &caps); |
411bfb37082b
Query the maximum texture size for the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
399 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
|
400 renderer->info.max_texture_height = caps.MaxTextureHeight; |
1918
092bd3a019c5
Starting on the OpenGL renderer...
Sam Lantinga <slouken@libsdl.org>
parents:
1917
diff
changeset
|
401 |
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
|
402 /* Set up parameters for rendering */ |
1904
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
403 IDirect3DDevice9_SetVertexShader(data->device, NULL); |
1987
36a08379b3f2
Implemented color modulation in the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
404 IDirect3DDevice9_SetFVF(data->device, |
36a08379b3f2
Implemented color modulation in the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
405 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
|
406 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
|
407 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
|
408 D3DCULL_NONE); |
1904
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
409 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
|
410 /* 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
|
411 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
|
412 D3DTOP_MODULATE); |
1ee02169bbb0
Figured out how texture stages work, thanks to this:
Sam Lantinga <slouken@libsdl.org>
parents:
1987
diff
changeset
|
413 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
|
414 D3DTA_TEXTURE); |
1ee02169bbb0
Figured out how texture stages work, thanks to this:
Sam Lantinga <slouken@libsdl.org>
parents:
1987
diff
changeset
|
415 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
|
416 D3DTA_DIFFUSE); |
1ee02169bbb0
Figured out how texture stages work, thanks to this:
Sam Lantinga <slouken@libsdl.org>
parents:
1987
diff
changeset
|
417 /* 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
|
418 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
|
419 D3DTOP_MODULATE); |
1ee02169bbb0
Figured out how texture stages work, thanks to this:
Sam Lantinga <slouken@libsdl.org>
parents:
1987
diff
changeset
|
420 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
|
421 D3DTA_TEXTURE); |
1ee02169bbb0
Figured out how texture stages work, thanks to this:
Sam Lantinga <slouken@libsdl.org>
parents:
1987
diff
changeset
|
422 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
|
423 D3DTA_DIFFUSE); |
1991
3863ba81c1d6
Clear the second texture stage explicitly
Sam Lantinga <slouken@libsdl.org>
parents:
1988
diff
changeset
|
424 /* Disable second texture stage, since we're done */ |
3863ba81c1d6
Clear the second texture stage explicitly
Sam Lantinga <slouken@libsdl.org>
parents:
1988
diff
changeset
|
425 IDirect3DDevice9_SetTextureStageState(data->device, 1, D3DTSS_COLOROP, |
3863ba81c1d6
Clear the second texture stage explicitly
Sam Lantinga <slouken@libsdl.org>
parents:
1988
diff
changeset
|
426 D3DTOP_DISABLE); |
3863ba81c1d6
Clear the second texture stage explicitly
Sam Lantinga <slouken@libsdl.org>
parents:
1988
diff
changeset
|
427 IDirect3DDevice9_SetTextureStageState(data->device, 1, D3DTSS_ALPHAOP, |
3863ba81c1d6
Clear the second texture stage explicitly
Sam Lantinga <slouken@libsdl.org>
parents:
1988
diff
changeset
|
428 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
|
429 |
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
|
430 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
|
431 } |
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
|
432 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
433 static int |
1975
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
434 D3D_Reset(SDL_Renderer * renderer) |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
435 { |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
436 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
|
437 HRESULT result; |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
438 |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
439 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
|
440 if (FAILED(result)) { |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
441 if (result == D3DERR_DEVICELOST) { |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
442 /* 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
|
443 return 0; |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
444 } else { |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
445 D3D_SetError("Reset()", result); |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
446 return -1; |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
447 } |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
448 } |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
449 IDirect3DDevice9_SetVertexShader(data->device, NULL); |
1987
36a08379b3f2
Implemented color modulation in the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
450 IDirect3DDevice9_SetFVF(data->device, |
36a08379b3f2
Implemented color modulation in the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
451 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
|
452 IDirect3DDevice9_SetRenderState(data->device, D3DRS_CULLMODE, |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
453 D3DCULL_NONE); |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
454 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
|
455 return 0; |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
456 } |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
457 |
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
|
458 /* 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
|
459 #if 0 |
1975
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
460 static int |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
461 D3D_DisplayModeChanged(SDL_Renderer * renderer) |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
462 { |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
463 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
|
464 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
|
465 SDL_VideoDisplay *display = window->display; |
1975
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
466 |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
467 data->pparams.BackBufferWidth = window->w; |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
468 data->pparams.BackBufferHeight = window->h; |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
469 if (window->flags & SDL_WINDOW_FULLSCREEN) { |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
470 data->pparams.BackBufferFormat = |
3519
1374f9275de9
Fixed compiling the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3495
diff
changeset
|
471 PixelFormatToD3DFMT(window->fullscreen_mode.format); |
1975
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
472 } else { |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
473 data->pparams.BackBufferFormat = D3DFMT_UNKNOWN; |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
474 } |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
475 return D3D_Reset(renderer); |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
476 } |
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
|
477 #endif |
1975
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
478 |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
479 static int |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
480 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
|
481 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
482 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
|
483 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
|
484 D3DFORMAT display_format = renderdata->pparams.BackBufferFormat; |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
485 D3D_TextureData *data; |
5176
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5169
diff
changeset
|
486 D3DPOOL pool; |
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5169
diff
changeset
|
487 DWORD usage; |
1903
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
488 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
|
489 |
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
|
490 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
|
491 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
|
492 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
|
493 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
|
494 } |
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
|
495 |
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
|
496 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
|
497 |
5176
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5169
diff
changeset
|
498 #ifdef USE_DYNAMIC_TEXTURE |
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5169
diff
changeset
|
499 if (texture->access == SDL_TEXTUREACCESS_STREAMING) { |
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5169
diff
changeset
|
500 pool = D3DPOOL_DEFAULT; |
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5169
diff
changeset
|
501 usage = D3DUSAGE_DYNAMIC; |
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5169
diff
changeset
|
502 } else |
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5169
diff
changeset
|
503 #endif |
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5169
diff
changeset
|
504 { |
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5169
diff
changeset
|
505 pool = D3DPOOL_MANAGED; |
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5169
diff
changeset
|
506 usage = 0; |
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5169
diff
changeset
|
507 } |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
508 |
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
|
509 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
|
510 IDirect3DDevice9_CreateTexture(renderdata->device, texture->w, |
5176
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5169
diff
changeset
|
511 texture->h, 1, usage, |
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5169
diff
changeset
|
512 PixelFormatToD3DFMT(texture->format), |
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5169
diff
changeset
|
513 pool, &data->texture, NULL); |
1903
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
514 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
|
515 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
|
516 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
|
517 } |
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
|
518 |
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
|
519 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
|
520 } |
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
|
521 |
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
|
522 static int |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
523 D3D_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
524 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
|
525 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
526 D3D_TextureData *data = (D3D_TextureData *) texture->driverdata; |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
527 D3D_RenderData *renderdata = (D3D_RenderData *) renderer->driverdata; |
5159
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
528 RECT d3drect; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
529 D3DLOCKED_RECT locked; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
530 const Uint8 *src; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
531 Uint8 *dst; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
532 int row, length; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
533 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
|
534 |
5176
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5169
diff
changeset
|
535 #ifdef USE_DYNAMIC_TEXTURE |
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5169
diff
changeset
|
536 if (texture->access == SDL_TEXTUREACCESS_STREAMING && |
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5169
diff
changeset
|
537 rect->x == 0 && rect->y == 0 && |
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5169
diff
changeset
|
538 rect->w == texture->w && rect->h == texture->h) { |
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5169
diff
changeset
|
539 result = IDirect3DTexture9_LockRect(data->texture, 0, &locked, NULL, D3DLOCK_DISCARD); |
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5169
diff
changeset
|
540 } else |
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5169
diff
changeset
|
541 #endif |
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5169
diff
changeset
|
542 { |
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5169
diff
changeset
|
543 d3drect.left = rect->x; |
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5169
diff
changeset
|
544 d3drect.right = rect->x + rect->w; |
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5169
diff
changeset
|
545 d3drect.top = rect->y; |
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5169
diff
changeset
|
546 d3drect.bottom = rect->y + rect->h; |
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5169
diff
changeset
|
547 result = IDirect3DTexture9_LockRect(data->texture, 0, &locked, &d3drect, 0); |
5159
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
548 } |
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
|
549 |
5159
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
550 if (FAILED(result)) { |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
551 D3D_SetError("LockRect()", result); |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
552 return -1; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
553 } |
2783
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
554 |
5159
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
555 src = pixels; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
556 dst = locked.pBits; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
557 length = rect->w * SDL_BYTESPERPIXEL(texture->format); |
5176
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5169
diff
changeset
|
558 if (length == pitch && length == locked.Pitch) { |
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5169
diff
changeset
|
559 SDL_memcpy(dst, src, length*rect->h); |
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5169
diff
changeset
|
560 } else { |
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5169
diff
changeset
|
561 for (row = 0; row < rect->h; ++row) { |
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5169
diff
changeset
|
562 SDL_memcpy(dst, src, length); |
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5169
diff
changeset
|
563 src += pitch; |
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5169
diff
changeset
|
564 dst += locked.Pitch; |
ebfedf3787b1
Standardized on using the managed texture pool.
Sam Lantinga <slouken@libsdl.org>
parents:
5169
diff
changeset
|
565 } |
5159
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
566 } |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
567 IDirect3DTexture9_UnlockRect(data->texture, 0); |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
568 |
5159
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
569 return 0; |
2783
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
570 } |
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
|
571 |
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
|
572 static int |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
573 D3D_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, |
5159
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
574 const SDL_Rect * rect, void **pixels, int *pitch) |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
575 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
576 D3D_TextureData *data = (D3D_TextureData *) texture->driverdata; |
5159
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
577 RECT d3drect; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
578 D3DLOCKED_RECT locked; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
579 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
|
580 |
5159
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
581 d3drect.left = rect->x; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
582 d3drect.right = rect->x + rect->w; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
583 d3drect.top = rect->y; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
584 d3drect.bottom = rect->y + rect->h; |
1903
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
585 |
5159
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
586 result = IDirect3DTexture9_LockRect(data->texture, 0, &locked, &d3drect, 0); |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
587 if (FAILED(result)) { |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
588 D3D_SetError("LockRect()", result); |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
589 return -1; |
1903
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
590 } |
5159
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
591 *pixels = locked.pBits; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
592 *pitch = locked.Pitch; |
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
593 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
|
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 |
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 static void |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
597 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
|
598 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
599 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
|
600 |
5159
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
601 IDirect3DTexture9_UnlockRect(data->texture, 0); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
602 } |
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
|
603 |
2932
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
604 static void |
2933 | 605 D3D_SetBlendMode(D3D_RenderData * data, int blendMode) |
2932
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
606 { |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
607 switch (blendMode) { |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
608 case SDL_BLENDMODE_NONE: |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
609 IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE, |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
610 FALSE); |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
611 break; |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
612 case SDL_BLENDMODE_BLEND: |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
613 IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE, |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
614 TRUE); |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
615 IDirect3DDevice9_SetRenderState(data->device, D3DRS_SRCBLEND, |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
616 D3DBLEND_SRCALPHA); |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
617 IDirect3DDevice9_SetRenderState(data->device, D3DRS_DESTBLEND, |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
618 D3DBLEND_INVSRCALPHA); |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
619 break; |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
620 case SDL_BLENDMODE_ADD: |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
621 IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE, |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
622 TRUE); |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
623 IDirect3DDevice9_SetRenderState(data->device, D3DRS_SRCBLEND, |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
624 D3DBLEND_SRCALPHA); |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
625 IDirect3DDevice9_SetRenderState(data->device, D3DRS_DESTBLEND, |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
626 D3DBLEND_ONE); |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
627 break; |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
628 } |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
629 } |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
630 |
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
|
631 static int |
3599
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
632 D3D_RenderDrawPoints(SDL_Renderer * renderer, const SDL_Point * points, |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
633 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
|
634 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
635 D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; |
2932
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
636 DWORD color; |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
637 Vertex *vertices; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
638 int i; |
2932
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
639 HRESULT result; |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
640 |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
641 if (data->beginScene) { |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
642 IDirect3DDevice9_BeginScene(data->device); |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
643 data->beginScene = SDL_FALSE; |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
644 } |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
645 |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
646 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
|
647 |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
648 result = |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
649 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
|
650 (IDirect3DBaseTexture9 *) 0); |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
651 if (FAILED(result)) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
652 D3D_SetError("SetTexture()", result); |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
653 return -1; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
654 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
655 |
2932
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
656 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
|
657 |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
658 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
|
659 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
|
660 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
|
661 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
|
662 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
|
663 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
|
664 vertices[i].color = color; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
665 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
|
666 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
|
667 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
668 result = |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
669 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
|
670 vertices, sizeof(*vertices)); |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
671 SDL_stack_free(vertices); |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
672 if (FAILED(result)) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
673 D3D_SetError("DrawPrimitiveUP()", result); |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
674 return -1; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
675 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
676 return 0; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
677 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
678 |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
679 static int |
3599
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
680 D3D_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points, |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
681 int count) |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
682 { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
683 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
|
684 DWORD color; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
685 Vertex *vertices; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
686 int i; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
687 HRESULT result; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
688 |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
689 if (data->beginScene) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
690 IDirect3DDevice9_BeginScene(data->device); |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
691 data->beginScene = SDL_FALSE; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
692 } |
2932
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
693 |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
694 D3D_SetBlendMode(data, renderer->blendMode); |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
695 |
2933 | 696 result = |
697 IDirect3DDevice9_SetTexture(data->device, 0, | |
698 (IDirect3DBaseTexture9 *) 0); | |
2932
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
699 if (FAILED(result)) { |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
700 D3D_SetError("SetTexture()", result); |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
701 return -1; |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
702 } |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
703 |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
704 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
|
705 |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
706 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
|
707 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
|
708 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
|
709 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
|
710 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
|
711 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
|
712 vertices[i].color = color; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
713 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
|
714 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
|
715 } |
2932
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
716 result = |
3551
4a39f28cd935
Fixed line drawing for D3D
Sam Lantinga <slouken@libsdl.org>
parents:
3549
diff
changeset
|
717 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
|
718 vertices, sizeof(*vertices)); |
3551
4a39f28cd935
Fixed line drawing for D3D
Sam Lantinga <slouken@libsdl.org>
parents:
3549
diff
changeset
|
719 |
4a39f28cd935
Fixed line drawing for D3D
Sam Lantinga <slouken@libsdl.org>
parents:
3549
diff
changeset
|
720 /* 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
|
721 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
|
722 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
|
723 vertices[0].x = (float) points[count-1].x; |
4a39f28cd935
Fixed line drawing for D3D
Sam Lantinga <slouken@libsdl.org>
parents:
3549
diff
changeset
|
724 vertices[0].y = (float) points[count-1].y; |
4a39f28cd935
Fixed line drawing for D3D
Sam Lantinga <slouken@libsdl.org>
parents:
3549
diff
changeset
|
725 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
|
726 } |
4a39f28cd935
Fixed line drawing for D3D
Sam Lantinga <slouken@libsdl.org>
parents:
3549
diff
changeset
|
727 |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
728 SDL_stack_free(vertices); |
2932
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
729 if (FAILED(result)) { |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
730 D3D_SetError("DrawPrimitiveUP()", result); |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
731 return -1; |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
732 } |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
733 return 0; |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
734 } |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
735 |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
736 static int |
3599
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
737 D3D_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects, |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
738 int count) |
2932
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
739 { |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
740 D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
741 DWORD color; |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
742 int i; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
743 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
|
744 Vertex vertices[4]; |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
745 HRESULT result; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
746 |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
747 if (data->beginScene) { |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
748 IDirect3DDevice9_BeginScene(data->device); |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
749 data->beginScene = SDL_FALSE; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
750 } |
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
|
751 |
2932
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
752 D3D_SetBlendMode(data, renderer->blendMode); |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
753 |
2933 | 754 result = |
755 IDirect3DDevice9_SetTexture(data->device, 0, | |
756 (IDirect3DBaseTexture9 *) 0); | |
2932
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
757 if (FAILED(result)) { |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
758 D3D_SetError("SetTexture()", result); |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
759 return -1; |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
760 } |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
761 |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
762 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
|
763 |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
764 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
|
765 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
|
766 |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
767 minx = (float) rect->x; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
768 miny = (float) rect->y; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
769 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
|
770 maxy = (float) rect->y + rect->h; |
2932
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
771 |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
772 vertices[0].x = minx; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
773 vertices[0].y = miny; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
774 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
|
775 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
|
776 vertices[0].color = color; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
777 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
|
778 vertices[0].v = 0.0f; |
2932
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
779 |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
780 vertices[1].x = maxx; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
781 vertices[1].y = miny; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
782 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
|
783 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
|
784 vertices[1].color = color; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
785 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
|
786 vertices[1].v = 0.0f; |
2932
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
787 |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
788 vertices[2].x = maxx; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
789 vertices[2].y = maxy; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
790 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
|
791 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
|
792 vertices[2].color = color; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
793 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
|
794 vertices[2].v = 0.0f; |
2932
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
795 |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
796 vertices[3].x = minx; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
797 vertices[3].y = maxy; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
798 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
|
799 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
|
800 vertices[3].color = color; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
801 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
|
802 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
|
803 |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
804 result = |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
805 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
|
806 2, vertices, sizeof(*vertices)); |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
807 if (FAILED(result)) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
808 D3D_SetError("DrawPrimitiveUP()", result); |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
809 return -1; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
810 } |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
811 } |
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
|
812 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
|
813 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
814 |
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
|
815 static int |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
816 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
|
817 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
|
818 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
819 D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
820 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
|
821 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
|
822 float minx, miny, maxx, maxy; |
1904
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
823 float minu, maxu, minv, maxv; |
1987
36a08379b3f2
Implemented color modulation in the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
824 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
|
825 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
|
826 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
|
827 |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
828 if (data->beginScene) { |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
829 IDirect3DDevice9_BeginScene(data->device); |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
830 data->beginScene = SDL_FALSE; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
831 } |
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
|
832 |
3279
fd207dce9f94
I think this fixes the texture pixel alignment
Sam Lantinga <slouken@libsdl.org>
parents:
3267
diff
changeset
|
833 minx = (float) dstrect->x - 0.5f; |
fd207dce9f94
I think this fixes the texture pixel alignment
Sam Lantinga <slouken@libsdl.org>
parents:
3267
diff
changeset
|
834 miny = (float) dstrect->y - 0.5f; |
fd207dce9f94
I think this fixes the texture pixel alignment
Sam Lantinga <slouken@libsdl.org>
parents:
3267
diff
changeset
|
835 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
|
836 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
|
837 |
1904
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
838 minu = (float) srcrect->x / texture->w; |
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
839 maxu = (float) (srcrect->x + srcrect->w) / texture->w; |
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
840 minv = (float) srcrect->y / texture->h; |
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
841 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
|
842 |
1987
36a08379b3f2
Implemented color modulation in the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
843 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
|
844 |
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
|
845 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
|
846 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
|
847 vertices[0].z = 0.0f; |
1904
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
848 vertices[0].rhw = 1.0f; |
1987
36a08379b3f2
Implemented color modulation in the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
849 vertices[0].color = color; |
1904
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
850 vertices[0].u = minu; |
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
851 vertices[0].v = minv; |
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
852 |
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
|
853 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
|
854 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
|
855 vertices[1].z = 0.0f; |
1904
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
856 vertices[1].rhw = 1.0f; |
1987
36a08379b3f2
Implemented color modulation in the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
857 vertices[1].color = color; |
1904
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
858 vertices[1].u = maxu; |
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
859 vertices[1].v = minv; |
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
860 |
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
|
861 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
|
862 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
|
863 vertices[2].z = 0.0f; |
1904
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
864 vertices[2].rhw = 1.0f; |
1987
36a08379b3f2
Implemented color modulation in the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
865 vertices[2].color = color; |
1904
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
866 vertices[2].u = maxu; |
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
867 vertices[2].v = maxv; |
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
868 |
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
|
869 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
|
870 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
|
871 vertices[3].z = 0.0f; |
1904
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
872 vertices[3].rhw = 1.0f; |
1987
36a08379b3f2
Implemented color modulation in the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
873 vertices[3].color = color; |
1904
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
874 vertices[3].u = minu; |
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
875 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
|
876 |
2932
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
877 D3D_SetBlendMode(data, texture->blendMode); |
1916
c773b0c0ac89
Implemented blend modes in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1913
diff
changeset
|
878 |
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
|
879 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
|
880 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
|
881 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
|
882 D3DTEXF_LINEAR); |
1917
3f54b3ec5a07
Implemented scaling in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1916
diff
changeset
|
883 |
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
|
884 result = |
2735
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2222
diff
changeset
|
885 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
|
886 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
|
887 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
|
888 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
|
889 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
|
890 } |
3556
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
891 if (shader) { |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
892 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
|
893 if (FAILED(result)) { |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
894 D3D_SetError("SetShader()", result); |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
895 return -1; |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
896 } |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
897 } |
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
|
898 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
|
899 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
|
900 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
|
901 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
|
902 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
|
903 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
|
904 } |
3556
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
905 if (shader) { |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
906 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
|
907 if (FAILED(result)) { |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
908 D3D_SetError("SetShader()", result); |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
909 return -1; |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
910 } |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
911 } |
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
|
912 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
|
913 } |
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
|
914 |
3427
36cf454ba065
Work in progress on implementation of SDL_RenderReadPixels() and SDL_RenderWritePixels(), code untested.
Sam Lantinga <slouken@libsdl.org>
parents:
3279
diff
changeset
|
915 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
|
916 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
|
917 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
|
918 { |
3549
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
919 D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
920 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
|
921 LPDIRECT3DSURFACE9 backBuffer; |
3549
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
922 LPDIRECT3DSURFACE9 surface; |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
923 RECT d3drect; |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
924 D3DLOCKED_RECT locked; |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
925 HRESULT result; |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
926 |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
927 result = IDirect3DDevice9_GetBackBuffer(data->device, 0, 0, D3DBACKBUFFER_TYPE_MONO, &backBuffer); |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
928 if (FAILED(result)) { |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
929 D3D_SetError("GetBackBuffer()", result); |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
930 return -1; |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
931 } |
3427
36cf454ba065
Work in progress on implementation of SDL_RenderReadPixels() and SDL_RenderWritePixels(), code untested.
Sam Lantinga <slouken@libsdl.org>
parents:
3279
diff
changeset
|
932 |
3549
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
933 result = IDirect3DSurface9_GetDesc(backBuffer, &desc); |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
934 if (FAILED(result)) { |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
935 D3D_SetError("GetDesc()", result); |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
936 IDirect3DSurface9_Release(backBuffer); |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
937 return -1; |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
938 } |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
939 |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
940 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
|
941 if (FAILED(result)) { |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
942 D3D_SetError("CreateOffscreenPlainSurface()", result); |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
943 IDirect3DSurface9_Release(backBuffer); |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
944 return -1; |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
945 } |
3427
36cf454ba065
Work in progress on implementation of SDL_RenderReadPixels() and SDL_RenderWritePixels(), code untested.
Sam Lantinga <slouken@libsdl.org>
parents:
3279
diff
changeset
|
946 |
3549
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
947 result = IDirect3DDevice9_GetRenderTargetData(data->device, backBuffer, surface); |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
948 if (FAILED(result)) { |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
949 D3D_SetError("GetRenderTargetData()", result); |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
950 IDirect3DSurface9_Release(surface); |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
951 IDirect3DSurface9_Release(backBuffer); |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
952 return -1; |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
953 } |
3427
36cf454ba065
Work in progress on implementation of SDL_RenderReadPixels() and SDL_RenderWritePixels(), code untested.
Sam Lantinga <slouken@libsdl.org>
parents:
3279
diff
changeset
|
954 |
3549
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
955 d3drect.left = rect->x; |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
956 d3drect.right = rect->x + rect->w; |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
957 d3drect.top = rect->y; |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
958 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
|
959 |
3549
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
960 result = IDirect3DSurface9_LockRect(surface, &locked, &d3drect, D3DLOCK_READONLY); |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
961 if (FAILED(result)) { |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
962 D3D_SetError("LockRect()", result); |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
963 IDirect3DSurface9_Release(surface); |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
964 IDirect3DSurface9_Release(backBuffer); |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
965 return -1; |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
966 } |
3427
36cf454ba065
Work in progress on implementation of SDL_RenderReadPixels() and SDL_RenderWritePixels(), code untested.
Sam Lantinga <slouken@libsdl.org>
parents:
3279
diff
changeset
|
967 |
3549
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
968 SDL_ConvertPixels(rect->w, rect->h, |
5159
307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5157
diff
changeset
|
969 D3DFMTToPixelFormat(desc.Format), locked.pBits, locked.Pitch, |
3549
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
970 format, pixels, pitch); |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
971 |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
972 IDirect3DSurface9_UnlockRect(surface); |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
973 |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
974 IDirect3DSurface9_Release(surface); |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
975 IDirect3DSurface9_Release(backBuffer); |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
976 |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
977 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
|
978 } |
36cf454ba065
Work in progress on implementation of SDL_RenderReadPixels() and SDL_RenderWritePixels(), code untested.
Sam Lantinga <slouken@libsdl.org>
parents:
3279
diff
changeset
|
979 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
980 static void |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
981 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
|
982 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
983 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
|
984 HRESULT result; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
985 |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
986 if (!data->beginScene) { |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
987 IDirect3DDevice9_EndScene(data->device); |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
988 data->beginScene = SDL_TRUE; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
989 } |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
990 |
1975
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
991 result = IDirect3DDevice9_TestCooperativeLevel(data->device); |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
992 if (result == D3DERR_DEVICELOST) { |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
993 /* We'll reset later */ |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
994 return; |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
995 } |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
996 if (result == D3DERR_DEVICENOTRESET) { |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
997 D3D_Reset(renderer); |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
998 } |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
999 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
|
1000 if (FAILED(result)) { |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
1001 D3D_SetError("Present()", result); |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
1002 } |
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
|
1003 } |
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
|
1004 |
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
|
1005 static void |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
1006 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
|
1007 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
1008 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
|
1009 |
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
|
1010 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
|
1011 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
|
1012 } |
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
|
1013 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
|
1014 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
|
1015 } |
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
|
1016 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
|
1017 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
|
1018 } |
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 |
1975
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
1020 static void |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
1021 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
|
1022 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
1023 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
|
1024 |
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
|
1025 if (data) { |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
1026 if (data->device) { |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
1027 IDirect3DDevice9_Release(data->device); |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
1028 } |
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
|
1029 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
|
1030 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
|
1031 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
|
1032 } |
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 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
|
1034 } |
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
|
1035 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
|
1036 } |
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
|
1037 |
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
|
1038 #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
|
1039 |
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
|
1040 /* vi: set ts=4 sw=4 expandtab: */ |