annotate src/video/dummy/SDL_nullrender.c @ 1678:90bf530ced8e SDL-1.3

SDL_SetVideoMode() compiles now...
author Sam Lantinga <slouken@libsdl.org>
date Wed, 14 Jun 2006 06:14:26 +0000
parents 5e4c5e095925
children 7ae8018b2e5d
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,
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
35 SDL_Rect * rect, void *pixels,
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,
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
38 SDL_Rect * rect, const void *pixels,
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
39 int pitch);
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 {
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
60 SDL_Surface *screen;
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
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
102 data->screen =
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);
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
105 if (!data->screen) {
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
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
110 return renderer;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
111 }
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
112
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
113 int
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
114 SDL_DUMMY_RenderReadPixels(SDL_Renderer * renderer, SDL_Rect * rect,
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
115 void *pixels, int pitch)
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
116 {
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
117 SDL_DUMMY_RenderData *data =
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
118 (SDL_DUMMY_RenderData *) renderer->driverdata;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
119 SDL_Surface *surface = data->screen;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
120 Uint8 *src, *dst;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
121 int row;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
122 size_t length;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
123
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
124 src =
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
125 (Uint8 *) surface->pixels + rect->y * surface->pitch +
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
126 rect->x * surface->format->BytesPerPixel;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
127 dst = (Uint8 *) pixels;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
128 length = rect->w * surface->format->BytesPerPixel;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
129 for (row = 0; row < rect->h; ++row) {
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
130 SDL_memcpy(dst, src, length);
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
131 src += surface->pitch;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
132 dst += pitch;
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 return 0;
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
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
137 int
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
138 SDL_DUMMY_RenderWritePixels(SDL_Renderer * renderer, SDL_Rect * rect,
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
139 const void *pixels, int pitch)
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
140 {
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
141 SDL_DUMMY_RenderData *data =
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
142 (SDL_DUMMY_RenderData *) renderer->driverdata;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
143 SDL_Surface *surface = data->screen;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
144 Uint8 *src, *dst;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
145 int row;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
146 size_t length;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
147
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
148 src = (Uint8 *) pixels;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
149 dst =
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
150 (Uint8 *) surface->pixels + rect->y * surface->pitch +
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
151 rect->x * surface->format->BytesPerPixel;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
152 length = rect->w * surface->format->BytesPerPixel;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
153 for (row = 0; row < rect->h; ++row) {
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
154 SDL_memcpy(dst, src, length);
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
155 src += pitch;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
156 dst += surface->pitch;
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 return 0;
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
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
161 void
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
162 SDL_DUMMY_RenderPresent(SDL_Renderer * renderer)
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
163 {
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
164 static int frame_number;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
165 SDL_DUMMY_RenderData *data =
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
166 (SDL_DUMMY_RenderData *) renderer->driverdata;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
167 SDL_Surface *surface = data->screen;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
168
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
169 if (SDL_getenv("SDL_VIDEO_DUMMY_SAVE_FRAMES")) {
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
170 char file[128];
1678
90bf530ced8e SDL_SetVideoMode() compiles now...
Sam Lantinga <slouken@libsdl.org>
parents: 1677
diff changeset
171 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
172 ++frame_number);
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
173 SDL_SaveBMP(surface, file);
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
174 }
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
175 }
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 void
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
178 SDL_DUMMY_DestroyRenderer(SDL_Renderer * renderer)
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
179 {
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
180 SDL_DUMMY_RenderData *data =
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
181 (SDL_DUMMY_RenderData *) renderer->driverdata;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
182
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
183 if (data) {
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
184 if (data->screen) {
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
185 SDL_FreeSurface(data->screen);
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 SDL_free(data);
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
188 }
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
189 SDL_free(renderer);
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
190 }
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 /* vi: set ts=4 sw=4 expandtab: */