comparison src/video/SDL_renderer_sw.c @ 1965:a788656ca29a

SDL constants are all uppercase.
author Sam Lantinga <slouken@libsdl.org>
date Sat, 05 Aug 2006 17:09:42 +0000
parents 9483df98e011
children db3ba6c0d0df
comparison
equal deleted inserted replaced
1964:071b6598d48f 1965:a788656ca29a
65 65
66 SDL_RenderDriver SW_RenderDriver = { 66 SDL_RenderDriver SW_RenderDriver = {
67 SW_CreateRenderer, 67 SW_CreateRenderer,
68 { 68 {
69 "software", 69 "software",
70 (SDL_Renderer_SingleBuffer | SDL_Renderer_PresentCopy | 70 (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY |
71 SDL_Renderer_PresentFlip2 | SDL_Renderer_PresentFlip3 | 71 SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 |
72 SDL_Renderer_PresentDiscard | SDL_Renderer_PresentVSync), 72 SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_PRESENTVSYNC),
73 (SDL_TextureBlendMode_None | SDL_TextureBlendMode_Mask | 73 (SDL_TEXTUREBLENDMODE_NONE | SDL_TEXTUREBLENDMODE_MASK |
74 SDL_TextureBlendMode_Blend), 74 SDL_TEXTUREBLENDMODE_BLEND),
75 (SDL_TextureScaleMode_None | SDL_TextureScaleMode_Fast), 75 (SDL_TEXTURESCALEMODE_NONE | SDL_TEXTURESCALEMODE_FAST),
76 11, 76 11,
77 { 77 {
78 SDL_PixelFormat_Index8, 78 SDL_PIXELFORMAT_INDEX8,
79 SDL_PixelFormat_RGB555, 79 SDL_PIXELFORMAT_RGB555,
80 SDL_PixelFormat_RGB565, 80 SDL_PIXELFORMAT_RGB565,
81 SDL_PixelFormat_RGB888, 81 SDL_PIXELFORMAT_RGB888,
82 SDL_PixelFormat_BGR888, 82 SDL_PIXELFORMAT_BGR888,
83 SDL_PixelFormat_ARGB8888, 83 SDL_PIXELFORMAT_ARGB8888,
84 SDL_PixelFormat_RGBA8888, 84 SDL_PIXELFORMAT_RGBA8888,
85 SDL_PixelFormat_ABGR8888, 85 SDL_PIXELFORMAT_ABGR8888,
86 SDL_PixelFormat_BGRA8888, 86 SDL_PIXELFORMAT_BGRA8888,
87 SDL_PixelFormat_YUY2, 87 SDL_PIXELFORMAT_YUY2,
88 SDL_PixelFormat_UYVY}, 88 SDL_PIXELFORMAT_UYVY},
89 0, 89 0,
90 0} 90 0}
91 }; 91 };
92 92
93 typedef struct 93 typedef struct
110 SDL_OutOfMemory(); 110 SDL_OutOfMemory();
111 return NULL; 111 return NULL;
112 } 112 }
113 113
114 texture->format = format; 114 texture->format = format;
115 texture->access = SDL_TextureAccess_Local; 115 texture->access = SDL_TEXTUREACCESS_LOCAL;
116 texture->w = w; 116 texture->w = w;
117 texture->h = h; 117 texture->h = h;
118 texture->renderer = renderer; 118 texture->renderer = renderer;
119 119
120 if (renderer->CreateTexture(renderer, texture) < 0) { 120 if (renderer->CreateTexture(renderer, texture) < 0) {
197 renderer->window = window->id; 197 renderer->window = window->id;
198 renderer->driverdata = data; 198 renderer->driverdata = data;
199 199
200 renderer->info.flags = 0; 200 renderer->info.flags = 0;
201 201
202 if (flags & SDL_Renderer_PresentFlip2) { 202 if (flags & SDL_RENDERER_PRESENTFLIP2) {
203 renderer->info.flags |= SDL_Renderer_PresentFlip2; 203 renderer->info.flags |= SDL_RENDERER_PRESENTFLIP2;
204 n = 2; 204 n = 2;
205 } else if (flags & SDL_Renderer_PresentFlip3) { 205 } else if (flags & SDL_RENDERER_PRESENTFLIP3) {
206 renderer->info.flags |= SDL_Renderer_PresentFlip3; 206 renderer->info.flags |= SDL_RENDERER_PRESENTFLIP3;
207 n = 3; 207 n = 3;
208 } else { 208 } else {
209 renderer->info.flags |= SDL_Renderer_PresentCopy; 209 renderer->info.flags |= SDL_RENDERER_PRESENTCOPY;
210 n = 1; 210 n = 1;
211 } 211 }
212 data->format = displayMode->format; 212 data->format = displayMode->format;
213 213
214 /* Find a render driver that we can use to display data */ 214 /* Find a render driver that we can use to display data */
215 renderer_flags = (SDL_Renderer_SingleBuffer | 215 renderer_flags = (SDL_RENDERER_SINGLEBUFFER |
216 SDL_Renderer_PresentDiscard); 216 SDL_RENDERER_PRESENTDISCARD);
217 if (flags & SDL_Renderer_PresentVSync) { 217 if (flags & SDL_RENDERER_PRESENTVSYNC) {
218 renderer_flags |= SDL_Renderer_PresentVSync; 218 renderer_flags |= SDL_RENDERER_PRESENTVSYNC;
219 } 219 }
220 desired_driver = SDL_getenv("SDL_VIDEO_RENDERER_SWDRIVER"); 220 desired_driver = SDL_getenv("SDL_VIDEO_RENDERER_SWDRIVER");
221 for (i = 0; i < display->num_render_drivers; ++i) { 221 for (i = 0; i < display->num_render_drivers; ++i) {
222 SDL_RenderDriver *driver = &display->render_drivers[i]; 222 SDL_RenderDriver *driver = &display->render_drivers[i];
223 if (driver->info.name == SW_RenderDriver.info.name) { 223 if (driver->info.name == SW_RenderDriver.info.name) {
235 if (i == display->num_render_drivers) { 235 if (i == display->num_render_drivers) {
236 SW_DestroyRenderer(renderer); 236 SW_DestroyRenderer(renderer);
237 SDL_SetError("Couldn't find display render driver"); 237 SDL_SetError("Couldn't find display render driver");
238 return NULL; 238 return NULL;
239 } 239 }
240 if (data->renderer->info.flags & SDL_Renderer_PresentVSync) { 240 if (data->renderer->info.flags & SDL_RENDERER_PRESENTVSYNC) {
241 renderer->info.flags |= SDL_Renderer_PresentVSync; 241 renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC;
242 } 242 }
243 243
244 /* Create the textures we'll use for display */ 244 /* Create the textures we'll use for display */
245 for (i = 0; i < n; ++i) { 245 for (i = 0; i < n; ++i) {
246 data->texture[i] = 246 data->texture[i] =
409 SW_RenderData *data = (SW_RenderData *) renderer->driverdata; 409 SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
410 Uint8 r, g, b, a; 410 Uint8 r, g, b, a;
411 SDL_Rect real_rect; 411 SDL_Rect real_rect;
412 int status; 412 int status;
413 413
414 if (data->renderer->info.flags & SDL_Renderer_PresentCopy) { 414 if (data->renderer->info.flags & SDL_RENDERER_PRESENTCOPY) {
415 SDL_AddDirtyRect(&data->dirty, rect); 415 SDL_AddDirtyRect(&data->dirty, rect);
416 } 416 }
417 417
418 a = (Uint8) ((color >> 24) & 0xFF); 418 a = (Uint8) ((color >> 24) & 0xFF);
419 r = (Uint8) ((color >> 16) & 0xFF); 419 r = (Uint8) ((color >> 16) & 0xFF);
447 { 447 {
448 SW_RenderData *data = (SW_RenderData *) renderer->driverdata; 448 SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
449 SDL_Window *window = SDL_GetWindowFromID(renderer->window); 449 SDL_Window *window = SDL_GetWindowFromID(renderer->window);
450 int status; 450 int status;
451 451
452 if (data->renderer->info.flags & SDL_Renderer_PresentCopy) { 452 if (data->renderer->info.flags & SDL_RENDERER_PRESENTCOPY) {
453 SDL_AddDirtyRect(&data->dirty, dstrect); 453 SDL_AddDirtyRect(&data->dirty, dstrect);
454 } 454 }
455 455
456 if (data->renderer-> 456 if (data->renderer->
457 LockTexture(data->renderer, data->texture[data->current_texture], 457 LockTexture(data->renderer, data->texture[data->current_texture],
475 data->surface.clip_rect.w = dstrect->w; 475 data->surface.clip_rect.w = dstrect->w;
476 data->surface.clip_rect.h = dstrect->h; 476 data->surface.clip_rect.h = dstrect->h;
477 real_dstrect = data->surface.clip_rect; 477 real_dstrect = data->surface.clip_rect;
478 478
479 if (blendMode & 479 if (blendMode &
480 (SDL_TextureBlendMode_Mask | SDL_TextureBlendMode_Blend)) { 480 (SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND)) {
481 SDL_SetAlpha(surface, SDL_SRCALPHA, 0); 481 SDL_SetAlpha(surface, SDL_SRCALPHA, 0);
482 } else { 482 } else {
483 SDL_SetAlpha(surface, 0, 0); 483 SDL_SetAlpha(surface, 0, 0);
484 } 484 }
485 if (scaleMode != SDL_TextureScaleMode_None && 485 if (scaleMode != SDL_TEXTURESCALEMODE_NONE &&
486 (srcrect->w != dstrect->w || srcrect->h != dstrect->h)) { 486 (srcrect->w != dstrect->w || srcrect->h != dstrect->h)) {
487 status = 487 status =
488 SDL_SoftStretch(surface, &real_srcrect, &data->surface, 488 SDL_SoftStretch(surface, &real_srcrect, &data->surface,
489 &real_dstrect); 489 &real_dstrect);
490 } else { 490 } else {
503 { 503 {
504 SW_RenderData *data = (SW_RenderData *) renderer->driverdata; 504 SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
505 SDL_Texture *texture = data->texture[data->current_texture]; 505 SDL_Texture *texture = data->texture[data->current_texture];
506 506
507 /* Send the data to the display */ 507 /* Send the data to the display */
508 if (data->renderer->info.flags & SDL_Renderer_PresentCopy) { 508 if (data->renderer->info.flags & SDL_RENDERER_PRESENTCOPY) {
509 SDL_DirtyRect *dirty; 509 SDL_DirtyRect *dirty;
510 for (dirty = data->dirty.list; dirty; dirty = dirty->next) { 510 for (dirty = data->dirty.list; dirty; dirty = dirty->next) {
511 data->renderer->RenderCopy(data->renderer, texture, &dirty->rect, 511 data->renderer->RenderCopy(data->renderer, texture, &dirty->rect,
512 &dirty->rect, 512 &dirty->rect,
513 SDL_TextureBlendMode_None, 513 SDL_TEXTUREBLENDMODE_NONE,
514 SDL_TextureScaleMode_None); 514 SDL_TEXTURESCALEMODE_NONE);
515 } 515 }
516 SDL_ClearDirtyRects(&data->dirty); 516 SDL_ClearDirtyRects(&data->dirty);
517 } else { 517 } else {
518 SDL_Rect rect; 518 SDL_Rect rect;
519 rect.x = 0; 519 rect.x = 0;
520 rect.y = 0; 520 rect.y = 0;
521 rect.w = texture->w; 521 rect.w = texture->w;
522 rect.h = texture->h; 522 rect.h = texture->h;
523 data->renderer->RenderCopy(data->renderer, texture, &rect, &rect, 523 data->renderer->RenderCopy(data->renderer, texture, &rect, &rect,
524 SDL_TextureBlendMode_None, 524 SDL_TEXTUREBLENDMODE_NONE,
525 SDL_TextureScaleMode_None); 525 SDL_TEXTURESCALEMODE_NONE);
526 } 526 }
527 data->renderer->RenderPresent(data->renderer); 527 data->renderer->RenderPresent(data->renderer);
528 528
529 /* Update the flipping chain, if any */ 529 /* Update the flipping chain, if any */
530 if (renderer->info.flags & SDL_Renderer_PresentFlip2) { 530 if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP2) {
531 data->current_texture = (data->current_texture + 1) % 2; 531 data->current_texture = (data->current_texture + 1) % 2;
532 } else if (renderer->info.flags & SDL_Renderer_PresentFlip3) { 532 } else if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP3) {
533 data->current_texture = (data->current_texture + 1) % 3; 533 data->current_texture = (data->current_texture + 1) % 3;
534 } 534 }
535 } 535 }
536 536
537 static void 537 static void