Mercurial > sdl-ios-xcode
annotate src/video/windows/SDL_d3drender.c @ 5141:da10636e5eca
Making the API simpler, scaling is always defined as linear interpolation and should be supported as much as possible on all renderers.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 31 Jan 2011 22:44:43 -0800 |
parents | e8916fe9cfc8 |
children | e743b9c3f6d6 |
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 |
5062 | 26 #include "SDL_windowsvideo.h" |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
27 #include "../SDL_yuv_sw_c.h" |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
28 |
3556
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
29 #ifdef ASSEMBLE_SHADER |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
30 /////////////////////////////////////////////////////////////////////////// |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
31 // ID3DXBuffer: |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
32 // ------------ |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
33 // 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
|
34 // |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
35 // GetBufferPointer - |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
36 // 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
|
37 // |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
38 // GetBufferSize - |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
39 // 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
|
40 /////////////////////////////////////////////////////////////////////////// |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
41 |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
42 typedef interface ID3DXBuffer ID3DXBuffer; |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
43 typedef interface ID3DXBuffer *LPD3DXBUFFER; |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
44 |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
45 // {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
|
46 DEFINE_GUID(IID_ID3DXBuffer, |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
47 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
|
48 |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
49 #undef INTERFACE |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
50 #define INTERFACE ID3DXBuffer |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
51 |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
52 typedef interface ID3DXBuffer { |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
53 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
|
54 } ID3DXBuffer; |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
55 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
|
56 const struct ID3DXBufferVtbl |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
57 { |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
58 // IUnknown |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
59 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
|
60 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
|
61 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
|
62 |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
63 // ID3DXBuffer |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
64 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
|
65 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
|
66 }; |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
67 |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
68 HRESULT WINAPI |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
69 D3DXAssembleShader( |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
70 LPCSTR pSrcData, |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
71 UINT SrcDataLen, |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
72 CONST LPVOID* pDefines, |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
73 LPVOID pInclude, |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
74 DWORD Flags, |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
75 LPD3DXBUFFER* ppShader, |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
76 LPD3DXBUFFER* ppErrorMsgs); |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
77 |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
78 #endif /* ASSEMBLE_SHADER */ |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
79 |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
80 |
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
|
81 /* 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
|
82 |
2786 | 83 #if 1 /* This takes more memory but you won't lose your texture data */ |
2932
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
84 #define D3DPOOL_SDL D3DPOOL_MANAGED |
2783
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
85 #define SDL_MEMORY_POOL_MANAGED |
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
86 #else |
2932
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
87 #define D3DPOOL_SDL D3DPOOL_DEFAULT |
2783
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
88 #define SDL_MEMORY_POOL_DEFAULT |
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
89 #endif |
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
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); |
1975
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
92 static int D3D_DisplayModeChanged(SDL_Renderer * renderer); |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
93 static int D3D_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture); |
2990 | 94 static int D3D_QueryTexturePixels(SDL_Renderer * renderer, |
95 SDL_Texture * texture, void **pixels, | |
96 int *pitch); | |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
97 static int D3D_SetTexturePalette(SDL_Renderer * renderer, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
98 SDL_Texture * texture, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
99 const SDL_Color * colors, int firstcolor, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
100 int ncolors); |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
101 static int D3D_GetTexturePalette(SDL_Renderer * renderer, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
102 SDL_Texture * texture, SDL_Color * colors, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
103 int firstcolor, int ncolors); |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
104 static int D3D_SetTextureColorMod(SDL_Renderer * renderer, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
105 SDL_Texture * texture); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
106 static int D3D_SetTextureAlphaMod(SDL_Renderer * renderer, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
107 SDL_Texture * texture); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
108 static int D3D_SetTextureBlendMode(SDL_Renderer * renderer, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
109 SDL_Texture * texture); |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
110 static int D3D_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
111 const SDL_Rect * rect, const void *pixels, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
112 int pitch); |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
113 static int D3D_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
114 const SDL_Rect * rect, int markDirty, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
115 void **pixels, int *pitch); |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
116 static void D3D_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture); |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
117 static void D3D_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
118 int numrects, const SDL_Rect * rects); |
3599
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
119 static int D3D_RenderDrawPoints(SDL_Renderer * renderer, |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
120 const SDL_Point * points, int count); |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
121 static int D3D_RenderDrawLines(SDL_Renderer * renderer, |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
122 const SDL_Point * points, int count); |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
123 static int D3D_RenderDrawRects(SDL_Renderer * renderer, |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
124 const SDL_Rect ** rects, int count); |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
125 static int D3D_RenderFillRects(SDL_Renderer * renderer, |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
126 const SDL_Rect ** rects, int count); |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
127 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
|
128 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
|
129 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
|
130 Uint32 format, void * pixels, int pitch); |
cd763d104465
The Direct3D Read/Write pixels interface is in progress.
Sam Lantinga <slouken@libsdl.org>
parents:
3427
diff
changeset
|
131 static int D3D_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect, |
cd763d104465
The Direct3D Read/Write pixels interface is in progress.
Sam Lantinga <slouken@libsdl.org>
parents:
3427
diff
changeset
|
132 Uint32 format, const void * pixels, int pitch); |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
133 static void D3D_RenderPresent(SDL_Renderer * renderer); |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
134 static void D3D_DestroyTexture(SDL_Renderer * renderer, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
135 SDL_Texture * texture); |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
136 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
|
137 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
138 |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
139 SDL_RenderDriver D3D_RenderDriver = { |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
140 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
|
141 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
142 "d3d", |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
143 (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY | |
1975
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
144 SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 | |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
145 SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_PRESENTVSYNC | |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
146 SDL_RENDERER_ACCELERATED), |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
147 (SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_COLOR | |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
148 SDL_TEXTUREMODULATE_ALPHA), |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
149 (SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK | |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
150 SDL_BLENDMODE_BLEND | SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD), |
2972
0a4b70368372
Query available formats before advertising them.
Sam Lantinga <slouken@libsdl.org>
parents:
2933
diff
changeset
|
151 0, |
0a4b70368372
Query available formats before advertising them.
Sam Lantinga <slouken@libsdl.org>
parents:
2933
diff
changeset
|
152 {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
|
153 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
|
154 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
|
155 }; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
156 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
157 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
|
158 { |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
159 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
|
160 IDirect3DDevice9 *device; |
3527
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
161 UINT adapter; |
1975
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
162 D3DPRESENT_PARAMETERS pparams; |
3556
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
163 LPDIRECT3DPIXELSHADER9 ps_mask; |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
164 SDL_bool beginScene; |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
165 } 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
|
166 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
167 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
|
168 { |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
169 SDL_SW_YUVTexture *yuv; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
170 Uint32 format; |
1903
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
171 IDirect3DTexture9 *texture; |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
172 } 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
|
173 |
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
|
174 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
|
175 { |
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
|
176 float x, y, z; |
1904
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
177 float rhw; |
1987
36a08379b3f2
Implemented color modulation in the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
178 DWORD color; |
1904
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
179 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
|
180 } 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
|
181 |
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
|
182 static void |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
183 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
|
184 { |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
185 const char *error; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
186 |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
187 switch (result) { |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
188 case D3DERR_WRONGTEXTUREFORMAT: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
189 error = "WRONGTEXTUREFORMAT"; |
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_UNSUPPORTEDCOLOROPERATION: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
192 error = "UNSUPPORTEDCOLOROPERATION"; |
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_UNSUPPORTEDCOLORARG: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
195 error = "UNSUPPORTEDCOLORARG"; |
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_UNSUPPORTEDALPHAOPERATION: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
198 error = "UNSUPPORTEDALPHAOPERATION"; |
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_UNSUPPORTEDALPHAARG: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
201 error = "UNSUPPORTEDALPHAARG"; |
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_TOOMANYOPERATIONS: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
204 error = "TOOMANYOPERATIONS"; |
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_CONFLICTINGTEXTUREFILTER: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
207 error = "CONFLICTINGTEXTUREFILTER"; |
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_UNSUPPORTEDFACTORVALUE: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
210 error = "UNSUPPORTEDFACTORVALUE"; |
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_CONFLICTINGRENDERSTATE: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
213 error = "CONFLICTINGRENDERSTATE"; |
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_UNSUPPORTEDTEXTUREFILTER: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
216 error = "UNSUPPORTEDTEXTUREFILTER"; |
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_CONFLICTINGTEXTUREPALETTE: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
219 error = "CONFLICTINGTEXTUREPALETTE"; |
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 case D3DERR_DRIVERINTERNALERROR: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
222 error = "DRIVERINTERNALERROR"; |
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 case D3DERR_NOTFOUND: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
225 error = "NOTFOUND"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
226 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
227 case D3DERR_MOREDATA: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
228 error = "MOREDATA"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
229 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
230 case D3DERR_DEVICELOST: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
231 error = "DEVICELOST"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
232 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
233 case D3DERR_DEVICENOTRESET: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
234 error = "DEVICENOTRESET"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
235 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
236 case D3DERR_NOTAVAILABLE: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
237 error = "NOTAVAILABLE"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
238 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
239 case D3DERR_OUTOFVIDEOMEMORY: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
240 error = "OUTOFVIDEOMEMORY"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
241 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
242 case D3DERR_INVALIDDEVICE: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
243 error = "INVALIDDEVICE"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
244 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
245 case D3DERR_INVALIDCALL: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
246 error = "INVALIDCALL"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
247 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
248 case D3DERR_DRIVERINVALIDCALL: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
249 error = "DRIVERINVALIDCALL"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
250 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
251 case D3DERR_WASSTILLDRAWING: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
252 error = "WASSTILLDRAWING"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
253 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
254 default: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
255 error = "UNKNOWN"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
256 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
257 } |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
258 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
|
259 } |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
260 |
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
|
261 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
|
262 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
|
263 { |
1903
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
264 switch (format) { |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
265 case SDL_PIXELFORMAT_INDEX8: |
1903
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
266 return D3DFMT_P8; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
267 case SDL_PIXELFORMAT_RGB332: |
1903
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
268 return D3DFMT_R3G3B2; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
269 case SDL_PIXELFORMAT_RGB444: |
1903
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
270 return D3DFMT_X4R4G4B4; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
271 case SDL_PIXELFORMAT_RGB555: |
1903
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
272 return D3DFMT_X1R5G5B5; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
273 case SDL_PIXELFORMAT_ARGB4444: |
1903
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
274 return D3DFMT_A4R4G4B4; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
275 case SDL_PIXELFORMAT_ARGB1555: |
1903
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
276 return D3DFMT_A1R5G5B5; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
277 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
|
278 return D3DFMT_R5G6B5; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
279 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
|
280 return D3DFMT_X8R8G8B8; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
281 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
|
282 return D3DFMT_A8R8G8B8; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
283 case SDL_PIXELFORMAT_ARGB2101010: |
1903
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
284 return D3DFMT_A2R10G10B10; |
3495 | 285 case SDL_PIXELFORMAT_YV12: |
286 return MAKEFOURCC('Y','V','1','2'); | |
287 case SDL_PIXELFORMAT_IYUV: | |
288 return MAKEFOURCC('I','4','2','0'); | |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
289 case SDL_PIXELFORMAT_UYVY: |
1903
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
290 return D3DFMT_UYVY; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
291 case SDL_PIXELFORMAT_YUY2: |
1903
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
292 return D3DFMT_YUY2; |
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
293 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
|
294 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
|
295 } |
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
|
296 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
297 |
3527
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
298 static UINT D3D_FindAdapter(IDirect3D9 * d3d, SDL_VideoDisplay * display) |
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
299 { |
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
300 SDL_DisplayData *displaydata = (SDL_DisplayData *) display->driverdata; |
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
301 UINT adapter, count; |
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
302 |
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
303 count = IDirect3D9_GetAdapterCount(d3d); |
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
304 for (adapter = 0; adapter < count; ++adapter) { |
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
305 HRESULT result; |
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
306 D3DADAPTER_IDENTIFIER9 info; |
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
307 char *name; |
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
308 |
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
309 result = IDirect3D9_GetAdapterIdentifier(d3d, adapter, 0, &info); |
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
310 if (FAILED(result)) { |
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
311 continue; |
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
312 } |
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
313 name = WIN_StringToUTF8(displaydata->DeviceName); |
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
314 if (SDL_strcmp(name, info.DeviceName) == 0) { |
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
315 SDL_free(name); |
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
316 return adapter; |
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
317 } |
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
318 SDL_free(name); |
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
319 } |
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
320 |
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
321 /* This should never happen, but just in case... */ |
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
322 return D3DADAPTER_DEFAULT; |
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
323 } |
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
324 |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
325 static SDL_bool |
3527
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
326 D3D_IsTextureFormatAvailable(IDirect3D9 * d3d, UINT adapter, |
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
327 Uint32 display_format, |
2990 | 328 Uint32 texture_format) |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
329 { |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
330 HRESULT result; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
331 |
3527
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
332 result = IDirect3D9_CheckDeviceFormat(d3d, adapter, |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
333 D3DDEVTYPE_HAL, |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
334 PixelFormatToD3DFMT(display_format), |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
335 0, |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
336 D3DRTYPE_TEXTURE, |
2990 | 337 PixelFormatToD3DFMT |
338 (texture_format)); | |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
339 return FAILED(result) ? SDL_FALSE : SDL_TRUE; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
340 } |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
341 |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
342 static void |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
343 UpdateYUVTextureData(SDL_Texture * texture) |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
344 { |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
345 D3D_TextureData *data = (D3D_TextureData *) texture->driverdata; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
346 SDL_Rect rect; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
347 RECT d3drect; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
348 D3DLOCKED_RECT locked; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
349 HRESULT result; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
350 |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
351 d3drect.left = 0; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
352 d3drect.right = texture->w; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
353 d3drect.top = 0; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
354 d3drect.bottom = texture->h; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
355 |
2990 | 356 result = |
357 IDirect3DTexture9_LockRect(data->texture, 0, &locked, &d3drect, 0); | |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
358 if (FAILED(result)) { |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
359 return; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
360 } |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
361 |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
362 rect.x = 0; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
363 rect.y = 0; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
364 rect.w = texture->w; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
365 rect.h = texture->h; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
366 SDL_SW_CopyYUVToRGB(data->yuv, &rect, data->format, texture->w, |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
367 texture->h, locked.pBits, locked.Pitch); |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
368 |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
369 IDirect3DTexture9_UnlockRect(data->texture, 0); |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
370 } |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
371 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
372 void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
373 D3D_AddRenderDriver(_THIS) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
374 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
375 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; |
2972
0a4b70368372
Query available formats before advertising them.
Sam Lantinga <slouken@libsdl.org>
parents:
2933
diff
changeset
|
376 SDL_RendererInfo *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
|
377 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
378 if (data->d3d) { |
3527
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
379 int i, j; |
2972
0a4b70368372
Query available formats before advertising them.
Sam Lantinga <slouken@libsdl.org>
parents:
2933
diff
changeset
|
380 int formats[] = { |
2990 | 381 SDL_PIXELFORMAT_INDEX8, |
382 SDL_PIXELFORMAT_RGB332, | |
383 SDL_PIXELFORMAT_RGB444, | |
384 SDL_PIXELFORMAT_RGB555, | |
385 SDL_PIXELFORMAT_ARGB4444, | |
386 SDL_PIXELFORMAT_ARGB1555, | |
387 SDL_PIXELFORMAT_RGB565, | |
388 SDL_PIXELFORMAT_RGB888, | |
389 SDL_PIXELFORMAT_ARGB8888, | |
390 SDL_PIXELFORMAT_ARGB2101010, | |
2972
0a4b70368372
Query available formats before advertising them.
Sam Lantinga <slouken@libsdl.org>
parents:
2933
diff
changeset
|
391 }; |
0a4b70368372
Query available formats before advertising them.
Sam Lantinga <slouken@libsdl.org>
parents:
2933
diff
changeset
|
392 |
3527
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
393 for (i = 0; i < _this->num_displays; ++i) { |
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
394 SDL_VideoDisplay *display = &_this->displays[i]; |
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
395 SDL_DisplayMode *mode = &display->desktop_mode; |
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
396 UINT adapter = D3D_FindAdapter(data->d3d, display); |
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
397 |
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
398 /* Get the matching D3D adapter for this display */ |
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
399 info->num_texture_formats = 0; |
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
400 for (j = 0; j < SDL_arraysize(formats); ++j) { |
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
401 if (D3D_IsTextureFormatAvailable |
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
402 (data->d3d, adapter, mode->format, formats[j])) { |
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
403 info->texture_formats[info->num_texture_formats++] = |
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
404 formats[j]; |
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
405 } |
2972
0a4b70368372
Query available formats before advertising them.
Sam Lantinga <slouken@libsdl.org>
parents:
2933
diff
changeset
|
406 } |
3527
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
407 info->texture_formats[info->num_texture_formats++] = |
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
408 SDL_PIXELFORMAT_YV12; |
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
409 info->texture_formats[info->num_texture_formats++] = |
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
410 SDL_PIXELFORMAT_IYUV; |
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
411 info->texture_formats[info->num_texture_formats++] = |
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
412 SDL_PIXELFORMAT_YUY2; |
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
413 info->texture_formats[info->num_texture_formats++] = |
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
414 SDL_PIXELFORMAT_UYVY; |
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
415 info->texture_formats[info->num_texture_formats++] = |
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
416 SDL_PIXELFORMAT_YVYU; |
2972
0a4b70368372
Query available formats before advertising them.
Sam Lantinga <slouken@libsdl.org>
parents:
2933
diff
changeset
|
417 |
3527
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
418 SDL_AddRenderDriver(display, &D3D_RenderDriver); |
3520
83518f8fcd61
Fixed calls to SDL_AddRenderDriver()
Sam Lantinga <slouken@libsdl.org>
parents:
3519
diff
changeset
|
419 } |
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
|
420 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
421 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
422 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
423 SDL_Renderer * |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
424 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
|
425 { |
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
|
426 SDL_VideoDisplay *display = window->display; |
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
|
427 SDL_VideoData *videodata = (SDL_VideoData *) display->device->driverdata; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
428 SDL_WindowData *windowdata = (SDL_WindowData *) window->driverdata; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
429 SDL_Renderer *renderer; |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
430 D3D_RenderData *data; |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
431 HRESULT result; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
432 D3DPRESENT_PARAMETERS pparams; |
1907
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
433 IDirect3DSwapChain9 *chain; |
1925
411bfb37082b
Query the maximum texture size for the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
434 D3DCAPS9 caps; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
435 |
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
|
436 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
|
437 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
|
438 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
|
439 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
|
440 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
441 |
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
|
442 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
|
443 if (!data) { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
444 D3D_DestroyRenderer(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
|
445 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
|
446 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
|
447 } |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
448 data->d3d = videodata->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
|
449 |
4569 | 450 videodata->render = RENDER_D3D; |
451 | |
1975
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
452 renderer->DisplayModeChanged = D3D_DisplayModeChanged; |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
453 renderer->CreateTexture = D3D_CreateTexture; |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
454 renderer->QueryTexturePixels = D3D_QueryTexturePixels; |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
455 renderer->SetTexturePalette = D3D_SetTexturePalette; |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
456 renderer->GetTexturePalette = D3D_GetTexturePalette; |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
457 renderer->SetTextureColorMod = D3D_SetTextureColorMod; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
458 renderer->SetTextureAlphaMod = D3D_SetTextureAlphaMod; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
459 renderer->SetTextureBlendMode = D3D_SetTextureBlendMode; |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
460 renderer->UpdateTexture = D3D_UpdateTexture; |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
461 renderer->LockTexture = D3D_LockTexture; |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
462 renderer->UnlockTexture = D3D_UnlockTexture; |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
463 renderer->DirtyTexture = D3D_DirtyTexture; |
3599
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
464 renderer->RenderDrawPoints = D3D_RenderDrawPoints; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
465 renderer->RenderDrawLines = D3D_RenderDrawLines; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
466 renderer->RenderDrawRects = D3D_RenderDrawRects; |
3675 | 467 renderer->RenderFillRects = D3D_RenderFillRects; |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
468 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
|
469 renderer->RenderReadPixels = D3D_RenderReadPixels; |
3480
cd763d104465
The Direct3D Read/Write pixels interface is in progress.
Sam Lantinga <slouken@libsdl.org>
parents:
3427
diff
changeset
|
470 renderer->RenderWritePixels = D3D_RenderWritePixels; |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
471 renderer->RenderPresent = D3D_RenderPresent; |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
472 renderer->DestroyTexture = D3D_DestroyTexture; |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
473 renderer->DestroyRenderer = D3D_DestroyRenderer; |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
474 renderer->info = D3D_RenderDriver.info; |
3685
64ce267332c6
Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents:
3675
diff
changeset
|
475 renderer->window = window; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
476 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
|
477 |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
478 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
|
479 |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
480 SDL_zero(pparams); |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
481 pparams.BackBufferWidth = window->w; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
482 pparams.BackBufferHeight = window->h; |
1903
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
483 if (window->flags & SDL_WINDOW_FULLSCREEN) { |
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
484 pparams.BackBufferFormat = |
3519
1374f9275de9
Fixed compiling the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3495
diff
changeset
|
485 PixelFormatToD3DFMT(window->fullscreen_mode.format); |
1903
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
486 } 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
|
487 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
|
488 } |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
489 if (flags & SDL_RENDERER_PRESENTFLIP2) { |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
490 pparams.BackBufferCount = 2; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
491 pparams.SwapEffect = D3DSWAPEFFECT_FLIP; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
492 } else if (flags & SDL_RENDERER_PRESENTFLIP3) { |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
493 pparams.BackBufferCount = 3; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
494 pparams.SwapEffect = D3DSWAPEFFECT_FLIP; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
495 } else if (flags & SDL_RENDERER_PRESENTCOPY) { |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
496 pparams.BackBufferCount = 1; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
497 pparams.SwapEffect = D3DSWAPEFFECT_COPY; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
498 } else { |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
499 pparams.BackBufferCount = 1; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
500 pparams.SwapEffect = D3DSWAPEFFECT_DISCARD; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
501 } |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
502 if (window->flags & SDL_WINDOW_FULLSCREEN) { |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
503 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
|
504 pparams.FullScreen_RefreshRateInHz = |
3519
1374f9275de9
Fixed compiling the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3495
diff
changeset
|
505 window->fullscreen_mode.refresh_rate; |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
506 } else { |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
507 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
|
508 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
|
509 } |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
510 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
|
511 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
|
512 } else { |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
513 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
|
514 } |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
515 |
3527
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
516 data->adapter = D3D_FindAdapter(videodata->d3d, display); |
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
517 IDirect3D9_GetDeviceCaps(videodata->d3d, data->adapter, |
3197 | 518 D3DDEVTYPE_HAL, &caps); |
519 | |
3527
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
520 result = IDirect3D9_CreateDevice(videodata->d3d, data->adapter, |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
521 D3DDEVTYPE_HAL, |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
522 windowdata->hwnd, |
3197 | 523 (caps. |
524 DevCaps & | |
525 D3DDEVCAPS_HWTRANSFORMANDLIGHT) ? | |
526 D3DCREATE_HARDWARE_VERTEXPROCESSING : | |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
527 D3DCREATE_SOFTWARE_VERTEXPROCESSING, |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
528 &pparams, &data->device); |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
529 if (FAILED(result)) { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
530 D3D_DestroyRenderer(renderer); |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
531 D3D_SetError("CreateDevice()", result); |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
532 return NULL; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
533 } |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
534 data->beginScene = SDL_TRUE; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
535 |
1907
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
536 /* 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
|
537 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
|
538 if (FAILED(result)) { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
539 D3D_DestroyRenderer(renderer); |
1907
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
540 D3D_SetError("GetSwapChain()", result); |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
541 return NULL; |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
542 } |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
543 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
|
544 if (FAILED(result)) { |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
545 IDirect3DSwapChain9_Release(chain); |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
546 D3D_DestroyRenderer(renderer); |
1907
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
547 D3D_SetError("GetPresentParameters()", result); |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
548 return NULL; |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
549 } |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
550 IDirect3DSwapChain9_Release(chain); |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
551 switch (pparams.SwapEffect) { |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
552 case D3DSWAPEFFECT_COPY: |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
553 renderer->info.flags |= SDL_RENDERER_PRESENTCOPY; |
1907
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
554 break; |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
555 case D3DSWAPEFFECT_FLIP: |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
556 switch (pparams.BackBufferCount) { |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
557 case 2: |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
558 renderer->info.flags |= SDL_RENDERER_PRESENTFLIP2; |
1907
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
559 break; |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
560 case 3: |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
561 renderer->info.flags |= SDL_RENDERER_PRESENTFLIP3; |
1907
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
562 break; |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
563 } |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
564 break; |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
565 case D3DSWAPEFFECT_DISCARD: |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
566 renderer->info.flags |= SDL_RENDERER_PRESENTDISCARD; |
1907
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
567 break; |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
568 } |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
569 if (pparams.PresentationInterval == D3DPRESENT_INTERVAL_ONE) { |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
570 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
|
571 } |
1975
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
572 data->pparams = pparams; |
1907
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
573 |
1925
411bfb37082b
Query the maximum texture size for the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
574 IDirect3DDevice9_GetDeviceCaps(data->device, &caps); |
411bfb37082b
Query the maximum texture size for the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
575 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
|
576 renderer->info.max_texture_height = caps.MaxTextureHeight; |
1918
092bd3a019c5
Starting on the OpenGL renderer...
Sam Lantinga <slouken@libsdl.org>
parents:
1917
diff
changeset
|
577 |
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
|
578 /* Set up parameters for rendering */ |
1904
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
579 IDirect3DDevice9_SetVertexShader(data->device, NULL); |
1987
36a08379b3f2
Implemented color modulation in the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
580 IDirect3DDevice9_SetFVF(data->device, |
36a08379b3f2
Implemented color modulation in the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
581 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
|
582 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
|
583 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
|
584 D3DCULL_NONE); |
1904
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
585 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
|
586 /* 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
|
587 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
|
588 D3DTOP_MODULATE); |
1ee02169bbb0
Figured out how texture stages work, thanks to this:
Sam Lantinga <slouken@libsdl.org>
parents:
1987
diff
changeset
|
589 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
|
590 D3DTA_TEXTURE); |
1ee02169bbb0
Figured out how texture stages work, thanks to this:
Sam Lantinga <slouken@libsdl.org>
parents:
1987
diff
changeset
|
591 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
|
592 D3DTA_DIFFUSE); |
1ee02169bbb0
Figured out how texture stages work, thanks to this:
Sam Lantinga <slouken@libsdl.org>
parents:
1987
diff
changeset
|
593 /* 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
|
594 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
|
595 D3DTOP_MODULATE); |
1ee02169bbb0
Figured out how texture stages work, thanks to this:
Sam Lantinga <slouken@libsdl.org>
parents:
1987
diff
changeset
|
596 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
|
597 D3DTA_TEXTURE); |
1ee02169bbb0
Figured out how texture stages work, thanks to this:
Sam Lantinga <slouken@libsdl.org>
parents:
1987
diff
changeset
|
598 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
|
599 D3DTA_DIFFUSE); |
1991
3863ba81c1d6
Clear the second texture stage explicitly
Sam Lantinga <slouken@libsdl.org>
parents:
1988
diff
changeset
|
600 /* Disable second texture stage, since we're done */ |
3863ba81c1d6
Clear the second texture stage explicitly
Sam Lantinga <slouken@libsdl.org>
parents:
1988
diff
changeset
|
601 IDirect3DDevice9_SetTextureStageState(data->device, 1, D3DTSS_COLOROP, |
3863ba81c1d6
Clear the second texture stage explicitly
Sam Lantinga <slouken@libsdl.org>
parents:
1988
diff
changeset
|
602 D3DTOP_DISABLE); |
3863ba81c1d6
Clear the second texture stage explicitly
Sam Lantinga <slouken@libsdl.org>
parents:
1988
diff
changeset
|
603 IDirect3DDevice9_SetTextureStageState(data->device, 1, D3DTSS_ALPHAOP, |
3863ba81c1d6
Clear the second texture stage explicitly
Sam Lantinga <slouken@libsdl.org>
parents:
1988
diff
changeset
|
604 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
|
605 |
3556
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
606 { |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
607 #ifdef ASSEMBLE_SHADER |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
608 const char *shader_text = |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
609 "ps_1_1\n" |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
610 "def c0, 0, 0, 0, 0.496\n" |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
611 "def c1, 0, 0, 0, 1\n" |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
612 "def c2, 0, 0, 0, -1\n" |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
613 "tex t0\n" |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
614 "mul r1, t0, v0\n" |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
615 "add r0, r1, c0\n" |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
616 "cnd r0, r0.a, c1, c2\n" |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
617 "add r0, r0, r1\n"; |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
618 LPD3DXBUFFER pCode; // buffer with the assembled shader code |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
619 LPD3DXBUFFER pErrorMsgs; // buffer with error messages |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
620 LPDWORD shader_data; |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
621 DWORD shader_size; |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
622 result = D3DXAssembleShader( shader_text, SDL_strlen(shader_text), NULL, NULL, 0, &pCode, &pErrorMsgs ); |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
623 if (FAILED(result)) { |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
624 D3D_SetError("D3DXAssembleShader()", result); |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
625 } |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
626 shader_data = (DWORD*)pCode->lpVtbl->GetBufferPointer(pCode); |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
627 shader_size = pCode->lpVtbl->GetBufferSize(pCode); |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
628 #else |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
629 const DWORD shader_data[] = { |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
630 0xffff0101,0x00000051,0xa00f0000,0x00000000,0x00000000,0x00000000, |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
631 0x3efdf3b6,0x00000051,0xa00f0001,0x00000000,0x00000000,0x00000000, |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
632 0x3f800000,0x00000051,0xa00f0002,0x00000000,0x00000000,0x00000000, |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
633 0xbf800000,0x00000042,0xb00f0000,0x00000005,0x800f0001,0xb0e40000, |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
634 0x90e40000,0x00000002,0x800f0000,0x80e40001,0xa0e40000,0x00000050, |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
635 0x800f0000,0x80ff0000,0xa0e40001,0xa0e40002,0x00000002,0x800f0000, |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
636 0x80e40000,0x80e40001,0x0000ffff |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
637 }; |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
638 #endif |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
639 result = IDirect3DDevice9_CreatePixelShader(data->device, shader_data, &data->ps_mask); |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
640 if (FAILED(result)) { |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
641 D3D_SetError("CreatePixelShader()", result); |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
642 } |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
643 } |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
644 |
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
|
645 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
|
646 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
647 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
648 static int |
1975
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
649 D3D_Reset(SDL_Renderer * renderer) |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
650 { |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
651 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
|
652 HRESULT result; |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
653 |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
654 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
|
655 if (FAILED(result)) { |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
656 if (result == D3DERR_DEVICELOST) { |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
657 /* 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
|
658 return 0; |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
659 } else { |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
660 D3D_SetError("Reset()", result); |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
661 return -1; |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
662 } |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
663 } |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
664 IDirect3DDevice9_SetVertexShader(data->device, NULL); |
1987
36a08379b3f2
Implemented color modulation in the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
665 IDirect3DDevice9_SetFVF(data->device, |
36a08379b3f2
Implemented color modulation in the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
666 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
|
667 IDirect3DDevice9_SetRenderState(data->device, D3DRS_CULLMODE, |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
668 D3DCULL_NONE); |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
669 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
|
670 return 0; |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
671 } |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
672 |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
673 static int |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
674 D3D_DisplayModeChanged(SDL_Renderer * renderer) |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
675 { |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
676 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
|
677 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
|
678 SDL_VideoDisplay *display = window->display; |
1975
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
679 |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
680 data->pparams.BackBufferWidth = window->w; |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
681 data->pparams.BackBufferHeight = window->h; |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
682 if (window->flags & SDL_WINDOW_FULLSCREEN) { |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
683 data->pparams.BackBufferFormat = |
3519
1374f9275de9
Fixed compiling the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents:
3495
diff
changeset
|
684 PixelFormatToD3DFMT(window->fullscreen_mode.format); |
1975
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
685 } else { |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
686 data->pparams.BackBufferFormat = D3DFMT_UNKNOWN; |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
687 } |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
688 return D3D_Reset(renderer); |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
689 } |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
690 |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
691 static int |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
692 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
|
693 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
694 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
|
695 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
|
696 SDL_VideoDisplay *display = window->display; |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
697 Uint32 display_format = display->current_mode.format; |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
698 D3D_TextureData *data; |
1903
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
699 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
|
700 |
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
|
701 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
|
702 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
|
703 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
|
704 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
|
705 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
706 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
707 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
|
708 |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
709 if (SDL_ISPIXELFORMAT_FOURCC(texture->format) && |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
710 (texture->format != SDL_PIXELFORMAT_YUY2 || |
3527
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
711 !D3D_IsTextureFormatAvailable(renderdata->d3d, renderdata->adapter, |
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
712 display_format, texture->format)) |
2990 | 713 && (texture->format != SDL_PIXELFORMAT_YVYU |
3527
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
714 || !D3D_IsTextureFormatAvailable(renderdata->d3d, renderdata->adapter, |
444cb12cadb6
Fixed to use the correct display adapter
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
715 display_format, texture->format))) { |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
716 data->yuv = |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
717 SDL_SW_CreateYUVTexture(texture->format, texture->w, texture->h); |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
718 if (!data->yuv) { |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
719 return -1; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
720 } |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
721 data->format = display->current_mode.format; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
722 } else { |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
723 data->format = texture->format; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
724 } |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
725 |
1903
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
726 result = |
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
727 IDirect3DDevice9_CreateTexture(renderdata->device, texture->w, |
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
|
728 texture->h, 1, 0, |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
729 PixelFormatToD3DFMT(data->format), |
2783
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
730 D3DPOOL_SDL, &data->texture, NULL); |
1903
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
731 if (FAILED(result)) { |
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
732 D3D_SetError("CreateTexture()", result); |
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
733 return -1; |
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
734 } |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
735 |
1903
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
736 return 0; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
737 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
738 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
739 static int |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
740 D3D_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture, |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
741 void **pixels, int *pitch) |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
742 { |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
743 D3D_TextureData *data = (D3D_TextureData *) texture->driverdata; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
744 |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
745 if (data->yuv) { |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
746 return SDL_SW_QueryYUVTexturePixels(data->yuv, pixels, pitch); |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
747 } else { |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
748 /* D3D textures don't have their pixels hanging out */ |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
749 return -1; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
750 } |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
751 } |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
752 |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
753 static int |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
754 D3D_SetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
755 const SDL_Color * colors, int firstcolor, int ncolors) |
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
|
756 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
757 D3D_RenderData *renderdata = (D3D_RenderData *) renderer->driverdata; |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
758 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
|
759 |
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
|
760 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
|
761 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
762 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
763 static int |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
764 D3D_GetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
765 SDL_Color * colors, int firstcolor, int ncolors) |
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
|
766 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
767 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
|
768 |
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
|
769 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
|
770 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
771 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
772 static int |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
773 D3D_SetTextureColorMod(SDL_Renderer * renderer, SDL_Texture * texture) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
774 { |
1987
36a08379b3f2
Implemented color modulation in the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
775 return 0; |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
776 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
777 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
778 static int |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
779 D3D_SetTextureAlphaMod(SDL_Renderer * renderer, SDL_Texture * texture) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
780 { |
1987
36a08379b3f2
Implemented color modulation in the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
781 return 0; |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
782 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
783 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
784 static int |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
785 D3D_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
786 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
787 switch (texture->blendMode) { |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
788 case SDL_BLENDMODE_NONE: |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
789 case SDL_BLENDMODE_MASK: |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
790 case SDL_BLENDMODE_BLEND: |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
791 case SDL_BLENDMODE_ADD: |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
792 case SDL_BLENDMODE_MOD: |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
793 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
794 default: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
795 SDL_Unsupported(); |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
796 texture->blendMode = SDL_BLENDMODE_NONE; |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
797 return -1; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
798 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
799 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
800 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
801 static int |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
802 D3D_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
803 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
|
804 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
805 D3D_TextureData *data = (D3D_TextureData *) texture->driverdata; |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
806 D3D_RenderData *renderdata = (D3D_RenderData *) renderer->driverdata; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
807 |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
808 if (data->yuv) { |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
809 if (SDL_SW_UpdateYUVTexture(data->yuv, rect, pixels, pitch) < 0) { |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
810 return -1; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
811 } |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
812 UpdateYUVTextureData(texture); |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
813 return 0; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
814 } else { |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
815 #ifdef SDL_MEMORY_POOL_DEFAULT |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
816 IDirect3DTexture9 *temp; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
817 RECT d3drect; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
818 D3DLOCKED_RECT locked; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
819 const Uint8 *src; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
820 Uint8 *dst; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
821 int row, length; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
822 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
|
823 |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
824 result = |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
825 IDirect3DDevice9_CreateTexture(renderdata->device, texture->w, |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
826 texture->h, 1, 0, |
3013
8cc00819c8d6
Reverted Bob's indent checkin
Sam Lantinga <slouken@libsdl.org>
parents:
3011
diff
changeset
|
827 PixelFormatToD3DFMT(texture-> |
8cc00819c8d6
Reverted Bob's indent checkin
Sam Lantinga <slouken@libsdl.org>
parents:
3011
diff
changeset
|
828 format), |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
829 D3DPOOL_SYSTEMMEM, &temp, NULL); |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
830 if (FAILED(result)) { |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
831 D3D_SetError("CreateTexture()", result); |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
832 return -1; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
833 } |
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
|
834 |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
835 d3drect.left = rect->x; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
836 d3drect.right = rect->x + rect->w; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
837 d3drect.top = rect->y; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
838 d3drect.bottom = rect->y + rect->h; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
839 |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
840 result = IDirect3DTexture9_LockRect(temp, 0, &locked, &d3drect, 0); |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
841 if (FAILED(result)) { |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
842 IDirect3DTexture9_Release(temp); |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
843 D3D_SetError("LockRect()", result); |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
844 return -1; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
845 } |
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
|
846 |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
847 src = pixels; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
848 dst = locked.pBits; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
849 length = rect->w * SDL_BYTESPERPIXEL(texture->format); |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
850 for (row = 0; row < rect->h; ++row) { |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
851 SDL_memcpy(dst, src, length); |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
852 src += pitch; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
853 dst += locked.Pitch; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
854 } |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
855 IDirect3DTexture9_UnlockRect(temp, 0); |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
856 |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
857 result = |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
858 IDirect3DDevice9_UpdateTexture(renderdata->device, |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
859 (IDirect3DBaseTexture9 *) temp, |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
860 (IDirect3DBaseTexture9 *) |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
861 data->texture); |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
862 IDirect3DTexture9_Release(temp); |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
863 if (FAILED(result)) { |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
864 D3D_SetError("UpdateTexture()", result); |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
865 return -1; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
866 } |
2783
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
867 #else |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
868 RECT d3drect; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
869 D3DLOCKED_RECT locked; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
870 const Uint8 *src; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
871 Uint8 *dst; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
872 int row, length; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
873 HRESULT result; |
2783
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
874 |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
875 d3drect.left = rect->x; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
876 d3drect.right = rect->x + rect->w; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
877 d3drect.top = rect->y; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
878 d3drect.bottom = rect->y + rect->h; |
2783
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
879 |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
880 result = |
2990 | 881 IDirect3DTexture9_LockRect(data->texture, 0, &locked, &d3drect, |
882 0); | |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
883 if (FAILED(result)) { |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
884 D3D_SetError("LockRect()", result); |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
885 return -1; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
886 } |
2783
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
887 |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
888 src = pixels; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
889 dst = locked.pBits; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
890 length = rect->w * SDL_BYTESPERPIXEL(texture->format); |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
891 for (row = 0; row < rect->h; ++row) { |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
892 SDL_memcpy(dst, src, length); |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
893 src += pitch; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
894 dst += locked.Pitch; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
895 } |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
896 IDirect3DTexture9_UnlockRect(data->texture, 0); |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
897 #endif // SDL_MEMORY_POOL_DEFAULT |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
898 |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
899 return 0; |
2783
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
900 } |
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
901 } |
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
|
902 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
903 static int |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
904 D3D_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
905 const SDL_Rect * rect, int markDirty, void **pixels, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
906 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
|
907 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
908 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
|
909 |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
910 if (data->yuv) { |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
911 return SDL_SW_LockYUVTexture(data->yuv, rect, markDirty, pixels, |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
912 pitch); |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
913 } else { |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
914 RECT d3drect; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
915 D3DLOCKED_RECT locked; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
916 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
|
917 |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
918 d3drect.left = rect->x; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
919 d3drect.right = rect->x + rect->w; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
920 d3drect.top = rect->y; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
921 d3drect.bottom = rect->y + rect->h; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
922 |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
923 result = |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
924 IDirect3DTexture9_LockRect(data->texture, 0, &locked, &d3drect, |
2990 | 925 markDirty ? 0 : |
926 D3DLOCK_NO_DIRTY_UPDATE); | |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
927 if (FAILED(result)) { |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
928 D3D_SetError("LockRect()", result); |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
929 return -1; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
930 } |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
931 *pixels = locked.pBits; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
932 *pitch = locked.Pitch; |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
933 return 0; |
1903
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
934 } |
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
|
935 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
936 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
937 static void |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
938 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
|
939 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
940 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
|
941 |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
942 if (data->yuv) { |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
943 SDL_SW_UnlockYUVTexture(data->yuv); |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
944 UpdateYUVTextureData(texture); |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
945 } else { |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
946 IDirect3DTexture9_UnlockRect(data->texture, 0); |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
947 } |
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
|
948 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
949 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
950 static void |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
951 D3D_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture, int numrects, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
952 const SDL_Rect * rects) |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
953 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
954 D3D_TextureData *data = (D3D_TextureData *) texture->driverdata; |
1903
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
955 RECT d3drect; |
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
956 int i; |
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
957 |
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
|
958 for (i = 0; i < numrects; ++i) { |
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
959 const SDL_Rect *rect = &rects[i]; |
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
960 |
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
|
961 d3drect.left = rect->x; |
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
962 d3drect.right = rect->x + rect->w; |
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
963 d3drect.top = rect->y; |
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
964 d3drect.bottom = rect->y + rect->h; |
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
965 |
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
|
966 IDirect3DTexture9_AddDirtyRect(data->texture, &d3drect); |
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
967 } |
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
|
968 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
969 |
2932
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
970 static void |
2933 | 971 D3D_SetBlendMode(D3D_RenderData * data, int blendMode) |
2932
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
972 { |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
973 switch (blendMode) { |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
974 case SDL_BLENDMODE_NONE: |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
975 IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE, |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
976 FALSE); |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
977 break; |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
978 case SDL_BLENDMODE_MASK: |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
979 case SDL_BLENDMODE_BLEND: |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
980 IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE, |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
981 TRUE); |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
982 IDirect3DDevice9_SetRenderState(data->device, D3DRS_SRCBLEND, |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
983 D3DBLEND_SRCALPHA); |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
984 IDirect3DDevice9_SetRenderState(data->device, D3DRS_DESTBLEND, |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
985 D3DBLEND_INVSRCALPHA); |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
986 break; |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
987 case SDL_BLENDMODE_ADD: |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
988 IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE, |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
989 TRUE); |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
990 IDirect3DDevice9_SetRenderState(data->device, D3DRS_SRCBLEND, |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
991 D3DBLEND_SRCALPHA); |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
992 IDirect3DDevice9_SetRenderState(data->device, D3DRS_DESTBLEND, |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
993 D3DBLEND_ONE); |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
994 break; |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
995 case SDL_BLENDMODE_MOD: |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
996 IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE, |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
997 TRUE); |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
998 IDirect3DDevice9_SetRenderState(data->device, D3DRS_SRCBLEND, |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
999 D3DBLEND_ZERO); |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
1000 IDirect3DDevice9_SetRenderState(data->device, D3DRS_DESTBLEND, |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
1001 D3DBLEND_SRCCOLOR); |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
1002 break; |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
1003 } |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
1004 } |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
1005 |
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
|
1006 static int |
3599
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1007 D3D_RenderDrawPoints(SDL_Renderer * renderer, const SDL_Point * points, |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1008 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
|
1009 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
1010 D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; |
2932
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
1011 DWORD color; |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1012 Vertex *vertices; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1013 int i; |
2932
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
1014 HRESULT result; |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
1015 |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
1016 if (data->beginScene) { |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
1017 IDirect3DDevice9_BeginScene(data->device); |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
1018 data->beginScene = SDL_FALSE; |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
1019 } |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
1020 |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1021 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
|
1022 |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1023 result = |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1024 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
|
1025 (IDirect3DBaseTexture9 *) 0); |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1026 if (FAILED(result)) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1027 D3D_SetError("SetTexture()", result); |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1028 return -1; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1029 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1030 |
2932
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
1031 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
|
1032 |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1033 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
|
1034 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
|
1035 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
|
1036 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
|
1037 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
|
1038 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
|
1039 vertices[i].color = color; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1040 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
|
1041 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
|
1042 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1043 result = |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1044 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
|
1045 vertices, sizeof(*vertices)); |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1046 SDL_stack_free(vertices); |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1047 if (FAILED(result)) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1048 D3D_SetError("DrawPrimitiveUP()", result); |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1049 return -1; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1050 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1051 return 0; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1052 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1053 |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1054 static int |
3599
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1055 D3D_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points, |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1056 int count) |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1057 { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1058 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
|
1059 DWORD color; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1060 Vertex *vertices; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1061 int i; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1062 HRESULT result; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1063 |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1064 if (data->beginScene) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1065 IDirect3DDevice9_BeginScene(data->device); |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1066 data->beginScene = SDL_FALSE; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1067 } |
2932
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
1068 |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
1069 D3D_SetBlendMode(data, renderer->blendMode); |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
1070 |
2933 | 1071 result = |
1072 IDirect3DDevice9_SetTexture(data->device, 0, | |
1073 (IDirect3DBaseTexture9 *) 0); | |
2932
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
1074 if (FAILED(result)) { |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
1075 D3D_SetError("SetTexture()", result); |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
1076 return -1; |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
1077 } |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1078 |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1079 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
|
1080 |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1081 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
|
1082 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
|
1083 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
|
1084 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
|
1085 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
|
1086 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
|
1087 vertices[i].color = color; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1088 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
|
1089 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
|
1090 } |
2932
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
1091 result = |
3551
4a39f28cd935
Fixed line drawing for D3D
Sam Lantinga <slouken@libsdl.org>
parents:
3549
diff
changeset
|
1092 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
|
1093 vertices, sizeof(*vertices)); |
3551
4a39f28cd935
Fixed line drawing for D3D
Sam Lantinga <slouken@libsdl.org>
parents:
3549
diff
changeset
|
1094 |
4a39f28cd935
Fixed line drawing for D3D
Sam Lantinga <slouken@libsdl.org>
parents:
3549
diff
changeset
|
1095 /* 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
|
1096 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
|
1097 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
|
1098 vertices[0].x = (float) points[count-1].x; |
4a39f28cd935
Fixed line drawing for D3D
Sam Lantinga <slouken@libsdl.org>
parents:
3549
diff
changeset
|
1099 vertices[0].y = (float) points[count-1].y; |
4a39f28cd935
Fixed line drawing for D3D
Sam Lantinga <slouken@libsdl.org>
parents:
3549
diff
changeset
|
1100 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
|
1101 } |
4a39f28cd935
Fixed line drawing for D3D
Sam Lantinga <slouken@libsdl.org>
parents:
3549
diff
changeset
|
1102 |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1103 SDL_stack_free(vertices); |
2932
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
1104 if (FAILED(result)) { |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
1105 D3D_SetError("DrawPrimitiveUP()", result); |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
1106 return -1; |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
1107 } |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
1108 return 0; |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
1109 } |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
1110 |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
1111 static int |
3599
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1112 D3D_RenderDrawRects(SDL_Renderer * renderer, const SDL_Rect ** rects, |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1113 int count) |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1114 { |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1115 D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1116 DWORD color; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1117 int i; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1118 Vertex vertices[5]; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1119 HRESULT result; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1120 |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1121 if (data->beginScene) { |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1122 IDirect3DDevice9_BeginScene(data->device); |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1123 data->beginScene = SDL_FALSE; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1124 } |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1125 |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1126 D3D_SetBlendMode(data, renderer->blendMode); |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1127 |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1128 result = |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1129 IDirect3DDevice9_SetTexture(data->device, 0, |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1130 (IDirect3DBaseTexture9 *) 0); |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1131 if (FAILED(result)) { |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1132 D3D_SetError("SetTexture()", result); |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1133 return -1; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1134 } |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1135 |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1136 color = D3DCOLOR_ARGB(renderer->a, renderer->r, renderer->g, renderer->b); |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1137 |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1138 for (i = 0; i < SDL_arraysize(vertices); ++i) { |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1139 vertices[i].z = 0.0f; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1140 vertices[i].rhw = 1.0f; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1141 vertices[i].color = color; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1142 vertices[i].u = 0.0f; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1143 vertices[i].v = 0.0f; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1144 } |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1145 |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1146 for (i = 0; i < count; ++i) { |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1147 const SDL_Rect *rect = rects[i]; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1148 |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1149 vertices[0].x = (float) rect->x; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1150 vertices[0].y = (float) rect->y; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1151 |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1152 vertices[1].x = (float) rect->x+rect->w-1; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1153 vertices[1].y = (float) rect->y; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1154 |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1155 vertices[2].x = (float) rect->x+rect->w-1; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1156 vertices[2].y = (float) rect->y+rect->h-1; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1157 |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1158 vertices[3].x = (float) rect->x; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1159 vertices[3].y = (float) rect->y+rect->h-1; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1160 |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1161 vertices[4].x = (float) rect->x; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1162 vertices[4].y = (float) rect->y; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1163 |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1164 result = |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1165 IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_LINESTRIP, 4, |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1166 vertices, sizeof(*vertices)); |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1167 |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1168 if (FAILED(result)) { |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1169 D3D_SetError("DrawPrimitiveUP()", result); |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1170 return -1; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1171 } |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1172 } |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1173 return 0; |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1174 } |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1175 |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1176 static int |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1177 D3D_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects, |
0f958e527e5e
Updated to compile on Windows
Sam Lantinga <slouken@libsdl.org>
parents:
3556
diff
changeset
|
1178 int count) |
2932
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
1179 { |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
1180 D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
1181 DWORD color; |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1182 int i; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1183 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
|
1184 Vertex vertices[4]; |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
1185 HRESULT result; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
1186 |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
1187 if (data->beginScene) { |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
1188 IDirect3DDevice9_BeginScene(data->device); |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
1189 data->beginScene = SDL_FALSE; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
1190 } |
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
|
1191 |
2932
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
1192 D3D_SetBlendMode(data, renderer->blendMode); |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
1193 |
2933 | 1194 result = |
1195 IDirect3DDevice9_SetTexture(data->device, 0, | |
1196 (IDirect3DBaseTexture9 *) 0); | |
2932
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
1197 if (FAILED(result)) { |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
1198 D3D_SetError("SetTexture()", result); |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
1199 return -1; |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
1200 } |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
1201 |
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
1202 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
|
1203 |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1204 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
|
1205 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
|
1206 |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1207 minx = (float) rect->x; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1208 miny = (float) rect->y; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1209 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
|
1210 maxy = (float) rect->y + rect->h; |
2932
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
1211 |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1212 vertices[0].x = minx; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1213 vertices[0].y = miny; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1214 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
|
1215 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
|
1216 vertices[0].color = color; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1217 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
|
1218 vertices[0].v = 0.0f; |
2932
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
1219 |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1220 vertices[1].x = maxx; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1221 vertices[1].y = miny; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1222 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
|
1223 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
|
1224 vertices[1].color = color; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1225 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
|
1226 vertices[1].v = 0.0f; |
2932
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
1227 |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1228 vertices[2].x = maxx; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1229 vertices[2].y = maxy; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1230 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
|
1231 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
|
1232 vertices[2].color = color; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1233 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
|
1234 vertices[2].v = 0.0f; |
2932
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
1235 |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1236 vertices[3].x = minx; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1237 vertices[3].y = maxy; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1238 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
|
1239 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
|
1240 vertices[3].color = color; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1241 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
|
1242 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
|
1243 |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1244 result = |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1245 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
|
1246 2, vertices, sizeof(*vertices)); |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1247 if (FAILED(result)) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1248 D3D_SetError("DrawPrimitiveUP()", result); |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1249 return -1; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3527
diff
changeset
|
1250 } |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
1251 } |
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
|
1252 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
|
1253 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1254 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1255 static int |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
1256 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
|
1257 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
|
1258 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
1259 D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
1260 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
|
1261 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
|
1262 float minx, miny, maxx, maxy; |
1904
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
1263 float minu, maxu, minv, maxv; |
1987
36a08379b3f2
Implemented color modulation in the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1264 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
|
1265 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
|
1266 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
|
1267 |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
1268 if (data->beginScene) { |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
1269 IDirect3DDevice9_BeginScene(data->device); |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
1270 data->beginScene = SDL_FALSE; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
1271 } |
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
|
1272 |
3279
fd207dce9f94
I think this fixes the texture pixel alignment
Sam Lantinga <slouken@libsdl.org>
parents:
3267
diff
changeset
|
1273 minx = (float) dstrect->x - 0.5f; |
fd207dce9f94
I think this fixes the texture pixel alignment
Sam Lantinga <slouken@libsdl.org>
parents:
3267
diff
changeset
|
1274 miny = (float) dstrect->y - 0.5f; |
fd207dce9f94
I think this fixes the texture pixel alignment
Sam Lantinga <slouken@libsdl.org>
parents:
3267
diff
changeset
|
1275 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
|
1276 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
|
1277 |
1904
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
1278 minu = (float) srcrect->x / texture->w; |
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
1279 maxu = (float) (srcrect->x + srcrect->w) / texture->w; |
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
1280 minv = (float) srcrect->y / texture->h; |
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
1281 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
|
1282 |
1987
36a08379b3f2
Implemented color modulation in the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1283 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
|
1284 |
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
|
1285 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
|
1286 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
|
1287 vertices[0].z = 0.0f; |
1904
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
1288 vertices[0].rhw = 1.0f; |
1987
36a08379b3f2
Implemented color modulation in the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1289 vertices[0].color = color; |
1904
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
1290 vertices[0].u = minu; |
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
1291 vertices[0].v = minv; |
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
1292 |
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
|
1293 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
|
1294 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
|
1295 vertices[1].z = 0.0f; |
1904
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
1296 vertices[1].rhw = 1.0f; |
1987
36a08379b3f2
Implemented color modulation in the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1297 vertices[1].color = color; |
1904
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
1298 vertices[1].u = maxu; |
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
1299 vertices[1].v = minv; |
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
1300 |
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
|
1301 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
|
1302 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
|
1303 vertices[2].z = 0.0f; |
1904
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
1304 vertices[2].rhw = 1.0f; |
1987
36a08379b3f2
Implemented color modulation in the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1305 vertices[2].color = color; |
1904
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
1306 vertices[2].u = maxu; |
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
1307 vertices[2].v = maxv; |
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
1308 |
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
|
1309 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
|
1310 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
|
1311 vertices[3].z = 0.0f; |
1904
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
1312 vertices[3].rhw = 1.0f; |
1987
36a08379b3f2
Implemented color modulation in the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1313 vertices[3].color = color; |
1904
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
1314 vertices[3].u = minu; |
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
1315 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
|
1316 |
2932
676754cc1acb
Implemented Direct3D line and point drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2920
diff
changeset
|
1317 D3D_SetBlendMode(data, texture->blendMode); |
1916
c773b0c0ac89
Implemented blend modes in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1913
diff
changeset
|
1318 |
3556
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
1319 if (texture->blendMode == SDL_BLENDMODE_MASK) { |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
1320 shader = data->ps_mask; |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
1321 } |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
1322 |
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
|
1323 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
|
1324 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
|
1325 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
|
1326 D3DTEXF_LINEAR); |
1917
3f54b3ec5a07
Implemented scaling in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1916
diff
changeset
|
1327 |
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
|
1328 result = |
2735
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2222
diff
changeset
|
1329 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
|
1330 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
|
1331 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
|
1332 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
|
1333 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
|
1334 } |
3556
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
1335 if (shader) { |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
1336 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
|
1337 if (FAILED(result)) { |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
1338 D3D_SetError("SetShader()", result); |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
1339 return -1; |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
1340 } |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
1341 } |
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
|
1342 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
|
1343 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
|
1344 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
|
1345 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
|
1346 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
|
1347 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
|
1348 } |
3556
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
1349 if (shader) { |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
1350 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
|
1351 if (FAILED(result)) { |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
1352 D3D_SetError("SetShader()", result); |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
1353 return -1; |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
1354 } |
9c2e92de786a
Added a BLENDMODE_MASK pixel shader so render tests succeed
Sam Lantinga <slouken@libsdl.org>
parents:
3553
diff
changeset
|
1355 } |
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
|
1356 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
|
1357 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1358 |
3427
36cf454ba065
Work in progress on implementation of SDL_RenderReadPixels() and SDL_RenderWritePixels(), code untested.
Sam Lantinga <slouken@libsdl.org>
parents:
3279
diff
changeset
|
1359 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
|
1360 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
|
1361 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
|
1362 { |
3549
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1363 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
|
1364 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
|
1365 SDL_VideoDisplay *display = window->display; |
3549
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1366 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
|
1367 LPDIRECT3DSURFACE9 backBuffer; |
3549
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1368 LPDIRECT3DSURFACE9 surface; |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1369 RECT d3drect; |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1370 D3DLOCKED_RECT locked; |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1371 HRESULT result; |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1372 |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1373 result = IDirect3DDevice9_GetBackBuffer(data->device, 0, 0, D3DBACKBUFFER_TYPE_MONO, &backBuffer); |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1374 if (FAILED(result)) { |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1375 D3D_SetError("GetBackBuffer()", result); |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1376 return -1; |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1377 } |
3427
36cf454ba065
Work in progress on implementation of SDL_RenderReadPixels() and SDL_RenderWritePixels(), code untested.
Sam Lantinga <slouken@libsdl.org>
parents:
3279
diff
changeset
|
1378 |
3549
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1379 result = IDirect3DSurface9_GetDesc(backBuffer, &desc); |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1380 if (FAILED(result)) { |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1381 D3D_SetError("GetDesc()", result); |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1382 IDirect3DSurface9_Release(backBuffer); |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1383 return -1; |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1384 } |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1385 |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1386 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
|
1387 if (FAILED(result)) { |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1388 D3D_SetError("CreateOffscreenPlainSurface()", result); |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1389 IDirect3DSurface9_Release(backBuffer); |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1390 return -1; |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1391 } |
3427
36cf454ba065
Work in progress on implementation of SDL_RenderReadPixels() and SDL_RenderWritePixels(), code untested.
Sam Lantinga <slouken@libsdl.org>
parents:
3279
diff
changeset
|
1392 |
3549
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1393 result = IDirect3DDevice9_GetRenderTargetData(data->device, backBuffer, surface); |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1394 if (FAILED(result)) { |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1395 D3D_SetError("GetRenderTargetData()", result); |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1396 IDirect3DSurface9_Release(surface); |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1397 IDirect3DSurface9_Release(backBuffer); |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1398 return -1; |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1399 } |
3427
36cf454ba065
Work in progress on implementation of SDL_RenderReadPixels() and SDL_RenderWritePixels(), code untested.
Sam Lantinga <slouken@libsdl.org>
parents:
3279
diff
changeset
|
1400 |
3549
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1401 d3drect.left = rect->x; |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1402 d3drect.right = rect->x + rect->w; |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1403 d3drect.top = rect->y; |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1404 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
|
1405 |
3549
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1406 result = IDirect3DSurface9_LockRect(surface, &locked, &d3drect, D3DLOCK_READONLY); |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1407 if (FAILED(result)) { |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1408 D3D_SetError("LockRect()", result); |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1409 IDirect3DSurface9_Release(surface); |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1410 IDirect3DSurface9_Release(backBuffer); |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1411 return -1; |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1412 } |
3427
36cf454ba065
Work in progress on implementation of SDL_RenderReadPixels() and SDL_RenderWritePixels(), code untested.
Sam Lantinga <slouken@libsdl.org>
parents:
3279
diff
changeset
|
1413 |
3549
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1414 SDL_ConvertPixels(rect->w, rect->h, |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1415 display->current_mode.format, locked.pBits, locked.Pitch, |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1416 format, pixels, pitch); |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1417 |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1418 IDirect3DSurface9_UnlockRect(surface); |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1419 |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1420 IDirect3DSurface9_Release(surface); |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1421 IDirect3DSurface9_Release(backBuffer); |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1422 |
686f0e69cd37
Finished implementing RenderReadPixels()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
1423 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
|
1424 } |
36cf454ba065
Work in progress on implementation of SDL_RenderReadPixels() and SDL_RenderWritePixels(), code untested.
Sam Lantinga <slouken@libsdl.org>
parents:
3279
diff
changeset
|
1425 |
3480
cd763d104465
The Direct3D Read/Write pixels interface is in progress.
Sam Lantinga <slouken@libsdl.org>
parents:
3427
diff
changeset
|
1426 static int |
cd763d104465
The Direct3D Read/Write pixels interface is in progress.
Sam Lantinga <slouken@libsdl.org>
parents:
3427
diff
changeset
|
1427 D3D_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect, |
cd763d104465
The Direct3D Read/Write pixels interface is in progress.
Sam Lantinga <slouken@libsdl.org>
parents:
3427
diff
changeset
|
1428 Uint32 format, const void * pixels, int pitch) |
cd763d104465
The Direct3D Read/Write pixels interface is in progress.
Sam Lantinga <slouken@libsdl.org>
parents:
3427
diff
changeset
|
1429 { |
cd763d104465
The Direct3D Read/Write pixels interface is in progress.
Sam Lantinga <slouken@libsdl.org>
parents:
3427
diff
changeset
|
1430 /* Work in progress */ |
3553
a579694613fd
Note that the WritePixels call is unsupported right now.
Sam Lantinga <slouken@libsdl.org>
parents:
3551
diff
changeset
|
1431 SDL_Unsupported(); |
3480
cd763d104465
The Direct3D Read/Write pixels interface is in progress.
Sam Lantinga <slouken@libsdl.org>
parents:
3427
diff
changeset
|
1432 return -1; |
cd763d104465
The Direct3D Read/Write pixels interface is in progress.
Sam Lantinga <slouken@libsdl.org>
parents:
3427
diff
changeset
|
1433 } |
cd763d104465
The Direct3D Read/Write pixels interface is in progress.
Sam Lantinga <slouken@libsdl.org>
parents:
3427
diff
changeset
|
1434 |
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
|
1435 static void |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
1436 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
|
1437 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
1438 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
|
1439 HRESULT result; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
1440 |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
1441 if (!data->beginScene) { |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
1442 IDirect3DDevice9_EndScene(data->device); |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
1443 data->beginScene = SDL_TRUE; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
1444 } |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
1445 |
1975
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
1446 result = IDirect3DDevice9_TestCooperativeLevel(data->device); |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
1447 if (result == D3DERR_DEVICELOST) { |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
1448 /* We'll reset later */ |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
1449 return; |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
1450 } |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
1451 if (result == D3DERR_DEVICENOTRESET) { |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
1452 D3D_Reset(renderer); |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
1453 } |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
1454 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
|
1455 if (FAILED(result)) { |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
1456 D3D_SetError("Present()", result); |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
1457 } |
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
|
1458 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1459 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1460 static void |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
1461 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
|
1462 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
1463 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
|
1464 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1465 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
|
1466 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
|
1467 } |
2973
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
1468 if (data->yuv) { |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
1469 SDL_SW_DestroyYUVTexture(data->yuv); |
ab0c00f1b070
Improved Direct3D YUV texture support
Sam Lantinga <slouken@libsdl.org>
parents:
2972
diff
changeset
|
1470 } |
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
|
1471 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
|
1472 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
|
1473 } |
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
|
1474 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
|
1475 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
|
1476 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1477 |
1975
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
1478 static void |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
1479 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
|
1480 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
1481 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
|
1482 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1483 if (data) { |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
1484 if (data->device) { |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
1485 IDirect3DDevice9_Release(data->device); |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
1486 } |
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
|
1487 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
|
1488 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1489 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
|
1490 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1491 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1492 #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
|
1493 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1494 /* vi: set ts=4 sw=4 expandtab: */ |