annotate src/video/win32/SDL_d3drender.c @ 1901:f1828a500391

Removed libc dependency on Windows again, to fix building with Visual C++ 2005 Express Edition. Fixed performance problem with testsprite2 on the D3D driver.
author Sam Lantinga <slouken@libsdl.org>
date Thu, 13 Jul 2006 08:13:02 +0000
parents 5c6bdbf3aadf
children f132024010be
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
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3 Copyright (C) 1997-2006 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
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 #include "../SDL_yuv_sw_c.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
28
c121d94672cb 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 /* 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
30
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
31 static SDL_Renderer *SDL_D3D_CreateRenderer(SDL_Window * 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
32 Uint32 flags);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
33 static int SDL_D3D_CreateTexture(SDL_Renderer * 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
34 SDL_Texture * texture);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
35 static int SDL_D3D_QueryTexturePixels(SDL_Renderer * 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
36 SDL_Texture * texture, void **pixels,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
37 int *pitch);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
38 static int SDL_D3D_SetTexturePalette(SDL_Renderer * 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
39 SDL_Texture * texture,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
40 const SDL_Color * colors, int firstcolor,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
41 int ncolors);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
42 static int SDL_D3D_GetTexturePalette(SDL_Renderer * 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
43 SDL_Texture * texture,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
44 SDL_Color * colors, int firstcolor,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
45 int ncolors);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
46 static int SDL_D3D_UpdateTexture(SDL_Renderer * 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
47 SDL_Texture * texture, const SDL_Rect * rect,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
48 const void *pixels, int pitch);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
49 static int SDL_D3D_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
50 const SDL_Rect * rect, int markDirty,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
51 void **pixels, int *pitch);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
52 static void SDL_D3D_UnlockTexture(SDL_Renderer * 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
53 SDL_Texture * texture);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
54 static void SDL_D3D_DirtyTexture(SDL_Renderer * 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
55 SDL_Texture * texture, int numrects,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
56 const SDL_Rect * rects);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
57 static void SDL_D3D_SelectRenderTexture(SDL_Renderer * 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
58 SDL_Texture * texture);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
59 static int SDL_D3D_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
60 Uint32 color);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
61 static int SDL_D3D_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
62 const SDL_Rect * srcrect,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
63 const SDL_Rect * dstrect, int blendMode,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
64 int scaleMode);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
65 static int SDL_D3D_RenderReadPixels(SDL_Renderer * 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
66 const SDL_Rect * rect, void *pixels,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
67 int pitch);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
68 static int SDL_D3D_RenderWritePixels(SDL_Renderer * 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
69 const SDL_Rect * rect,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
70 const void *pixels, int pitch);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
71 static void SDL_D3D_RenderPresent(SDL_Renderer * 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
72 static void SDL_D3D_DestroyTexture(SDL_Renderer * 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
73 SDL_Texture * texture);
c121d94672cb 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 static void SDL_D3D_DestroyRenderer(SDL_Renderer * 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
75
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
76
c121d94672cb 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 SDL_RenderDriver SDL_D3D_RenderDriver = {
c121d94672cb 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 SDL_D3D_CreateRenderer,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
79 {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
80 "d3d",
1900
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
81 ( //SDL_Renderer_Minimal |
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
82 SDL_Renderer_SingleBuffer | SDL_Renderer_PresentCopy |
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
83 SDL_Renderer_PresentFlip2 | SDL_Renderer_PresentFlip3 |
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
84 SDL_Renderer_PresentDiscard | SDL_Renderer_RenderTarget),
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
85 (SDL_TextureBlendMode_None |
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
86 SDL_TextureBlendMode_Mask | SDL_TextureBlendMode_Blend),
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
87 (SDL_TextureScaleMode_None | SDL_TextureScaleMode_Fast),
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
88 11,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
89 {
c121d94672cb 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 SDL_PixelFormat_Index8,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
91 SDL_PixelFormat_RGB555,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
92 SDL_PixelFormat_RGB565,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
93 SDL_PixelFormat_RGB888,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
94 SDL_PixelFormat_BGR888,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
95 SDL_PixelFormat_ARGB8888,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
96 SDL_PixelFormat_RGBA8888,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
97 SDL_PixelFormat_ABGR8888,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
98 SDL_PixelFormat_BGRA8888,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
99 SDL_PixelFormat_YUY2,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
100 SDL_PixelFormat_UYVY},
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
101 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
102 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
103 };
c121d94672cb 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
c121d94672cb 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 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
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 IDirect3DDevice9 *device;
1900
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
108 SDL_bool beginScene;
1895
c121d94672cb 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 } SDL_D3D_RenderData;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
110
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
111 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
112 {
c121d94672cb 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 SDL_SW_YUVTexture *yuv;
c121d94672cb 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 } SDL_D3D_TextureData;
c121d94672cb 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
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
116 static void
1900
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
117 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
118 {
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
119 const char *error;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
120
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
121 switch (result) {
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
122 case D3DERR_WRONGTEXTUREFORMAT:
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
123 error = "WRONGTEXTUREFORMAT";
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
124 break;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
125 case D3DERR_UNSUPPORTEDCOLOROPERATION:
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
126 error = "UNSUPPORTEDCOLOROPERATION";
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
127 break;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
128 case D3DERR_UNSUPPORTEDCOLORARG:
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
129 error = "UNSUPPORTEDCOLORARG";
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
130 break;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
131 case D3DERR_UNSUPPORTEDALPHAOPERATION:
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
132 error = "UNSUPPORTEDALPHAOPERATION";
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
133 break;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
134 case D3DERR_UNSUPPORTEDALPHAARG:
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
135 error = "UNSUPPORTEDALPHAARG";
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
136 break;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
137 case D3DERR_TOOMANYOPERATIONS:
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
138 error = "TOOMANYOPERATIONS";
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
139 break;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
140 case D3DERR_CONFLICTINGTEXTUREFILTER:
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
141 error = "CONFLICTINGTEXTUREFILTER";
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
142 break;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
143 case D3DERR_UNSUPPORTEDFACTORVALUE:
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
144 error = "UNSUPPORTEDFACTORVALUE";
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
145 break;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
146 case D3DERR_CONFLICTINGRENDERSTATE:
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
147 error = "CONFLICTINGRENDERSTATE";
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
148 break;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
149 case D3DERR_UNSUPPORTEDTEXTUREFILTER:
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
150 error = "UNSUPPORTEDTEXTUREFILTER";
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
151 break;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
152 case D3DERR_CONFLICTINGTEXTUREPALETTE:
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
153 error = "CONFLICTINGTEXTUREPALETTE";
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
154 break;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
155 case D3DERR_DRIVERINTERNALERROR:
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
156 error = "DRIVERINTERNALERROR";
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
157 break;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
158 case D3DERR_NOTFOUND:
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
159 error = "NOTFOUND";
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
160 break;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
161 case D3DERR_MOREDATA:
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
162 error = "MOREDATA";
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
163 break;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
164 case D3DERR_DEVICELOST:
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
165 error = "DEVICELOST";
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
166 break;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
167 case D3DERR_DEVICENOTRESET:
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
168 error = "DEVICENOTRESET";
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
169 break;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
170 case D3DERR_NOTAVAILABLE:
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
171 error = "NOTAVAILABLE";
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
172 break;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
173 case D3DERR_OUTOFVIDEOMEMORY:
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
174 error = "OUTOFVIDEOMEMORY";
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
175 break;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
176 case D3DERR_INVALIDDEVICE:
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
177 error = "INVALIDDEVICE";
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
178 break;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
179 case D3DERR_INVALIDCALL:
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
180 error = "INVALIDCALL";
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
181 break;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
182 case D3DERR_DRIVERINVALIDCALL:
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
183 error = "DRIVERINVALIDCALL";
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
184 break;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
185 case D3DERR_WASSTILLDRAWING:
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
186 error = "WASSTILLDRAWING";
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
187 break;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
188 default:
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
189 error = "UNKNOWN";
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
190 break;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
191 }
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
192 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
193 }
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
194
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
195 static void
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
196 UpdateYUVTextureData(SDL_Texture * texture)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
197 {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
198 SDL_D3D_TextureData *data = (SDL_D3D_TextureData *) texture->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
199 SDL_Rect rect;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
200
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
201 rect.x = 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
202 rect.y = 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
203 rect.w = texture->w;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
204 rect.h = texture->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
205 //SDL_SW_CopyYUVToRGB(data->yuv, &rect, data->format, texture->w,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
206 // texture->h, data->pixels, data->pitch);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
207 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
208
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
209 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
210 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
211 {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
212 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
213
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
214 if (data->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
215 SDL_AddRenderDriver(0, &SDL_D3D_RenderDriver);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
216 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
217 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
218
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
219 SDL_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
220 SDL_D3D_CreateRenderer(SDL_Window * window, Uint32 flags)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
221 {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
222 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
223 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
224 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
225 SDL_Renderer *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
226 SDL_D3D_RenderData *data;
1900
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
227 HRESULT result;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
228 D3DPRESENT_PARAMETERS pparams;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
229
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
230 renderer = (SDL_Renderer *) SDL_malloc(sizeof(*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
231 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
232 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
233 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
234 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
235 SDL_zerop(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
236
c121d94672cb 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 data = (SDL_D3D_RenderData *) SDL_malloc(sizeof(*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
238 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
239 SDL_D3D_DestroyRenderer(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
240 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
241 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
242 }
c121d94672cb 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 SDL_zerop(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
244
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
245 renderer->CreateTexture = SDL_D3D_CreateTexture;
c121d94672cb 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 renderer->QueryTexturePixels = SDL_D3D_QueryTexturePixels;
c121d94672cb 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 renderer->SetTexturePalette = SDL_D3D_SetTexturePalette;
c121d94672cb 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 renderer->GetTexturePalette = SDL_D3D_GetTexturePalette;
c121d94672cb 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 renderer->UpdateTexture = SDL_D3D_UpdateTexture;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
250 renderer->LockTexture = SDL_D3D_LockTexture;
c121d94672cb 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 renderer->UnlockTexture = SDL_D3D_UnlockTexture;
c121d94672cb 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 renderer->DirtyTexture = SDL_D3D_DirtyTexture;
c121d94672cb 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 renderer->SelectRenderTexture = SDL_D3D_SelectRenderTexture;
c121d94672cb 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 renderer->RenderFill = SDL_D3D_RenderFill;
c121d94672cb 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 renderer->RenderCopy = SDL_D3D_RenderCopy;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
256 renderer->RenderReadPixels = SDL_D3D_RenderReadPixels;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
257 renderer->RenderWritePixels = SDL_D3D_RenderWritePixels;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
258 renderer->RenderPresent = SDL_D3D_RenderPresent;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
259 renderer->DestroyTexture = SDL_D3D_DestroyTexture;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
260 renderer->DestroyRenderer = SDL_D3D_DestroyRenderer;
c121d94672cb 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 renderer->info = SDL_D3D_RenderDriver.info;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
262 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
263 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
264
c121d94672cb 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 renderer->info.flags = SDL_Renderer_RenderTarget;
c121d94672cb 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
1900
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
267 SDL_zero(pparams);
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
268 pparams.BackBufferWidth = window->w;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
269 pparams.BackBufferHeight = window->h;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
270 pparams.BackBufferFormat = D3DFMT_UNKNOWN; /* FIXME */
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
271 if (flags & SDL_Renderer_PresentFlip2) {
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
272 pparams.BackBufferCount = 2;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
273 pparams.SwapEffect = D3DSWAPEFFECT_FLIP;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
274 } else if (flags & SDL_Renderer_PresentFlip3) {
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
275 pparams.BackBufferCount = 3;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
276 pparams.SwapEffect = D3DSWAPEFFECT_FLIP;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
277 } else if (flags & SDL_Renderer_PresentCopy) {
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
278 pparams.BackBufferCount = 1;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
279 pparams.SwapEffect = D3DSWAPEFFECT_COPY;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
280 } else {
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
281 pparams.BackBufferCount = 1;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
282 pparams.SwapEffect = D3DSWAPEFFECT_DISCARD;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
283 }
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
284 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
285 pparams.Windowed = FALSE;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
286 } else {
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
287 pparams.Windowed = TRUE;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
288 }
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
289 pparams.FullScreen_RefreshRateInHz = 0; /* FIXME */
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
290 pparams.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
1900
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
291
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
292 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
293 D3DDEVTYPE_HAL,
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
294 windowdata->hwnd,
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
295 D3DCREATE_SOFTWARE_VERTEXPROCESSING,
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
296 &pparams, &data->device);
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
297 if (FAILED(result)) {
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
298 SDL_D3D_DestroyRenderer(renderer);
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
299 D3D_SetError("CreateDevice()", result);
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
300 return NULL;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
301 }
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
302 data->beginScene = SDL_TRUE;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
303
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
304 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
305 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
306
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
307 static int
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
308 SDL_D3D_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
309 {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
310 SDL_D3D_RenderData *renderdata =
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
311 (SDL_D3D_RenderData *) renderer->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
312 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
313 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
314 SDL_D3D_TextureData *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
315
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
316 data = (SDL_D3D_TextureData *) SDL_malloc(sizeof(*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
317 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
318 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
319 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
320 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
321 SDL_zerop(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
322
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
323 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
324
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
325 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
326 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
327
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
328 static int
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
329 SDL_D3D_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
330 void **pixels, int *pitch)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
331 {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
332 SDL_D3D_TextureData *data = (SDL_D3D_TextureData *) texture->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
333
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
334 if (data->yuv) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
335 return SDL_SW_QueryYUVTexturePixels(data->yuv, pixels, pitch);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
336 } else {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
337 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
338 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
339 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
340
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
341 static int
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
342 SDL_D3D_SetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
343 const SDL_Color * colors, int firstcolor,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
344 int ncolors)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
345 {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
346 SDL_D3D_RenderData *renderdata =
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
347 (SDL_D3D_RenderData *) renderer->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
348 SDL_D3D_TextureData *data = (SDL_D3D_TextureData *) texture->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
349
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
350 if (data->yuv) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
351 SDL_SetError("YUV textures don't have a palette");
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
352 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
353 } else {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
354 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
355 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
356 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
357
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
358 static int
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
359 SDL_D3D_GetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
360 SDL_Color * colors, int firstcolor, int ncolors)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
361 {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
362 SDL_D3D_TextureData *data = (SDL_D3D_TextureData *) texture->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
363
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
364 if (data->yuv) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
365 SDL_SetError("YUV textures don't have a palette");
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
366 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
367 } else {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
368 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
369 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
370 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
371
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
372 static int
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
373 SDL_D3D_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
374 const SDL_Rect * rect, const void *pixels, int pitch)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
375 {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
376 SDL_D3D_TextureData *data = (SDL_D3D_TextureData *) texture->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
377
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
378 if (data->yuv) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
379 if (SDL_SW_UpdateYUVTexture(data->yuv, rect, pixels, pitch) < 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
380 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
381 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
382 UpdateYUVTextureData(texture);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
383 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
384 } else {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
385 SDL_D3D_RenderData *renderdata =
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
386 (SDL_D3D_RenderData *) renderer->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
387
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
388 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
389 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
390 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
391
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
392 static int
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
393 SDL_D3D_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
394 const SDL_Rect * rect, int markDirty, void **pixels,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
395 int *pitch)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
396 {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
397 SDL_D3D_TextureData *data = (SDL_D3D_TextureData *) texture->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
398
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
399 if (data->yuv) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
400 return SDL_SW_LockYUVTexture(data->yuv, rect, markDirty, pixels,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
401 pitch);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
402 } else {
1900
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
403 return -1;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
404 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
405 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
406
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
407 static 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
408 SDL_D3D_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
409 {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
410 SDL_D3D_TextureData *data = (SDL_D3D_TextureData *) texture->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
411
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
412 if (data->yuv) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
413 SDL_SW_UnlockYUVTexture(data->yuv);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
414 UpdateYUVTextureData(texture);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
415 }
c121d94672cb 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 }
c121d94672cb 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 static 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
419 SDL_D3D_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
420 int numrects, const SDL_Rect * rects)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
421 {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
422 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
423
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
424 static 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
425 SDL_D3D_SelectRenderTexture(SDL_Renderer * renderer, SDL_Texture * texture)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
426 {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
427 SDL_D3D_RenderData *data = (SDL_D3D_RenderData *) renderer->driverdata;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
428 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
429
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
430 static int
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
431 SDL_D3D_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
432 Uint32 color)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
433 {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
434 SDL_D3D_RenderData *data = (SDL_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
435 D3DRECT d3drect;
1900
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
436 HRESULT result;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
437
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
438 if (data->beginScene) {
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
439 IDirect3DDevice9_BeginScene(data->device);
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
440 data->beginScene = SDL_FALSE;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
441 }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
442
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
443 d3drect.x1 = rect->x;
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
444 d3drect.x2 = rect->x+rect->w;
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
445 d3drect.y1 = rect->y;
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
446 d3drect.y2 = rect->y+rect->h;
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
447
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
448 result = IDirect3DDevice9_Clear(data->device, 1, &d3drect, D3DCLEAR_TARGET, (D3DCOLOR) color, 1.0f, 0);
1900
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
449 if (FAILED(result)) {
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
450 D3D_SetError("Clear()", result);
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
451 return -1;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
452 }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
453 return 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
454 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
455
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
456 static int
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
457 SDL_D3D_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
458 const SDL_Rect * srcrect, const SDL_Rect * dstrect,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
459 int blendMode, int scaleMode)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
460 {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
461 SDL_D3D_RenderData *data = (SDL_D3D_RenderData *) renderer->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
462 SDL_D3D_TextureData *texturedata =
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
463 (SDL_D3D_TextureData *) texture->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
464
1900
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
465 if (data->beginScene) {
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
466 IDirect3DDevice9_BeginScene(data->device);
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
467 data->beginScene = SDL_FALSE;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
468 }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
469 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
470 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
471
c121d94672cb 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 static int
c121d94672cb 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_D3D_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
c121d94672cb 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 void *pixels, int pitch)
c121d94672cb 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 SDL_D3D_RenderData *data = (SDL_D3D_RenderData *) renderer->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
477
c121d94672cb 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 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
479 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
480
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
481 static int
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
482 SDL_D3D_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
483 const void *pixels, int pitch)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
484 {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
485 SDL_D3D_RenderData *data = (SDL_D3D_RenderData *) renderer->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
486
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
487 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
488 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
489
c121d94672cb 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 static 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
491 SDL_D3D_RenderPresent(SDL_Renderer * 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
492 {
1900
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
493 SDL_D3D_RenderData *data = (SDL_D3D_RenderData *) renderer->driverdata;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
494 HRESULT result;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
495
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
496 if (!data->beginScene) {
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
497 IDirect3DDevice9_EndScene(data->device);
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
498 data->beginScene = SDL_TRUE;
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
499 }
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
500
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
501 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
502 if (FAILED(result)) {
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
503 D3D_SetError("Present()", result);
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
504 }
1895
c121d94672cb 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 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
506
c121d94672cb 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 static 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
508 SDL_D3D_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
c121d94672cb 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 SDL_D3D_TextureData *data = (SDL_D3D_TextureData *) texture->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
511
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
512 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
513 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
514 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
515 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
516 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
517 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
518
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
519 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
520 SDL_D3D_DestroyRenderer(SDL_Renderer * 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
521 {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
522 SDL_D3D_RenderData *data = (SDL_D3D_RenderData *) renderer->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
523
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
524 if (data) {
1900
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
525 if (data->device) {
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
526 IDirect3DDevice9_Release(data->device);
5c6bdbf3aadf First stab at a D3D renderer, only 30FPS so far... ?
Sam Lantinga <slouken@libsdl.org>
parents: 1898
diff changeset
527 }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
528 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
529 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
530 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
531 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
532
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
533 #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
534
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
535 /* vi: set ts=4 sw=4 expandtab: */