Mercurial > sdl-ios-xcode
annotate src/video/dummy/SDL_nullrender.c @ 1682:7ae8018b2e5d SDL-1.3
Default palette entries to white, instead of black.
More palettized video mode support...
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Fri, 16 Jun 2006 06:00:31 +0000 |
parents | 90bf530ced8e |
children | 396a35389351 |
rev | line source |
---|---|
1677
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 /* |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3 Copyright (C) 1997-2006 Sam Lantinga |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4 |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5 This library is free software; you can redistribute it and/or |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
7 License as published by the Free Software Foundation; either |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
9 |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
13 Lesser General Public License for more details. |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
14 |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
18 |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
19 Sam Lantinga |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
20 slouken@libsdl.org |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
21 */ |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
22 #include "SDL_config.h" |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
23 |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
24 #include "SDL_video.h" |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
25 #include "../SDL_sysvideo.h" |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
26 |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
27 |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
28 /* SDL surface based renderer implementation */ |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
29 |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
30 static SDL_Renderer *SDL_DUMMY_CreateRenderer(SDL_Window * window, |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
31 Uint32 flags); |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
32 static int SDL_DUMMY_CreateTexture(SDL_Renderer * renderer, |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
33 SDL_Texture * texture); |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
34 static int SDL_DUMMY_RenderReadPixels(SDL_Renderer * renderer, |
1682
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1678
diff
changeset
|
35 const SDL_Rect * rect, void *pixels, |
1677
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
36 int pitch); |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
37 static int SDL_DUMMY_RenderWritePixels(SDL_Renderer * renderer, |
1682
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1678
diff
changeset
|
38 const SDL_Rect * rect, |
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1678
diff
changeset
|
39 const void *pixels, int pitch); |
1677
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
40 static void SDL_DUMMY_RenderPresent(SDL_Renderer * renderer); |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
41 static void SDL_DUMMY_DestroyRenderer(SDL_Renderer * renderer); |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
42 |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
43 |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
44 SDL_RenderDriver SDL_DUMMY_RenderDriver = { |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
45 SDL_DUMMY_CreateRenderer, |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
46 { |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
47 "minimal", |
1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1677
diff
changeset
|
48 (SDL_Renderer_Minimal | SDL_Renderer_PresentDiscard | |
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1677
diff
changeset
|
49 SDL_Renderer_PresentCopy), |
1677
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
50 SDL_TextureBlendMode_None, |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
51 SDL_TextureScaleMode_None, |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
52 0, |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
53 {}, |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
54 0, |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
55 0} |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
56 }; |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
57 |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
58 typedef struct |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
59 { |
1682
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1678
diff
changeset
|
60 SDL_Surface *surface; |
1677
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
61 } SDL_DUMMY_RenderData; |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
62 |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
63 SDL_Renderer * |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
64 SDL_DUMMY_CreateRenderer(SDL_Window * window, Uint32 flags) |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
65 { |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
66 SDL_DisplayMode *displayMode = &window->display->current_mode; |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
67 SDL_Renderer *renderer; |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
68 SDL_DUMMY_RenderData *data; |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
69 int i, n; |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
70 int bpp; |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
71 Uint32 Rmask, Gmask, Bmask, Amask; |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
72 |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
73 if (!SDL_PixelFormatEnumToMasks |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
74 (displayMode->format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) { |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
75 SDL_SetError("Unknown display format"); |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
76 return NULL; |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
77 } |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
78 |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
79 renderer = (SDL_Renderer *) SDL_malloc(sizeof(*renderer)); |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
80 if (!renderer) { |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
81 SDL_OutOfMemory(); |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
82 return NULL; |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
83 } |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
84 SDL_zerop(renderer); |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
85 |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
86 data = (SDL_DUMMY_RenderData *) SDL_malloc(sizeof(*data)); |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
87 if (!data) { |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
88 SDL_DUMMY_DestroyRenderer(renderer); |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
89 SDL_OutOfMemory(); |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
90 return NULL; |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
91 } |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
92 SDL_zerop(data); |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
93 |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
94 renderer->RenderReadPixels = SDL_DUMMY_RenderReadPixels; |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
95 renderer->RenderWritePixels = SDL_DUMMY_RenderWritePixels; |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
96 renderer->RenderPresent = SDL_DUMMY_RenderPresent; |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
97 renderer->DestroyRenderer = SDL_DUMMY_DestroyRenderer; |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
98 renderer->info = SDL_DUMMY_RenderDriver.info; |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
99 renderer->window = window; |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
100 renderer->driverdata = data; |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
101 |
1682
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1678
diff
changeset
|
102 data->surface = |
1677
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
103 SDL_CreateRGBSurface(0, window->w, window->h, bpp, Rmask, Gmask, |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
104 Bmask, Amask); |
1682
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1678
diff
changeset
|
105 if (!data->surface) { |
1677
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
106 SDL_DUMMY_DestroyRenderer(renderer); |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
107 return NULL; |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
108 } |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
109 |
1682
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1678
diff
changeset
|
110 /* If the display has a palette, use it for the window surfaces */ |
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1678
diff
changeset
|
111 if (window->display->palette.ncolors) { |
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1678
diff
changeset
|
112 SDL_PixelFormat *format = data->surface->format; |
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1678
diff
changeset
|
113 if (format->palette->colors) { |
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1678
diff
changeset
|
114 SDL_free(format->palette->colors); |
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1678
diff
changeset
|
115 } |
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1678
diff
changeset
|
116 SDL_free(format->palette); |
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1678
diff
changeset
|
117 format->palette = &window->display->palette; |
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1678
diff
changeset
|
118 } |
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1678
diff
changeset
|
119 |
1677
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
120 return renderer; |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
121 } |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
122 |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
123 int |
1682
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1678
diff
changeset
|
124 SDL_DUMMY_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, |
1677
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
125 void *pixels, int pitch) |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
126 { |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
127 SDL_DUMMY_RenderData *data = |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
128 (SDL_DUMMY_RenderData *) renderer->driverdata; |
1682
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1678
diff
changeset
|
129 SDL_Surface *surface = data->surface; |
1677
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
130 Uint8 *src, *dst; |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
131 int row; |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
132 size_t length; |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
133 |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
134 src = |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
135 (Uint8 *) surface->pixels + rect->y * surface->pitch + |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
136 rect->x * surface->format->BytesPerPixel; |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
137 dst = (Uint8 *) pixels; |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
138 length = rect->w * surface->format->BytesPerPixel; |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
139 for (row = 0; row < rect->h; ++row) { |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
140 SDL_memcpy(dst, src, length); |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
141 src += surface->pitch; |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
142 dst += pitch; |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
143 } |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
144 return 0; |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
145 } |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
146 |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
147 int |
1682
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1678
diff
changeset
|
148 SDL_DUMMY_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect, |
1677
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
149 const void *pixels, int pitch) |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
150 { |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
151 SDL_DUMMY_RenderData *data = |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
152 (SDL_DUMMY_RenderData *) renderer->driverdata; |
1682
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1678
diff
changeset
|
153 SDL_Surface *surface = data->surface; |
1677
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
154 Uint8 *src, *dst; |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
155 int row; |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
156 size_t length; |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
157 |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
158 src = (Uint8 *) pixels; |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
159 dst = |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
160 (Uint8 *) surface->pixels + rect->y * surface->pitch + |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
161 rect->x * surface->format->BytesPerPixel; |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
162 length = rect->w * surface->format->BytesPerPixel; |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
163 for (row = 0; row < rect->h; ++row) { |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
164 SDL_memcpy(dst, src, length); |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
165 src += pitch; |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
166 dst += surface->pitch; |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
167 } |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
168 return 0; |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
169 } |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
170 |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
171 void |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
172 SDL_DUMMY_RenderPresent(SDL_Renderer * renderer) |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
173 { |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
174 static int frame_number; |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
175 SDL_DUMMY_RenderData *data = |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
176 (SDL_DUMMY_RenderData *) renderer->driverdata; |
1682
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1678
diff
changeset
|
177 SDL_Surface *surface = data->surface; |
1677
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
178 |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
179 if (SDL_getenv("SDL_VIDEO_DUMMY_SAVE_FRAMES")) { |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
180 char file[128]; |
1678
90bf530ced8e
SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents:
1677
diff
changeset
|
181 SDL_snprintf(file, sizeof(file), "SDL_frame-%8.8d.bmp", |
1677
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
182 ++frame_number); |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
183 SDL_SaveBMP(surface, file); |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
184 } |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
185 } |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
186 |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
187 void |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
188 SDL_DUMMY_DestroyRenderer(SDL_Renderer * renderer) |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
189 { |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
190 SDL_DUMMY_RenderData *data = |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
191 (SDL_DUMMY_RenderData *) renderer->driverdata; |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
192 |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
193 if (data) { |
1682
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1678
diff
changeset
|
194 if (data->surface) { |
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1678
diff
changeset
|
195 data->surface->format->palette = NULL; |
7ae8018b2e5d
Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents:
1678
diff
changeset
|
196 SDL_FreeSurface(data->surface); |
1677
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
197 } |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
198 SDL_free(data); |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
199 } |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
200 SDL_free(renderer); |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
201 } |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
202 |
5e4c5e095925
Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
203 /* vi: set ts=4 sw=4 expandtab: */ |