comparison src/video/SDL_renderer_sw.c @ 1706:1577404809f0 SDL-1.3

Added a multi-window version of testsprite using the new API.
author Sam Lantinga <slouken@libsdl.org>
date Sat, 24 Jun 2006 16:51:01 +0000
parents c4aa1a2f48f1
children a1ebb17f9c52
comparison
equal deleted inserted replaced
1705:fc731a7d83ed 1706:1577404809f0
109 } SDL_SW_RenderData; 109 } SDL_SW_RenderData;
110 110
111 SDL_Renderer * 111 SDL_Renderer *
112 SDL_SW_CreateRenderer(SDL_Window * window, Uint32 flags) 112 SDL_SW_CreateRenderer(SDL_Window * window, Uint32 flags)
113 { 113 {
114 SDL_DisplayMode *displayMode = &window->display->current_mode; 114 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
115 SDL_DisplayMode *displayMode = &display->current_mode;
115 SDL_Renderer *renderer; 116 SDL_Renderer *renderer;
116 SDL_SW_RenderData *data; 117 SDL_SW_RenderData *data;
117 int i, n; 118 int i, n;
118 int bpp; 119 int bpp;
119 Uint32 Rmask, Gmask, Bmask, Amask; 120 Uint32 Rmask, Gmask, Bmask, Amask;
154 renderer->RenderWritePixels = SDL_SW_RenderWritePixels; 155 renderer->RenderWritePixels = SDL_SW_RenderWritePixels;
155 renderer->RenderPresent = SDL_SW_RenderPresent; 156 renderer->RenderPresent = SDL_SW_RenderPresent;
156 renderer->DestroyTexture = SDL_SW_DestroyTexture; 157 renderer->DestroyTexture = SDL_SW_DestroyTexture;
157 renderer->DestroyRenderer = SDL_SW_DestroyRenderer; 158 renderer->DestroyRenderer = SDL_SW_DestroyRenderer;
158 renderer->info = SDL_SW_RenderDriver.info; 159 renderer->info = SDL_SW_RenderDriver.info;
159 renderer->window = window; 160 renderer->window = window->id;
160 renderer->driverdata = data; 161 renderer->driverdata = data;
161 162
162 renderer->info.flags = SDL_Renderer_RenderTarget; 163 renderer->info.flags = SDL_Renderer_RenderTarget;
163 164
164 if (flags & SDL_Renderer_PresentFlip2) { 165 if (flags & SDL_Renderer_PresentFlip2) {
177 Bmask, Amask); 178 Bmask, Amask);
178 if (!data->screens[i]) { 179 if (!data->screens[i]) {
179 SDL_SW_DestroyRenderer(renderer); 180 SDL_SW_DestroyRenderer(renderer);
180 return NULL; 181 return NULL;
181 } 182 }
182 SDL_SetSurfacePalette(data->screens[i], window->display->palette); 183 SDL_SetSurfacePalette(data->screens[i], display->palette);
183 } 184 }
184 data->current_screen = 0; 185 data->current_screen = 0;
185 data->target = data->screens[0]; 186 data->target = data->screens[0];
186 187
187 /* Find a render driver that we can use to display data */ 188 /* Find a render driver that we can use to display data */
188 for (i = 0; i < window->display->num_render_drivers; ++i) { 189 for (i = 0; i < display->num_render_drivers; ++i) {
189 SDL_RenderDriver *driver = &window->display->render_drivers[i]; 190 SDL_RenderDriver *driver = &display->render_drivers[i];
190 if (driver->info.name != SDL_SW_RenderDriver.info.name) { 191 if (driver->info.name != SDL_SW_RenderDriver.info.name) {
191 data->renderer = 192 data->renderer =
192 driver->CreateRenderer(window, SDL_Renderer_PresentDiscard); 193 driver->CreateRenderer(window, SDL_Renderer_PresentDiscard);
193 if (data->renderer) { 194 if (data->renderer) {
194 break; 195 break;
195 } 196 }
196 } 197 }
197 } 198 }
198 if (i == window->display->num_render_drivers) { 199 if (i == display->num_render_drivers) {
199 SDL_SW_DestroyRenderer(renderer); 200 SDL_SW_DestroyRenderer(renderer);
200 SDL_SetError("Couldn't find display render driver"); 201 SDL_SetError("Couldn't find display render driver");
201 return NULL; 202 return NULL;
202 } 203 }
203 return renderer; 204 return renderer;
375 SDL_SW_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, 376 SDL_SW_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
376 const SDL_Rect * srcrect, const SDL_Rect * dstrect, 377 const SDL_Rect * srcrect, const SDL_Rect * dstrect,
377 int blendMode, int scaleMode) 378 int blendMode, int scaleMode)
378 { 379 {
379 SDL_SW_RenderData *data = (SDL_SW_RenderData *) renderer->driverdata; 380 SDL_SW_RenderData *data = (SDL_SW_RenderData *) renderer->driverdata;
381 SDL_Window *window = SDL_GetWindowFromID(renderer->window);
382 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
380 383
381 if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) { 384 if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
382 SDL_Surface *target = data->target; 385 SDL_Surface *target = data->target;
383 void *pixels = 386 void *pixels =
384 (Uint8 *) target->pixels + dstrect->y * target->pitch + 387 (Uint8 *) target->pixels + dstrect->y * target->pitch +
385 dstrect->x * target->format->BytesPerPixel; 388 dstrect->x * target->format->BytesPerPixel;
386 return SDL_SW_CopyYUVToRGB((SDL_SW_YUVTexture *) texture->driverdata, 389 return SDL_SW_CopyYUVToRGB((SDL_SW_YUVTexture *) texture->driverdata,
387 srcrect, 390 srcrect, display->current_mode.format,
388 renderer->window->display->current_mode. 391 dstrect->w, dstrect->h, pixels,
389 format, dstrect->w, dstrect->h, pixels,
390 target->pitch); 392 target->pitch);
391 } else { 393 } else {
392 SDL_Surface *surface = (SDL_Surface *) texture->driverdata; 394 SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
393 SDL_Rect real_srcrect = *srcrect; 395 SDL_Rect real_srcrect = *srcrect;
394 SDL_Rect real_dstrect = *dstrect; 396 SDL_Rect real_dstrect = *dstrect;