annotate src/video/dummy/SDL_nullrender.c @ 1718:ed4d4f1ea201 SDL-1.3

Further progress on the new Windows video driver: * SDL_SetModuleHandle() is obsolete, I hope. * SDL 1.3 uses the UNICODE API * I'm ignoring Windows CE for the moment, we'll reevaluate what needs to be different for Windows CE later. * Pulled the stdio redirection from WinMain()
author Sam Lantinga <slouken@libsdl.org>
date Tue, 27 Jun 2006 07:46:36 +0000
parents 1577404809f0
children a1ebb17f9c52
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 {
1706
1577404809f0 Added a multi-window version of testsprite using the new API.
Sam Lantinga <slouken@libsdl.org>
parents: 1683
diff changeset
66 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
1577404809f0 Added a multi-window version of testsprite using the new API.
Sam Lantinga <slouken@libsdl.org>
parents: 1683
diff changeset
67 SDL_DisplayMode *displayMode = &display->current_mode;
1677
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
68 SDL_Renderer *renderer;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
69 SDL_DUMMY_RenderData *data;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
70 int i, n;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
71 int bpp;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
72 Uint32 Rmask, Gmask, Bmask, Amask;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
73
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
74 if (!SDL_PixelFormatEnumToMasks
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
75 (displayMode->format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) {
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
76 SDL_SetError("Unknown display format");
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
77 return NULL;
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
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
80 renderer = (SDL_Renderer *) SDL_malloc(sizeof(*renderer));
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
81 if (!renderer) {
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
82 SDL_OutOfMemory();
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
83 return NULL;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
84 }
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
85 SDL_zerop(renderer);
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
86
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
87 data = (SDL_DUMMY_RenderData *) SDL_malloc(sizeof(*data));
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
88 if (!data) {
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
89 SDL_DUMMY_DestroyRenderer(renderer);
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
90 SDL_OutOfMemory();
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
91 return NULL;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
92 }
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
93 SDL_zerop(data);
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
94
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
95 renderer->RenderReadPixels = SDL_DUMMY_RenderReadPixels;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
96 renderer->RenderWritePixels = SDL_DUMMY_RenderWritePixels;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
97 renderer->RenderPresent = SDL_DUMMY_RenderPresent;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
98 renderer->DestroyRenderer = SDL_DUMMY_DestroyRenderer;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
99 renderer->info = SDL_DUMMY_RenderDriver.info;
1706
1577404809f0 Added a multi-window version of testsprite using the new API.
Sam Lantinga <slouken@libsdl.org>
parents: 1683
diff changeset
100 renderer->window = window->id;
1677
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
101 renderer->driverdata = data;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
102
1682
7ae8018b2e5d Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents: 1678
diff changeset
103 data->surface =
1677
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
104 SDL_CreateRGBSurface(0, window->w, window->h, bpp, Rmask, Gmask,
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
105 Bmask, Amask);
1682
7ae8018b2e5d Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents: 1678
diff changeset
106 if (!data->surface) {
1677
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
107 SDL_DUMMY_DestroyRenderer(renderer);
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
108 return NULL;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
109 }
1706
1577404809f0 Added a multi-window version of testsprite using the new API.
Sam Lantinga <slouken@libsdl.org>
parents: 1683
diff changeset
110 SDL_SetSurfacePalette(data->surface, display->palette);
1682
7ae8018b2e5d Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents: 1678
diff changeset
111
1677
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
112 return renderer;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
113 }
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
114
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
115 int
1682
7ae8018b2e5d Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents: 1678
diff changeset
116 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
117 void *pixels, int pitch)
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
118 {
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
119 SDL_DUMMY_RenderData *data =
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
120 (SDL_DUMMY_RenderData *) renderer->driverdata;
1682
7ae8018b2e5d Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents: 1678
diff changeset
121 SDL_Surface *surface = data->surface;
1677
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
122 Uint8 *src, *dst;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
123 int row;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
124 size_t length;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
125
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
126 src =
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
127 (Uint8 *) surface->pixels + rect->y * surface->pitch +
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
128 rect->x * surface->format->BytesPerPixel;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
129 dst = (Uint8 *) pixels;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
130 length = rect->w * surface->format->BytesPerPixel;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
131 for (row = 0; row < rect->h; ++row) {
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
132 SDL_memcpy(dst, src, length);
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
133 src += surface->pitch;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
134 dst += pitch;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
135 }
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
136 return 0;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
137 }
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
138
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
139 int
1682
7ae8018b2e5d Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents: 1678
diff changeset
140 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
141 const void *pixels, int pitch)
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
142 {
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
143 SDL_DUMMY_RenderData *data =
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
144 (SDL_DUMMY_RenderData *) renderer->driverdata;
1682
7ae8018b2e5d Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents: 1678
diff changeset
145 SDL_Surface *surface = data->surface;
1677
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
146 Uint8 *src, *dst;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
147 int row;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
148 size_t length;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
149
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
150 src = (Uint8 *) pixels;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
151 dst =
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
152 (Uint8 *) surface->pixels + rect->y * surface->pitch +
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
153 rect->x * surface->format->BytesPerPixel;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
154 length = rect->w * surface->format->BytesPerPixel;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
155 for (row = 0; row < rect->h; ++row) {
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
156 SDL_memcpy(dst, src, length);
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
157 src += pitch;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
158 dst += surface->pitch;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
159 }
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
160 return 0;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
161 }
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
162
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
163 void
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
164 SDL_DUMMY_RenderPresent(SDL_Renderer * renderer)
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
165 {
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
166 static int frame_number;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
167 SDL_DUMMY_RenderData *data =
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
168 (SDL_DUMMY_RenderData *) renderer->driverdata;
1682
7ae8018b2e5d Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents: 1678
diff changeset
169 SDL_Surface *surface = data->surface;
1677
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 if (SDL_getenv("SDL_VIDEO_DUMMY_SAVE_FRAMES")) {
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
172 char file[128];
1683
396a35389351 Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents: 1682
diff changeset
173 SDL_snprintf(file, sizeof(file), "SDL_window%d-%8.8d.bmp",
1706
1577404809f0 Added a multi-window version of testsprite using the new API.
Sam Lantinga <slouken@libsdl.org>
parents: 1683
diff changeset
174 renderer->window, ++frame_number);
1677
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
175 SDL_SaveBMP(surface, file);
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
176 }
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
177 }
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 void
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
180 SDL_DUMMY_DestroyRenderer(SDL_Renderer * renderer)
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
181 {
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
182 SDL_DUMMY_RenderData *data =
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
183 (SDL_DUMMY_RenderData *) renderer->driverdata;
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 if (data) {
1682
7ae8018b2e5d Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents: 1678
diff changeset
186 if (data->surface) {
7ae8018b2e5d Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents: 1678
diff changeset
187 data->surface->format->palette = NULL;
7ae8018b2e5d Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents: 1678
diff changeset
188 SDL_FreeSurface(data->surface);
1677
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_free(data);
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
191 }
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
192 SDL_free(renderer);
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
193 }
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
194
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
195 /* vi: set ts=4 sw=4 expandtab: */