Mercurial > sdl-ios-xcode
annotate src/video/win32/SDL_d3drender.c @ 2915:deb377097225
Fixed CPU feature detection on x86_64 platform
(registers were being corrupted, causing crashes)
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Wed, 24 Dec 2008 13:13:38 +0000 |
parents | 9dde605c7540 |
children | 2f91a3847ae8 |
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 |
2859 | 3 Copyright (C) 1997-2009 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 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
26 #include "SDL_win32video.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
|
27 |
c121d94672cb
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 /* 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
|
29 |
2786 | 30 #if 1 /* This takes more memory but you won't lose your texture data */ |
2783
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
31 #define D3DPOOL_SDL D3DPOOL_MANAGED |
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
32 #define SDL_MEMORY_POOL_MANAGED |
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
33 #else |
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
34 #define D3DPOOL_SDL D3DPOOL_DEFAULT |
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
35 #define SDL_MEMORY_POOL_DEFAULT |
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
36 #endif |
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
37 |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
38 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
|
39 static int D3D_DisplayModeChanged(SDL_Renderer * renderer); |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
40 static int D3D_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture); |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
41 static int D3D_SetTexturePalette(SDL_Renderer * renderer, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
42 SDL_Texture * texture, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
43 const SDL_Color * colors, int firstcolor, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
44 int ncolors); |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
45 static int D3D_GetTexturePalette(SDL_Renderer * renderer, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
46 SDL_Texture * texture, SDL_Color * colors, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
47 int firstcolor, int ncolors); |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
48 static int D3D_SetTextureColorMod(SDL_Renderer * renderer, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
49 SDL_Texture * texture); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
50 static int D3D_SetTextureAlphaMod(SDL_Renderer * renderer, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
51 SDL_Texture * texture); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
52 static int D3D_SetTextureBlendMode(SDL_Renderer * renderer, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
53 SDL_Texture * texture); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
54 static int D3D_SetTextureScaleMode(SDL_Renderer * renderer, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
55 SDL_Texture * texture); |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
56 static int D3D_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
57 const SDL_Rect * rect, const void *pixels, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
58 int pitch); |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
59 static int D3D_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
60 const SDL_Rect * rect, int markDirty, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
61 void **pixels, int *pitch); |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
62 static void D3D_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture); |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
63 static void D3D_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
64 int numrects, const SDL_Rect * rects); |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
65 static int D3D_RenderFill(SDL_Renderer * renderer, Uint8 r, Uint8 g, Uint8 b, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
66 Uint8 a, const SDL_Rect * rect); |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
67 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
|
68 const SDL_Rect * srcrect, const SDL_Rect * dstrect); |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
69 static void D3D_RenderPresent(SDL_Renderer * renderer); |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
70 static void D3D_DestroyTexture(SDL_Renderer * renderer, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
71 SDL_Texture * texture); |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
72 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
|
73 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
74 |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
75 SDL_RenderDriver D3D_RenderDriver = { |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
76 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
|
77 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
78 "d3d", |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
79 (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
|
80 SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 | |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
81 SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_PRESENTVSYNC | |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
82 SDL_RENDERER_ACCELERATED), |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
83 (SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_COLOR | |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
84 SDL_TEXTUREMODULATE_ALPHA), |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
85 (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
|
86 SDL_BLENDMODE_BLEND | SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD), |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
87 (SDL_TEXTURESCALEMODE_NONE | SDL_TEXTURESCALEMODE_FAST | |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
88 SDL_TEXTURESCALEMODE_SLOW | SDL_TEXTURESCALEMODE_BEST), |
2811
7af2419ad5b0
Fixed the list of supported YUV formats
Sam Lantinga <slouken@libsdl.org>
parents:
2810
diff
changeset
|
89 12, |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
90 { |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
91 SDL_PIXELFORMAT_INDEX8, |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
92 SDL_PIXELFORMAT_RGB332, |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
93 SDL_PIXELFORMAT_RGB444, |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
94 SDL_PIXELFORMAT_RGB555, |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
95 SDL_PIXELFORMAT_ARGB4444, |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
96 SDL_PIXELFORMAT_ARGB1555, |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
97 SDL_PIXELFORMAT_RGB565, |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
98 SDL_PIXELFORMAT_RGB888, |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
99 SDL_PIXELFORMAT_ARGB8888, |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
100 SDL_PIXELFORMAT_ARGB2101010, |
2810
27cb878a278e
Implemented the X11 (non-OpenGL) renderer, no alpha or scaling available.
Sam Lantinga <slouken@libsdl.org>
parents:
2786
diff
changeset
|
101 SDL_PIXELFORMAT_YUY2, |
2811
7af2419ad5b0
Fixed the list of supported YUV formats
Sam Lantinga <slouken@libsdl.org>
parents:
2810
diff
changeset
|
102 SDL_PIXELFORMAT_UYVY}, |
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
|
103 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
|
104 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
|
105 }; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
106 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
107 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
|
108 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
109 IDirect3DDevice9 *device; |
1975
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
110 D3DPRESENT_PARAMETERS pparams; |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
111 SDL_bool beginScene; |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
112 } 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
|
113 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
114 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
|
115 { |
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
|
116 IDirect3DTexture9 *texture; |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
117 } 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
|
118 |
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
|
119 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
|
120 { |
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
121 float x, y, z; |
1904
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
122 float rhw; |
1987
36a08379b3f2
Implemented color modulation in the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
123 DWORD color; |
1904
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
124 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
|
125 } 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
|
126 |
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
|
127 static void |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
128 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
|
129 { |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
130 const char *error; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
131 |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
132 switch (result) { |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
133 case D3DERR_WRONGTEXTUREFORMAT: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
134 error = "WRONGTEXTUREFORMAT"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
135 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
136 case D3DERR_UNSUPPORTEDCOLOROPERATION: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
137 error = "UNSUPPORTEDCOLOROPERATION"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
138 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
139 case D3DERR_UNSUPPORTEDCOLORARG: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
140 error = "UNSUPPORTEDCOLORARG"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
141 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
142 case D3DERR_UNSUPPORTEDALPHAOPERATION: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
143 error = "UNSUPPORTEDALPHAOPERATION"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
144 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
145 case D3DERR_UNSUPPORTEDALPHAARG: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
146 error = "UNSUPPORTEDALPHAARG"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
147 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
148 case D3DERR_TOOMANYOPERATIONS: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
149 error = "TOOMANYOPERATIONS"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
150 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
151 case D3DERR_CONFLICTINGTEXTUREFILTER: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
152 error = "CONFLICTINGTEXTUREFILTER"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
153 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
154 case D3DERR_UNSUPPORTEDFACTORVALUE: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
155 error = "UNSUPPORTEDFACTORVALUE"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
156 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
157 case D3DERR_CONFLICTINGRENDERSTATE: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
158 error = "CONFLICTINGRENDERSTATE"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
159 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
160 case D3DERR_UNSUPPORTEDTEXTUREFILTER: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
161 error = "UNSUPPORTEDTEXTUREFILTER"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
162 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
163 case D3DERR_CONFLICTINGTEXTUREPALETTE: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
164 error = "CONFLICTINGTEXTUREPALETTE"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
165 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
166 case D3DERR_DRIVERINTERNALERROR: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
167 error = "DRIVERINTERNALERROR"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
168 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
169 case D3DERR_NOTFOUND: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
170 error = "NOTFOUND"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
171 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
172 case D3DERR_MOREDATA: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
173 error = "MOREDATA"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
174 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
175 case D3DERR_DEVICELOST: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
176 error = "DEVICELOST"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
177 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
178 case D3DERR_DEVICENOTRESET: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
179 error = "DEVICENOTRESET"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
180 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
181 case D3DERR_NOTAVAILABLE: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
182 error = "NOTAVAILABLE"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
183 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
184 case D3DERR_OUTOFVIDEOMEMORY: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
185 error = "OUTOFVIDEOMEMORY"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
186 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
187 case D3DERR_INVALIDDEVICE: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
188 error = "INVALIDDEVICE"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
189 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
190 case D3DERR_INVALIDCALL: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
191 error = "INVALIDCALL"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
192 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
193 case D3DERR_DRIVERINVALIDCALL: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
194 error = "DRIVERINVALIDCALL"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
195 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
196 case D3DERR_WASSTILLDRAWING: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
197 error = "WASSTILLDRAWING"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
198 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
199 default: |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
200 error = "UNKNOWN"; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
201 break; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
202 } |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
203 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
|
204 } |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
205 |
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
|
206 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
|
207 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
|
208 { |
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
|
209 switch (format) { |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
210 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
|
211 return D3DFMT_P8; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
212 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
|
213 return D3DFMT_R3G3B2; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
214 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
|
215 return D3DFMT_X4R4G4B4; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
216 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
|
217 return D3DFMT_X1R5G5B5; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
218 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
|
219 return D3DFMT_A4R4G4B4; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
220 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
|
221 return D3DFMT_A1R5G5B5; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
222 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
|
223 return D3DFMT_R5G6B5; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
224 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
|
225 return D3DFMT_X8R8G8B8; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
226 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
|
227 return D3DFMT_A8R8G8B8; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
228 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
|
229 return D3DFMT_A2R10G10B10; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
230 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
|
231 return D3DFMT_UYVY; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
232 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
|
233 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
|
234 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
|
235 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
|
236 } |
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
|
237 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
238 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
239 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
|
240 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
|
241 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
242 SDL_VideoData *data = (SDL_VideoData *) _this->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
|
243 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
244 if (data->d3d) { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
245 SDL_AddRenderDriver(0, &D3D_RenderDriver); |
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
|
246 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
247 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
248 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
249 SDL_Renderer * |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
250 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
|
251 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
252 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
253 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
|
254 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
|
255 SDL_Renderer *renderer; |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
256 D3D_RenderData *data; |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
257 HRESULT result; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
258 D3DPRESENT_PARAMETERS pparams; |
1907
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
259 IDirect3DSwapChain9 *chain; |
1925
411bfb37082b
Query the maximum texture size for the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
260 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
|
261 |
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
|
262 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
|
263 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
|
264 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
|
265 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
|
266 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
267 |
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
|
268 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
|
269 if (!data) { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
270 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
|
271 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
|
272 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
|
273 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
274 |
1975
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
275 renderer->DisplayModeChanged = D3D_DisplayModeChanged; |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
276 renderer->CreateTexture = D3D_CreateTexture; |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
277 renderer->SetTexturePalette = D3D_SetTexturePalette; |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
278 renderer->GetTexturePalette = D3D_GetTexturePalette; |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
279 renderer->SetTextureColorMod = D3D_SetTextureColorMod; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
280 renderer->SetTextureAlphaMod = D3D_SetTextureAlphaMod; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
281 renderer->SetTextureBlendMode = D3D_SetTextureBlendMode; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
282 renderer->SetTextureScaleMode = D3D_SetTextureScaleMode; |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
283 renderer->UpdateTexture = D3D_UpdateTexture; |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
284 renderer->LockTexture = D3D_LockTexture; |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
285 renderer->UnlockTexture = D3D_UnlockTexture; |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
286 renderer->DirtyTexture = D3D_DirtyTexture; |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
287 renderer->RenderFill = D3D_RenderFill; |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
288 renderer->RenderCopy = D3D_RenderCopy; |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
289 renderer->RenderPresent = D3D_RenderPresent; |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
290 renderer->DestroyTexture = D3D_DestroyTexture; |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
291 renderer->DestroyRenderer = D3D_DestroyRenderer; |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
292 renderer->info = D3D_RenderDriver.info; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
293 renderer->window = window->id; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
294 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
|
295 |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
296 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
|
297 |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
298 SDL_zero(pparams); |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
299 pparams.BackBufferWidth = window->w; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
300 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
|
301 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
|
302 pparams.BackBufferFormat = |
1975
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
303 PixelFormatToD3DFMT(display->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
|
304 } 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
|
305 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
|
306 } |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
307 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
|
308 pparams.BackBufferCount = 2; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
309 pparams.SwapEffect = D3DSWAPEFFECT_FLIP; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
310 } 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
|
311 pparams.BackBufferCount = 3; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
312 pparams.SwapEffect = D3DSWAPEFFECT_FLIP; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
313 } 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
|
314 pparams.BackBufferCount = 1; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
315 pparams.SwapEffect = D3DSWAPEFFECT_COPY; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
316 } else { |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
317 pparams.BackBufferCount = 1; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
318 pparams.SwapEffect = D3DSWAPEFFECT_DISCARD; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
319 } |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
320 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
|
321 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
|
322 pparams.FullScreen_RefreshRateInHz = |
1975
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
323 display->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
|
324 } else { |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
325 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
|
326 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
|
327 } |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
328 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
|
329 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
|
330 } else { |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
331 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
|
332 } |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
333 |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
334 result = IDirect3D9_CreateDevice(videodata->d3d, D3DADAPTER_DEFAULT, /* FIXME */ |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
335 D3DDEVTYPE_HAL, |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
336 windowdata->hwnd, |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
337 D3DCREATE_SOFTWARE_VERTEXPROCESSING, |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
338 &pparams, &data->device); |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
339 if (FAILED(result)) { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
340 D3D_DestroyRenderer(renderer); |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
341 D3D_SetError("CreateDevice()", result); |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
342 return NULL; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
343 } |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
344 data->beginScene = SDL_TRUE; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
345 |
1907
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
346 /* 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
|
347 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
|
348 if (FAILED(result)) { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
349 D3D_DestroyRenderer(renderer); |
1907
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
350 D3D_SetError("GetSwapChain()", result); |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
351 return NULL; |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
352 } |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
353 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
|
354 if (FAILED(result)) { |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
355 IDirect3DSwapChain9_Release(chain); |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
356 D3D_DestroyRenderer(renderer); |
1907
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
357 D3D_SetError("GetPresentParameters()", result); |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
358 return NULL; |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
359 } |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
360 IDirect3DSwapChain9_Release(chain); |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
361 switch (pparams.SwapEffect) { |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
362 case D3DSWAPEFFECT_COPY: |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
363 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
|
364 break; |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
365 case D3DSWAPEFFECT_FLIP: |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
366 switch (pparams.BackBufferCount) { |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
367 case 2: |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
368 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
|
369 break; |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
370 case 3: |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
371 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
|
372 break; |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
373 } |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
374 break; |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
375 case D3DSWAPEFFECT_DISCARD: |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
376 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
|
377 break; |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
378 } |
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
379 if (pparams.PresentationInterval == D3DPRESENT_INTERVAL_ONE) { |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
380 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
|
381 } |
1975
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
382 data->pparams = pparams; |
1907
06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1905
diff
changeset
|
383 |
1925
411bfb37082b
Query the maximum texture size for the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
384 IDirect3DDevice9_GetDeviceCaps(data->device, &caps); |
411bfb37082b
Query the maximum texture size for the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1924
diff
changeset
|
385 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
|
386 renderer->info.max_texture_height = caps.MaxTextureHeight; |
1918
092bd3a019c5
Starting on the OpenGL renderer...
Sam Lantinga <slouken@libsdl.org>
parents:
1917
diff
changeset
|
387 |
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
|
388 /* Set up parameters for rendering */ |
1904
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
389 IDirect3DDevice9_SetVertexShader(data->device, NULL); |
1987
36a08379b3f2
Implemented color modulation in the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
390 IDirect3DDevice9_SetFVF(data->device, |
36a08379b3f2
Implemented color modulation in the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
391 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
|
392 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
|
393 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
|
394 D3DCULL_NONE); |
1904
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
395 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
|
396 /* 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
|
397 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
|
398 D3DTOP_MODULATE); |
1ee02169bbb0
Figured out how texture stages work, thanks to this:
Sam Lantinga <slouken@libsdl.org>
parents:
1987
diff
changeset
|
399 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
|
400 D3DTA_TEXTURE); |
1ee02169bbb0
Figured out how texture stages work, thanks to this:
Sam Lantinga <slouken@libsdl.org>
parents:
1987
diff
changeset
|
401 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
|
402 D3DTA_DIFFUSE); |
1ee02169bbb0
Figured out how texture stages work, thanks to this:
Sam Lantinga <slouken@libsdl.org>
parents:
1987
diff
changeset
|
403 /* 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
|
404 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
|
405 D3DTOP_MODULATE); |
1ee02169bbb0
Figured out how texture stages work, thanks to this:
Sam Lantinga <slouken@libsdl.org>
parents:
1987
diff
changeset
|
406 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
|
407 D3DTA_TEXTURE); |
1ee02169bbb0
Figured out how texture stages work, thanks to this:
Sam Lantinga <slouken@libsdl.org>
parents:
1987
diff
changeset
|
408 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
|
409 D3DTA_DIFFUSE); |
1991
3863ba81c1d6
Clear the second texture stage explicitly
Sam Lantinga <slouken@libsdl.org>
parents:
1988
diff
changeset
|
410 /* Disable second texture stage, since we're done */ |
3863ba81c1d6
Clear the second texture stage explicitly
Sam Lantinga <slouken@libsdl.org>
parents:
1988
diff
changeset
|
411 IDirect3DDevice9_SetTextureStageState(data->device, 1, D3DTSS_COLOROP, |
3863ba81c1d6
Clear the second texture stage explicitly
Sam Lantinga <slouken@libsdl.org>
parents:
1988
diff
changeset
|
412 D3DTOP_DISABLE); |
3863ba81c1d6
Clear the second texture stage explicitly
Sam Lantinga <slouken@libsdl.org>
parents:
1988
diff
changeset
|
413 IDirect3DDevice9_SetTextureStageState(data->device, 1, D3DTSS_ALPHAOP, |
3863ba81c1d6
Clear the second texture stage explicitly
Sam Lantinga <slouken@libsdl.org>
parents:
1988
diff
changeset
|
414 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
|
415 |
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
|
416 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
|
417 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
418 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
419 static int |
1975
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
420 D3D_Reset(SDL_Renderer * renderer) |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
421 { |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
422 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
|
423 HRESULT result; |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
424 |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
425 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
|
426 if (FAILED(result)) { |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
427 if (result == D3DERR_DEVICELOST) { |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
428 /* 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
|
429 return 0; |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
430 } else { |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
431 D3D_SetError("Reset()", result); |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
432 return -1; |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
433 } |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
434 } |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
435 IDirect3DDevice9_SetVertexShader(data->device, NULL); |
1987
36a08379b3f2
Implemented color modulation in the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
436 IDirect3DDevice9_SetFVF(data->device, |
36a08379b3f2
Implemented color modulation in the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
437 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
|
438 IDirect3DDevice9_SetRenderState(data->device, D3DRS_CULLMODE, |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
439 D3DCULL_NONE); |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
440 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
|
441 return 0; |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
442 } |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
443 |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
444 static int |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
445 D3D_DisplayModeChanged(SDL_Renderer * renderer) |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
446 { |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
447 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
|
448 SDL_Window *window = SDL_GetWindowFromID(renderer->window); |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
449 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
450 |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
451 data->pparams.BackBufferWidth = window->w; |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
452 data->pparams.BackBufferHeight = window->h; |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
453 if (window->flags & SDL_WINDOW_FULLSCREEN) { |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
454 data->pparams.BackBufferFormat = |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
455 PixelFormatToD3DFMT(display->fullscreen_mode.format); |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
456 } else { |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
457 data->pparams.BackBufferFormat = D3DFMT_UNKNOWN; |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
458 } |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
459 return D3D_Reset(renderer); |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
460 } |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
461 |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
462 static int |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
463 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
|
464 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
465 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
|
466 SDL_Window *window = SDL_GetWindowFromID(renderer->window); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
467 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
468 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
|
469 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
|
470 |
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
|
471 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
|
472 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
|
473 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
|
474 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
|
475 } |
c121d94672cb
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 |
c121d94672cb
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 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
|
478 |
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
|
479 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
|
480 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
|
481 texture->h, 1, 0, |
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
482 PixelFormatToD3DFMT(texture->format), |
2783
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
483 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
|
484 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
|
485 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
|
486 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
|
487 } |
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
|
488 |
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
|
489 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
|
490 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
491 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
492 static int |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
493 D3D_SetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
494 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
|
495 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
496 D3D_RenderData *renderdata = (D3D_RenderData *) renderer->driverdata; |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
497 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
|
498 |
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
|
499 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
|
500 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
501 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
502 static int |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
503 D3D_GetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
504 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
|
505 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
506 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
|
507 |
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 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
|
509 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
510 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
511 static int |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
512 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
|
513 { |
1987
36a08379b3f2
Implemented color modulation in the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
514 return 0; |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
515 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
516 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
517 static int |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
518 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
|
519 { |
1987
36a08379b3f2
Implemented color modulation in the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
520 return 0; |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
521 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
522 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
523 static int |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
524 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
|
525 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
526 switch (texture->blendMode) { |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
527 case SDL_BLENDMODE_NONE: |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
528 case SDL_BLENDMODE_MASK: |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
529 case SDL_BLENDMODE_BLEND: |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
530 case SDL_BLENDMODE_ADD: |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
531 case SDL_BLENDMODE_MOD: |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
532 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
533 default: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
534 SDL_Unsupported(); |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
535 texture->blendMode = SDL_BLENDMODE_NONE; |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
536 return -1; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
537 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
538 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
539 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
540 static int |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
541 D3D_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
542 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
543 switch (texture->scaleMode) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
544 case SDL_TEXTURESCALEMODE_NONE: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
545 case SDL_TEXTURESCALEMODE_FAST: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
546 case SDL_TEXTURESCALEMODE_SLOW: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
547 case SDL_TEXTURESCALEMODE_BEST: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
548 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
549 default: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
550 SDL_Unsupported(); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
551 texture->scaleMode = SDL_TEXTURESCALEMODE_NONE; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
552 return -1; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
553 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
554 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
555 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
556 |
2783
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
557 #ifdef SDL_MEMORY_POOL_DEFAULT |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
558 static int |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
559 D3D_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
560 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
|
561 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
562 D3D_TextureData *data = (D3D_TextureData *) texture->driverdata; |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
563 D3D_RenderData *renderdata = (D3D_RenderData *) renderer->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
|
564 IDirect3DTexture9 *temp; |
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
565 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
|
566 D3DLOCKED_RECT locked; |
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
567 const Uint8 *src; |
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
568 Uint8 *dst; |
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
569 int row, length; |
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
570 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
|
571 |
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
|
572 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
|
573 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
|
574 texture->h, 1, 0, |
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
575 PixelFormatToD3DFMT(texture->format), |
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
576 D3DPOOL_SYSTEMMEM, &temp, NULL); |
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
577 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
|
578 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
|
579 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
|
580 } |
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
581 |
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
582 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
|
583 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
|
584 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
|
585 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
|
586 |
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
587 result = IDirect3DTexture9_LockRect(temp, 0, &locked, &d3drect, 0); |
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
588 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
|
589 IDirect3DTexture9_Release(temp); |
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
590 D3D_SetError("LockRect()", 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
|
591 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
|
592 } |
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
|
593 |
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
|
594 src = pixels; |
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
595 dst = locked.pBits; |
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
596 length = rect->w * SDL_BYTESPERPIXEL(texture->format); |
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
597 for (row = 0; row < rect->h; ++row) { |
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
598 SDL_memcpy(dst, src, length); |
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
599 src += pitch; |
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
600 dst += locked.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
|
601 } |
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
|
602 IDirect3DTexture9_UnlockRect(temp, 0); |
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
603 |
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
604 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
|
605 IDirect3DDevice9_UpdateTexture(renderdata->device, |
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
606 (IDirect3DBaseTexture9 *) temp, |
2735
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2222
diff
changeset
|
607 (IDirect3DBaseTexture9 *) |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2222
diff
changeset
|
608 data->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
|
609 IDirect3DTexture9_Release(temp); |
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
610 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
|
611 D3D_SetError("UpdateTexture()", 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
|
612 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
|
613 } |
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
614 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
|
615 } |
2783
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
616 #else |
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
617 static int |
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
618 D3D_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, |
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
619 const SDL_Rect * rect, const void *pixels, int pitch) |
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
620 { |
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
621 D3D_TextureData *data = (D3D_TextureData *) texture->driverdata; |
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
622 D3D_RenderData *renderdata = (D3D_RenderData *) renderer->driverdata; |
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
623 RECT d3drect; |
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
624 D3DLOCKED_RECT locked; |
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
625 const Uint8 *src; |
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
626 Uint8 *dst; |
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
627 int row, length; |
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
628 HRESULT result; |
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
629 |
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
630 d3drect.left = rect->x; |
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
631 d3drect.right = rect->x + rect->w; |
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
632 d3drect.top = rect->y; |
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
633 d3drect.bottom = rect->y + rect->h; |
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
634 |
2786 | 635 result = |
636 IDirect3DTexture9_LockRect(data->texture, 0, &locked, &d3drect, 0); | |
2783
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
637 if (FAILED(result)) { |
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
638 D3D_SetError("LockRect()", result); |
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
639 return -1; |
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
640 } |
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
641 |
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
642 src = pixels; |
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
643 dst = locked.pBits; |
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
644 length = rect->w * SDL_BYTESPERPIXEL(texture->format); |
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
645 for (row = 0; row < rect->h; ++row) { |
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
646 SDL_memcpy(dst, src, length); |
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
647 src += pitch; |
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
648 dst += locked.Pitch; |
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
649 } |
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
650 IDirect3DTexture9_UnlockRect(data->texture, 0); |
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
651 return 0; |
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
652 } |
e33ad7ebb7eb
Fixed Direct3D rendering
Sam Lantinga <slouken@libsdl.org>
parents:
2735
diff
changeset
|
653 #endif // SDL_MEMORY_POOL_DEFAULT |
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
|
654 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
655 static int |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
656 D3D_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
657 const SDL_Rect * rect, int markDirty, void **pixels, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
658 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
|
659 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
660 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
|
661 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
|
662 D3DLOCKED_RECT locked; |
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
663 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
|
664 |
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
|
665 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
|
666 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
|
667 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
|
668 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
|
669 |
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
670 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
|
671 IDirect3DTexture9_LockRect(data->texture, 0, &locked, &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
|
672 markDirty ? 0 : D3DLOCK_NO_DIRTY_UPDATE); |
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
673 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
|
674 D3D_SetError("LockRect()", 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
|
675 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
|
676 } |
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
677 *pixels = locked.pBits; |
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
678 *pitch = locked.Pitch; |
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
679 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
|
680 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
681 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
682 static void |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
683 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
|
684 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
685 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
|
686 |
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
|
687 IDirect3DTexture9_UnlockRect(data->texture, 0); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
688 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
689 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
690 static void |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
691 D3D_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture, int numrects, |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
692 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
|
693 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
694 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
|
695 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
|
696 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
|
697 |
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
698 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
|
699 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
|
700 |
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
701 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
|
702 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
|
703 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
|
704 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
|
705 |
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
706 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
|
707 } |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
708 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
709 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
710 static int |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
711 D3D_RenderFill(SDL_Renderer * renderer, Uint8 r, Uint8 g, Uint8 b, Uint8 a, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
712 const SDL_Rect * rect) |
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
|
713 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
714 D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; |
1901
f1828a500391
Removed libc dependency on Windows again, to fix building with Visual C++ 2005 Express Edition.
Sam Lantinga <slouken@libsdl.org>
parents:
1900
diff
changeset
|
715 D3DRECT d3drect; |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
716 HRESULT result; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
717 |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
718 if (data->beginScene) { |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
719 IDirect3DDevice9_BeginScene(data->device); |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
720 data->beginScene = SDL_FALSE; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
721 } |
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
|
722 |
1901
f1828a500391
Removed libc dependency on Windows again, to fix building with Visual C++ 2005 Express Edition.
Sam Lantinga <slouken@libsdl.org>
parents:
1900
diff
changeset
|
723 d3drect.x1 = rect->x; |
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
|
724 d3drect.x2 = rect->x + rect->w; |
1901
f1828a500391
Removed libc dependency on Windows again, to fix building with Visual C++ 2005 Express Edition.
Sam Lantinga <slouken@libsdl.org>
parents:
1900
diff
changeset
|
725 d3drect.y1 = rect->y; |
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 d3drect.y2 = rect->y + rect->h; |
1901
f1828a500391
Removed libc dependency on Windows again, to fix building with Visual C++ 2005 Express Edition.
Sam Lantinga <slouken@libsdl.org>
parents:
1900
diff
changeset
|
727 |
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
|
728 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
|
729 IDirect3DDevice9_Clear(data->device, 1, &d3drect, D3DCLEAR_TARGET, |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
730 D3DCOLOR_ARGB(a, r, g, b), 1.0f, 0); |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
731 if (FAILED(result)) { |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
732 D3D_SetError("Clear()", result); |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
733 return -1; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
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 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
|
736 } |
c121d94672cb
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 static int |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
739 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
|
740 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
|
741 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
742 D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; |
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
743 D3D_TextureData *texturedata = (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
|
744 float minx, miny, maxx, maxy; |
1904
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
745 float minu, maxu, minv, maxv; |
1987
36a08379b3f2
Implemented color modulation in the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
746 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
|
747 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
|
748 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
|
749 |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
750 if (data->beginScene) { |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
751 IDirect3DDevice9_BeginScene(data->device); |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
752 data->beginScene = SDL_FALSE; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
753 } |
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
|
754 |
1904
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
755 minx = (float) dstrect->x - 0.5f; |
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
756 miny = (float) dstrect->y - 0.5f; |
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
757 maxx = (float) dstrect->x + dstrect->w - 0.5f; |
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
758 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
|
759 |
1904
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
760 minu = (float) srcrect->x / texture->w; |
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
761 maxu = (float) (srcrect->x + srcrect->w) / texture->w; |
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
762 minv = (float) srcrect->y / texture->h; |
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
763 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
|
764 |
1987
36a08379b3f2
Implemented color modulation in the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
765 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
|
766 |
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
|
767 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
|
768 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
|
769 vertices[0].z = 0.0f; |
1904
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
770 vertices[0].rhw = 1.0f; |
1987
36a08379b3f2
Implemented color modulation in the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
771 vertices[0].color = color; |
1904
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
772 vertices[0].u = minu; |
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
773 vertices[0].v = minv; |
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
774 |
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
|
775 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
|
776 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
|
777 vertices[1].z = 0.0f; |
1904
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
778 vertices[1].rhw = 1.0f; |
1987
36a08379b3f2
Implemented color modulation in the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
779 vertices[1].color = color; |
1904
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
780 vertices[1].u = maxu; |
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
781 vertices[1].v = minv; |
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
782 |
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
|
783 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
|
784 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
|
785 vertices[2].z = 0.0f; |
1904
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
786 vertices[2].rhw = 1.0f; |
1987
36a08379b3f2
Implemented color modulation in the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
787 vertices[2].color = color; |
1904
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
788 vertices[2].u = maxu; |
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
789 vertices[2].v = maxv; |
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
790 |
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
|
791 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
|
792 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
|
793 vertices[3].z = 0.0f; |
1904
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
794 vertices[3].rhw = 1.0f; |
1987
36a08379b3f2
Implemented color modulation in the D3D renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
795 vertices[3].color = color; |
1904
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
796 vertices[3].u = minu; |
1a713f9d1f71
Yay! D3D renderer works!
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
797 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
|
798 |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
799 switch (texture->blendMode) { |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
800 case SDL_BLENDMODE_NONE: |
1916
c773b0c0ac89
Implemented blend modes in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1913
diff
changeset
|
801 IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE, |
c773b0c0ac89
Implemented blend modes in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1913
diff
changeset
|
802 FALSE); |
c773b0c0ac89
Implemented blend modes in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1913
diff
changeset
|
803 break; |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
804 case SDL_BLENDMODE_MASK: |
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
805 case SDL_BLENDMODE_BLEND: |
1916
c773b0c0ac89
Implemented blend modes in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1913
diff
changeset
|
806 IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE, |
c773b0c0ac89
Implemented blend modes in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1913
diff
changeset
|
807 TRUE); |
c773b0c0ac89
Implemented blend modes in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1913
diff
changeset
|
808 IDirect3DDevice9_SetRenderState(data->device, D3DRS_SRCBLEND, |
c773b0c0ac89
Implemented blend modes in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1913
diff
changeset
|
809 D3DBLEND_SRCALPHA); |
c773b0c0ac89
Implemented blend modes in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1913
diff
changeset
|
810 IDirect3DDevice9_SetRenderState(data->device, D3DRS_DESTBLEND, |
c773b0c0ac89
Implemented blend modes in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1913
diff
changeset
|
811 D3DBLEND_INVSRCALPHA); |
c773b0c0ac89
Implemented blend modes in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1913
diff
changeset
|
812 break; |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
813 case SDL_BLENDMODE_ADD: |
1916
c773b0c0ac89
Implemented blend modes in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1913
diff
changeset
|
814 IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE, |
c773b0c0ac89
Implemented blend modes in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1913
diff
changeset
|
815 TRUE); |
c773b0c0ac89
Implemented blend modes in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1913
diff
changeset
|
816 IDirect3DDevice9_SetRenderState(data->device, D3DRS_SRCBLEND, |
c773b0c0ac89
Implemented blend modes in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1913
diff
changeset
|
817 D3DBLEND_SRCALPHA); |
c773b0c0ac89
Implemented blend modes in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1913
diff
changeset
|
818 IDirect3DDevice9_SetRenderState(data->device, D3DRS_DESTBLEND, |
c773b0c0ac89
Implemented blend modes in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1913
diff
changeset
|
819 D3DBLEND_ONE); |
c773b0c0ac89
Implemented blend modes in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1913
diff
changeset
|
820 break; |
2884
9dde605c7540
Date: Fri, 19 Dec 2008 20:17:35 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
821 case SDL_BLENDMODE_MOD: |
1916
c773b0c0ac89
Implemented blend modes in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1913
diff
changeset
|
822 IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE, |
c773b0c0ac89
Implemented blend modes in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1913
diff
changeset
|
823 TRUE); |
c773b0c0ac89
Implemented blend modes in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1913
diff
changeset
|
824 IDirect3DDevice9_SetRenderState(data->device, D3DRS_SRCBLEND, |
c773b0c0ac89
Implemented blend modes in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1913
diff
changeset
|
825 D3DBLEND_ZERO); |
c773b0c0ac89
Implemented blend modes in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1913
diff
changeset
|
826 IDirect3DDevice9_SetRenderState(data->device, D3DRS_DESTBLEND, |
c773b0c0ac89
Implemented blend modes in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1913
diff
changeset
|
827 D3DBLEND_SRCCOLOR); |
c773b0c0ac89
Implemented blend modes in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1913
diff
changeset
|
828 break; |
c773b0c0ac89
Implemented blend modes in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1913
diff
changeset
|
829 } |
c773b0c0ac89
Implemented blend modes in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1913
diff
changeset
|
830 |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
1976
diff
changeset
|
831 switch (texture->scaleMode) { |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
832 case SDL_TEXTURESCALEMODE_NONE: |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
833 case SDL_TEXTURESCALEMODE_FAST: |
1917
3f54b3ec5a07
Implemented scaling in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1916
diff
changeset
|
834 IDirect3DDevice9_SetSamplerState(data->device, 0, D3DSAMP_MINFILTER, |
3f54b3ec5a07
Implemented scaling in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1916
diff
changeset
|
835 D3DTEXF_POINT); |
3f54b3ec5a07
Implemented scaling in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1916
diff
changeset
|
836 IDirect3DDevice9_SetSamplerState(data->device, 0, D3DSAMP_MAGFILTER, |
3f54b3ec5a07
Implemented scaling in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1916
diff
changeset
|
837 D3DTEXF_POINT); |
3f54b3ec5a07
Implemented scaling in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1916
diff
changeset
|
838 break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
839 case SDL_TEXTURESCALEMODE_SLOW: |
1917
3f54b3ec5a07
Implemented scaling in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1916
diff
changeset
|
840 IDirect3DDevice9_SetSamplerState(data->device, 0, D3DSAMP_MINFILTER, |
3f54b3ec5a07
Implemented scaling in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1916
diff
changeset
|
841 D3DTEXF_LINEAR); |
3f54b3ec5a07
Implemented scaling in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1916
diff
changeset
|
842 IDirect3DDevice9_SetSamplerState(data->device, 0, D3DSAMP_MAGFILTER, |
3f54b3ec5a07
Implemented scaling in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1916
diff
changeset
|
843 D3DTEXF_LINEAR); |
3f54b3ec5a07
Implemented scaling in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1916
diff
changeset
|
844 break; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1925
diff
changeset
|
845 case SDL_TEXTURESCALEMODE_BEST: |
1917
3f54b3ec5a07
Implemented scaling in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1916
diff
changeset
|
846 IDirect3DDevice9_SetSamplerState(data->device, 0, D3DSAMP_MINFILTER, |
3f54b3ec5a07
Implemented scaling in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1916
diff
changeset
|
847 D3DTEXF_GAUSSIANQUAD); |
3f54b3ec5a07
Implemented scaling in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1916
diff
changeset
|
848 IDirect3DDevice9_SetSamplerState(data->device, 0, D3DSAMP_MAGFILTER, |
3f54b3ec5a07
Implemented scaling in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1916
diff
changeset
|
849 D3DTEXF_GAUSSIANQUAD); |
3f54b3ec5a07
Implemented scaling in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1916
diff
changeset
|
850 break; |
3f54b3ec5a07
Implemented scaling in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1916
diff
changeset
|
851 } |
3f54b3ec5a07
Implemented scaling in the D3D renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1916
diff
changeset
|
852 |
1903
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
853 result = |
2735
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2222
diff
changeset
|
854 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
|
855 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
|
856 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
|
857 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
|
858 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
|
859 } |
f132024010be
More of the Direct3D renderer is implemented, I'm not sure why it's not showing texture copies yet...
Sam Lantinga <slouken@libsdl.org>
parents:
1901
diff
changeset
|
860 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
|
861 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
|
862 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
|
863 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
|
864 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
|
865 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
|
866 } |
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
|
867 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
|
868 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
869 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
870 static void |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
871 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
|
872 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
873 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
|
874 HRESULT result; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
875 |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
876 if (!data->beginScene) { |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
877 IDirect3DDevice9_EndScene(data->device); |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
878 data->beginScene = SDL_TRUE; |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
879 } |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
880 |
1975
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
881 result = IDirect3DDevice9_TestCooperativeLevel(data->device); |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
882 if (result == D3DERR_DEVICELOST) { |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
883 /* We'll reset later */ |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
884 return; |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
885 } |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
886 if (result == D3DERR_DEVICENOTRESET) { |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
887 D3D_Reset(renderer); |
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
888 } |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
889 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
|
890 if (FAILED(result)) { |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
891 D3D_SetError("Present()", result); |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
892 } |
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
|
893 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
894 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
895 static void |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
896 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
|
897 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
898 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
|
899 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
900 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
|
901 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
|
902 } |
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
|
903 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
|
904 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
|
905 } |
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
|
906 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
|
907 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
|
908 } |
c121d94672cb
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 |
1975
ccef0d0c40c6
Added resize support for GDI and Direct3D renderers
Sam Lantinga <slouken@libsdl.org>
parents:
1965
diff
changeset
|
910 static void |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
911 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
|
912 { |
1913
83420da906a5
Implemented Windows OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
913 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
|
914 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
915 if (data) { |
1900
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
916 if (data->device) { |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
917 IDirect3DDevice9_Release(data->device); |
5c6bdbf3aadf
First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents:
1898
diff
changeset
|
918 } |
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
|
919 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
|
920 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
921 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
|
922 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
923 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
924 #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
|
925 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
926 /* vi: set ts=4 sw=4 expandtab: */ |