Mercurial > sdl-ios-xcode
annotate src/video/dummy/SDL_nullrender.c @ 1971:5432b63cc919
Added window resize support for the software renderer
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 06 Aug 2006 04:57:28 +0000 |
parents | a788656ca29a |
children | 8055185ae4ed |
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 #include "SDL_video.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
|
25 #include "../SDL_sysvideo.h" |
1908
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
26 #include "../SDL_yuv_sw_c.h" |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
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 |
c121d94672cb
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 /* SDL surface based 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 |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
31 static SDL_Renderer *SDL_DUMMY_CreateRenderer(SDL_Window * window, |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
32 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
|
33 static int SDL_DUMMY_CreateTexture(SDL_Renderer * renderer, |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
34 SDL_Texture * texture); |
1908
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
35 static int SDL_DUMMY_QueryTexturePixels(SDL_Renderer * renderer, |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
36 SDL_Texture * texture, void **pixels, |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
37 int *pitch); |
1908
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
38 static int SDL_DUMMY_SetTexturePalette(SDL_Renderer * renderer, |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
39 SDL_Texture * texture, |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
40 const SDL_Color * colors, |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
41 int firstcolor, int ncolors); |
1908
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
42 static int SDL_DUMMY_GetTexturePalette(SDL_Renderer * renderer, |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
43 SDL_Texture * texture, |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
44 SDL_Color * colors, int firstcolor, |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
45 int ncolors); |
1908
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
46 static int SDL_DUMMY_UpdateTexture(SDL_Renderer * renderer, |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
47 SDL_Texture * texture, |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
48 const SDL_Rect * rect, const void *pixels, |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
49 int pitch); |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
50 static int SDL_DUMMY_LockTexture(SDL_Renderer * renderer, |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
51 SDL_Texture * texture, const SDL_Rect * rect, |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
52 int markDirty, void **pixels, int *pitch); |
1908
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
53 static void SDL_DUMMY_UnlockTexture(SDL_Renderer * renderer, |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
54 SDL_Texture * texture); |
1908
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
55 static void SDL_DUMMY_DirtyTexture(SDL_Renderer * renderer, |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
56 SDL_Texture * texture, int numrects, |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
57 const SDL_Rect * rects); |
1908
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
58 static void SDL_DUMMY_SelectRenderTexture(SDL_Renderer * renderer, |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
59 SDL_Texture * texture); |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
60 static int SDL_DUMMY_RenderFill(SDL_Renderer * renderer, |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
61 const SDL_Rect * rect, Uint32 color); |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
62 static int SDL_DUMMY_RenderCopy(SDL_Renderer * renderer, |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
63 SDL_Texture * texture, |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
64 const SDL_Rect * srcrect, |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
65 const SDL_Rect * dstrect, int blendMode, |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
66 int scaleMode); |
1908
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
67 static int SDL_DUMMY_RenderReadPixels(SDL_Renderer * renderer, |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
68 const SDL_Rect * rect, void *pixels, |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
69 int pitch); |
1908
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
70 static int SDL_DUMMY_RenderWritePixels(SDL_Renderer * renderer, |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
71 const SDL_Rect * rect, |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
72 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
|
73 static void SDL_DUMMY_RenderPresent(SDL_Renderer * renderer); |
1908
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
74 static void SDL_DUMMY_DestroyTexture(SDL_Renderer * renderer, |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
75 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
|
76 static void SDL_DUMMY_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
|
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 |
c121d94672cb
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 SDL_RenderDriver SDL_DUMMY_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
|
80 SDL_DUMMY_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
|
81 { |
1906
0c49855a7a3e
Changed the name of the dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
82 "dummy", |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1912
diff
changeset
|
83 (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY | |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1912
diff
changeset
|
84 SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 | |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1912
diff
changeset
|
85 SDL_RENDERER_PRESENTDISCARD), |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1912
diff
changeset
|
86 (SDL_TEXTUREBLENDMODE_NONE | SDL_TEXTUREBLENDMODE_MASK | |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1912
diff
changeset
|
87 SDL_TEXTUREBLENDMODE_BLEND), |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1912
diff
changeset
|
88 (SDL_TEXTURESCALEMODE_NONE | SDL_TEXTURESCALEMODE_FAST), |
1908
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
89 11, |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
90 { |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1912
diff
changeset
|
91 SDL_PIXELFORMAT_INDEX8, |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1912
diff
changeset
|
92 SDL_PIXELFORMAT_RGB555, |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1912
diff
changeset
|
93 SDL_PIXELFORMAT_RGB565, |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1912
diff
changeset
|
94 SDL_PIXELFORMAT_RGB888, |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1912
diff
changeset
|
95 SDL_PIXELFORMAT_BGR888, |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1912
diff
changeset
|
96 SDL_PIXELFORMAT_ARGB8888, |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1912
diff
changeset
|
97 SDL_PIXELFORMAT_RGBA8888, |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1912
diff
changeset
|
98 SDL_PIXELFORMAT_ABGR8888, |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1912
diff
changeset
|
99 SDL_PIXELFORMAT_BGRA8888, |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1912
diff
changeset
|
100 SDL_PIXELFORMAT_YUY2, |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1912
diff
changeset
|
101 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
|
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 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 }; |
c121d94672cb
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 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
|
107 { |
1908
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
108 int current_screen; |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
109 SDL_Surface *screens[3]; |
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
|
110 } SDL_DUMMY_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
|
111 |
c121d94672cb
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 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
|
113 SDL_DUMMY_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
|
114 { |
c121d94672cb
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 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
|
116 SDL_DisplayMode *displayMode = &display->current_mode; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
117 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
|
118 SDL_DUMMY_RenderData *data; |
1908
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
119 int i, n; |
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
|
120 int bpp; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
121 Uint32 Rmask, Gmask, Bmask, Amask; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
122 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
123 if (!SDL_PixelFormatEnumToMasks |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
124 (displayMode->format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
125 SDL_SetError("Unknown display format"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
126 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
|
127 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
128 |
1908
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
129 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
|
130 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
|
131 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
|
132 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
|
133 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
134 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
135 data = (SDL_DUMMY_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
|
136 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
|
137 SDL_DUMMY_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
|
138 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
|
139 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
|
140 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
141 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
|
142 |
1908
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
143 renderer->CreateTexture = SDL_DUMMY_CreateTexture; |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
144 renderer->QueryTexturePixels = SDL_DUMMY_QueryTexturePixels; |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
145 renderer->SetTexturePalette = SDL_DUMMY_SetTexturePalette; |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
146 renderer->GetTexturePalette = SDL_DUMMY_GetTexturePalette; |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
147 renderer->UpdateTexture = SDL_DUMMY_UpdateTexture; |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
148 renderer->LockTexture = SDL_DUMMY_LockTexture; |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
149 renderer->UnlockTexture = SDL_DUMMY_UnlockTexture; |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
150 renderer->DirtyTexture = SDL_DUMMY_DirtyTexture; |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
151 renderer->RenderFill = SDL_DUMMY_RenderFill; |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
152 renderer->RenderCopy = SDL_DUMMY_RenderCopy; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
153 renderer->RenderPresent = SDL_DUMMY_RenderPresent; |
1908
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
154 renderer->DestroyTexture = SDL_DUMMY_DestroyTexture; |
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
|
155 renderer->DestroyRenderer = SDL_DUMMY_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
|
156 renderer->info = SDL_DUMMY_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
|
157 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
|
158 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
|
159 |
1908
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
160 renderer->info.flags = 0; |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
161 |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1912
diff
changeset
|
162 if (flags & SDL_RENDERER_PRESENTFLIP2) { |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1912
diff
changeset
|
163 renderer->info.flags |= SDL_RENDERER_PRESENTFLIP2; |
1908
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
164 n = 2; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1912
diff
changeset
|
165 } else if (flags & SDL_RENDERER_PRESENTFLIP3) { |
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1912
diff
changeset
|
166 renderer->info.flags |= SDL_RENDERER_PRESENTFLIP3; |
1908
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
167 n = 3; |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
168 } else { |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1912
diff
changeset
|
169 renderer->info.flags |= SDL_RENDERER_PRESENTCOPY; |
1908
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
170 n = 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
|
171 } |
1908
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
172 for (i = 0; i < n; ++i) { |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
173 data->screens[i] = |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
174 SDL_CreateRGBSurface(0, window->w, window->h, bpp, Rmask, Gmask, |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
175 Bmask, Amask); |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
176 if (!data->screens[i]) { |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
177 SDL_DUMMY_DestroyRenderer(renderer); |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
178 return NULL; |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
179 } |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
180 SDL_SetSurfacePalette(data->screens[i], display->palette); |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
181 } |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
182 data->current_screen = 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
|
183 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
184 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
|
185 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
186 |
1908
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
187 static int |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
188 SDL_DUMMY_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
189 { |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
190 if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) { |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
191 texture->driverdata = SDL_SW_CreateYUVTexture(texture); |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
192 } else { |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
193 int bpp; |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
194 Uint32 Rmask, Gmask, Bmask, Amask; |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
195 |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
196 if (!SDL_PixelFormatEnumToMasks |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
197 (texture->format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) { |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
198 SDL_SetError("Unknown texture format"); |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
199 return -1; |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
200 } |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
201 |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
202 texture->driverdata = |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
203 SDL_CreateRGBSurface(0, texture->w, texture->h, bpp, Rmask, Gmask, |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
204 Bmask, Amask); |
1908
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
205 } |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
206 |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
207 if (!texture->driverdata) { |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
208 return -1; |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
209 } |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
210 return 0; |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
211 } |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
212 |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
213 static int |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
214 SDL_DUMMY_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture, |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
215 void **pixels, int *pitch) |
1908
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
216 { |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
217 if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) { |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
218 return SDL_SW_QueryYUVTexturePixels((SDL_SW_YUVTexture *) texture-> |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
219 driverdata, pixels, pitch); |
1908
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
220 } else { |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
221 SDL_Surface *surface = (SDL_Surface *) texture->driverdata; |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
222 |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
223 *pixels = surface->pixels; |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
224 *pitch = surface->pitch; |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
225 return 0; |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
226 } |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
227 } |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
228 |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
229 static int |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
230 SDL_DUMMY_SetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture, |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
231 const SDL_Color * colors, int firstcolor, |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
232 int ncolors) |
1908
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
233 { |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
234 if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) { |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
235 SDL_SetError("YUV textures don't have a palette"); |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
236 return -1; |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
237 } else { |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
238 SDL_Surface *surface = (SDL_Surface *) texture->driverdata; |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
239 |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
240 return SDL_SetPaletteColors(surface->format->palette, colors, |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
241 firstcolor, ncolors); |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
242 } |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
243 } |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
244 |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
245 static int |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
246 SDL_DUMMY_GetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture, |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
247 SDL_Color * colors, int firstcolor, int ncolors) |
1908
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
248 { |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
249 if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) { |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
250 SDL_SetError("YUV textures don't have a palette"); |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
251 return -1; |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
252 } else { |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
253 SDL_Surface *surface = (SDL_Surface *) texture->driverdata; |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
254 |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
255 SDL_memcpy(colors, &surface->format->palette->colors[firstcolor], |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
256 ncolors * sizeof(*colors)); |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
257 return 0; |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
258 } |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
259 } |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
260 |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
261 static int |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
262 SDL_DUMMY_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
263 const SDL_Rect * rect, const void *pixels, int pitch) |
1908
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
264 { |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
265 if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) { |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
266 return SDL_SW_UpdateYUVTexture((SDL_SW_YUVTexture *) texture-> |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
267 driverdata, rect, pixels, pitch); |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
268 } else { |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
269 SDL_Surface *surface = (SDL_Surface *) texture->driverdata; |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
270 Uint8 *src, *dst; |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
271 int row; |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
272 size_t length; |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
273 |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
274 src = (Uint8 *) pixels; |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
275 dst = |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
276 (Uint8 *) surface->pixels + rect->y * surface->pitch + |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
277 rect->x * surface->format->BytesPerPixel; |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
278 length = rect->w * surface->format->BytesPerPixel; |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
279 for (row = 0; row < rect->h; ++row) { |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
280 SDL_memcpy(dst, src, length); |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
281 src += pitch; |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
282 dst += surface->pitch; |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
283 } |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
284 return 0; |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
285 } |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
286 } |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
287 |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
288 static int |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
289 SDL_DUMMY_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
290 const SDL_Rect * rect, int markDirty, void **pixels, |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
291 int *pitch) |
1908
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
292 { |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
293 if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) { |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
294 return SDL_SW_LockYUVTexture((SDL_SW_YUVTexture *) texture-> |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
295 driverdata, rect, markDirty, pixels, |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
296 pitch); |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
297 } else { |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
298 SDL_Surface *surface = (SDL_Surface *) texture->driverdata; |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
299 |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
300 *pixels = |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
301 (void *) ((Uint8 *) surface->pixels + rect->y * surface->pitch + |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
302 rect->x * surface->format->BytesPerPixel); |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
303 *pitch = surface->pitch; |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
304 return 0; |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
305 } |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
306 } |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
307 |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
308 static void |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
309 SDL_DUMMY_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture) |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
310 { |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
311 if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) { |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
312 SDL_SW_UnlockYUVTexture((SDL_SW_YUVTexture *) texture->driverdata); |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
313 } |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
314 } |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
315 |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
316 static void |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
317 SDL_DUMMY_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture, |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
318 int numrects, const SDL_Rect * rects) |
1908
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
319 { |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
320 } |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
321 |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
322 static int |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
323 SDL_DUMMY_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect, |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
324 Uint32 color) |
1908
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
325 { |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
326 SDL_DUMMY_RenderData *data = |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
327 (SDL_DUMMY_RenderData *) renderer->driverdata; |
1908
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
328 SDL_Surface *target = data->screens[data->current_screen]; |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
329 SDL_Rect real_rect = *rect; |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
330 Uint8 r, g, b, a; |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
331 |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
332 a = (Uint8) ((color >> 24) & 0xFF); |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
333 r = (Uint8) ((color >> 16) & 0xFF); |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
334 g = (Uint8) ((color >> 8) & 0xFF); |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
335 b = (Uint8) (color & 0xFF); |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
336 color = SDL_MapRGBA(target->format, r, g, b, a); |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
337 |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
338 return SDL_FillRect(target, &real_rect, color); |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
339 } |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
340 |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
341 static int |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
342 SDL_DUMMY_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
343 const SDL_Rect * srcrect, const SDL_Rect * dstrect, |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
344 int blendMode, int scaleMode) |
1908
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
345 { |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
346 SDL_DUMMY_RenderData *data = |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
347 (SDL_DUMMY_RenderData *) renderer->driverdata; |
1908
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
348 SDL_Window *window = SDL_GetWindowFromID(renderer->window); |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
349 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
350 |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
351 if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) { |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
352 SDL_Surface *target = data->screens[data->current_screen]; |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
353 void *pixels = |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
354 (Uint8 *) target->pixels + dstrect->y * target->pitch + |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
355 dstrect->x * target->format->BytesPerPixel; |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
356 return SDL_SW_CopyYUVToRGB((SDL_SW_YUVTexture *) texture->driverdata, |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
357 srcrect, display->current_mode.format, |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
358 dstrect->w, dstrect->h, pixels, |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
359 target->pitch); |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
360 } else { |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
361 SDL_Surface *surface = (SDL_Surface *) texture->driverdata; |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
362 SDL_Surface *target = data->screens[data->current_screen]; |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
363 SDL_Rect real_srcrect = *srcrect; |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
364 SDL_Rect real_dstrect = *dstrect; |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
365 |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
366 if (blendMode & |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1912
diff
changeset
|
367 (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND)) { |
1908
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
368 SDL_SetAlpha(surface, SDL_SRCALPHA, 0); |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
369 } else { |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
370 SDL_SetAlpha(surface, 0, 0); |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
371 } |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1912
diff
changeset
|
372 if (scaleMode != SDL_TEXTURESCALEMODE_NONE && |
1908
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
373 (srcrect->w != dstrect->w || srcrect->h != dstrect->h)) { |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
374 return SDL_SoftStretch(surface, &real_srcrect, target, |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
375 &real_dstrect); |
1908
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
376 } else { |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
377 return SDL_LowerBlit(surface, &real_srcrect, target, |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
378 &real_dstrect); |
1908
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
379 } |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
380 } |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
381 } |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
382 |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
383 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
|
384 SDL_DUMMY_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
|
385 { |
c121d94672cb
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 static int frame_number; |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
387 SDL_DUMMY_RenderData *data = |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
388 (SDL_DUMMY_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
|
389 |
1908
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
390 /* Send the data to the display */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
391 if (SDL_getenv("SDL_VIDEO_DUMMY_SAVE_FRAMES")) { |
c121d94672cb
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 char file[128]; |
c121d94672cb
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_snprintf(file, sizeof(file), "SDL_window%d-%8.8d.bmp", |
c121d94672cb
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 renderer->window, ++frame_number); |
1908
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
395 SDL_SaveBMP(data->screens[data->current_screen], file); |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
396 } |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
397 |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
398 /* Update the flipping chain, if any */ |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1912
diff
changeset
|
399 if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP2) { |
1908
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
400 data->current_screen = (data->current_screen + 1) % 2; |
1965
a788656ca29a
SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents:
1912
diff
changeset
|
401 } else if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP3) { |
1908
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
402 data->current_screen = (data->current_screen + 1) % 3; |
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
|
403 } |
c121d94672cb
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 |
1908
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
406 static void |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
407 SDL_DUMMY_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture) |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
408 { |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
409 if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) { |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
410 SDL_SW_DestroyYUVTexture((SDL_SW_YUVTexture *) texture->driverdata); |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
411 } else { |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
412 SDL_Surface *surface = (SDL_Surface *) texture->driverdata; |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
413 |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
414 SDL_FreeSurface(surface); |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
415 } |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
416 } |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
417 |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
418 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
|
419 SDL_DUMMY_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
|
420 { |
1912
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
421 SDL_DUMMY_RenderData *data = |
8d384b647307
Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents:
1908
diff
changeset
|
422 (SDL_DUMMY_RenderData *) renderer->driverdata; |
1908
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
423 int i; |
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
|
424 |
c121d94672cb
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 if (data) { |
1908
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
426 for (i = 0; i < SDL_arraysize(data->screens); ++i) { |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
427 if (data->screens[i]) { |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
428 SDL_FreeSurface(data->screens[i]); |
e079dafea2bf
Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
1907
diff
changeset
|
429 } |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
430 } |
c121d94672cb
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_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
|
432 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
433 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
|
434 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
435 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
436 /* vi: set ts=4 sw=4 expandtab: */ |