annotate src/video/dummy/SDL_nullrender.c @ 1720:a1ebb17f9c52 SDL-1.3

Cleaned up a bunch of warnings, started adding Win32 event support
author Sam Lantinga <slouken@libsdl.org>
date Fri, 30 Jun 2006 05:42:49 +0000
parents 1577404809f0
children
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,
1720
a1ebb17f9c52 Cleaned up a bunch of warnings, started adding Win32 event support
Sam Lantinga <slouken@libsdl.org>
parents: 1706
diff changeset
53 {0},
1677
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 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;
1706
1577404809f0 Added a multi-window version of testsprite using the new API.
Sam Lantinga <slouken@libsdl.org>
parents: 1683
diff changeset
99 renderer->window = window->id;
1677
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 }
1706
1577404809f0 Added a multi-window version of testsprite using the new API.
Sam Lantinga <slouken@libsdl.org>
parents: 1683
diff changeset
109 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
110
1677
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
111 return renderer;
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
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
114 int
1682
7ae8018b2e5d Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents: 1678
diff changeset
115 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
116 void *pixels, int pitch)
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
117 {
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
118 SDL_DUMMY_RenderData *data =
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
119 (SDL_DUMMY_RenderData *) renderer->driverdata;
1682
7ae8018b2e5d Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents: 1678
diff changeset
120 SDL_Surface *surface = data->surface;
1677
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
121 Uint8 *src, *dst;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
122 int row;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
123 size_t length;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
124
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
125 src =
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
126 (Uint8 *) surface->pixels + rect->y * surface->pitch +
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
127 rect->x * surface->format->BytesPerPixel;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
128 dst = (Uint8 *) pixels;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
129 length = rect->w * surface->format->BytesPerPixel;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
130 for (row = 0; row < rect->h; ++row) {
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
131 SDL_memcpy(dst, src, length);
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
132 src += surface->pitch;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
133 dst += pitch;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
134 }
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
135 return 0;
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
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
138 int
1682
7ae8018b2e5d Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents: 1678
diff changeset
139 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
140 const void *pixels, int pitch)
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
141 {
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
142 SDL_DUMMY_RenderData *data =
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
143 (SDL_DUMMY_RenderData *) renderer->driverdata;
1682
7ae8018b2e5d Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents: 1678
diff changeset
144 SDL_Surface *surface = data->surface;
1677
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
145 Uint8 *src, *dst;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
146 int row;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
147 size_t length;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
148
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
149 src = (Uint8 *) pixels;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
150 dst =
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
151 (Uint8 *) surface->pixels + rect->y * surface->pitch +
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
152 rect->x * surface->format->BytesPerPixel;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
153 length = rect->w * surface->format->BytesPerPixel;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
154 for (row = 0; row < rect->h; ++row) {
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
155 SDL_memcpy(dst, src, length);
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
156 src += pitch;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
157 dst += surface->pitch;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
158 }
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
159 return 0;
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
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
162 void
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
163 SDL_DUMMY_RenderPresent(SDL_Renderer * renderer)
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
164 {
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
165 static int frame_number;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
166 SDL_DUMMY_RenderData *data =
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
167 (SDL_DUMMY_RenderData *) renderer->driverdata;
1682
7ae8018b2e5d Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents: 1678
diff changeset
168 SDL_Surface *surface = data->surface;
1677
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 if (SDL_getenv("SDL_VIDEO_DUMMY_SAVE_FRAMES")) {
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
171 char file[128];
1683
396a35389351 Finished palettized display handling.
Sam Lantinga <slouken@libsdl.org>
parents: 1682
diff changeset
172 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
173 renderer->window, ++frame_number);
1677
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
174 SDL_SaveBMP(surface, file);
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
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
178 void
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
179 SDL_DUMMY_DestroyRenderer(SDL_Renderer * renderer)
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
180 {
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
181 SDL_DUMMY_RenderData *data =
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
182 (SDL_DUMMY_RenderData *) renderer->driverdata;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
183
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
184 if (data) {
1682
7ae8018b2e5d Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents: 1678
diff changeset
185 if (data->surface) {
7ae8018b2e5d Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents: 1678
diff changeset
186 data->surface->format->palette = NULL;
7ae8018b2e5d Default palette entries to white, instead of black.
Sam Lantinga <slouken@libsdl.org>
parents: 1678
diff changeset
187 SDL_FreeSurface(data->surface);
1677
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(data);
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 SDL_free(renderer);
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
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
194 /* vi: set ts=4 sw=4 expandtab: */