comparison src/video/SDL_renderer_sw.c @ 2884:9dde605c7540

Date: Fri, 19 Dec 2008 20:17:35 +0100 From: Couriersud Subject: Re: Aw: Experience using SDL1.3 in sdlmame/Proposal for api additions > For consistency you'd probably want: > SDL_SetRenderDrawColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a); > SDL_SetRenderDrawBlendMode(SDL_BlendMode blendMode); > SDL_RenderLine(int x1, int y1, int x2, int y2); > SDL_RenderFill(SDL_Rect *rect); > > You probably also want to add API functions query the current state. > I have implemented the above api for the opengl, x11, directfb and software renderers. I have also renamed *TEXTUREBLENDMODE* constants to BLENDMODE*. The unix build compiles. The windows renderer still needs to be updated, but I have no windows development machine at hand. Have a look at the x11 renderer for a sample. Vector games now run at 90% both on opengl and directfb in comparison to sdlmame's own opengl renderer. The same applies to raster games. The diff also includes a) Changed XDrawRect to XFillRect in x11 renderer b) A number of changes to fix blending and modulation issues in the directfb renderer.
author Sam Lantinga <slouken@libsdl.org>
date Sat, 20 Dec 2008 12:00:00 +0000
parents 99210400e8b9
children 32e8bbba1e94
comparison
equal deleted inserted replaced
2883:11626a53e7bc 2884:9dde605c7540
57 int pitch); 57 int pitch);
58 static int SW_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, 58 static int SW_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
59 const SDL_Rect * rect, int markDirty, void **pixels, 59 const SDL_Rect * rect, int markDirty, void **pixels,
60 int *pitch); 60 int *pitch);
61 static void SW_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture); 61 static void SW_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
62 static int SW_RenderFill(SDL_Renderer * renderer, Uint8 r, Uint8 g, Uint8 b, 62 static int SW_SetDrawColor(SDL_Renderer * renderer);
63 Uint8 a, const SDL_Rect * rect); 63 static int SW_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect);
64 static int SW_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, 64 static int SW_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
65 const SDL_Rect * srcrect, const SDL_Rect * dstrect); 65 const SDL_Rect * srcrect, const SDL_Rect * dstrect);
66 static void SW_RenderPresent(SDL_Renderer * renderer); 66 static void SW_RenderPresent(SDL_Renderer * renderer);
67 static void SW_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture); 67 static void SW_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture);
68 static void SW_DestroyRenderer(SDL_Renderer * renderer); 68 static void SW_DestroyRenderer(SDL_Renderer * renderer);
75 (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY | 75 (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY |
76 SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 | 76 SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 |
77 SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_PRESENTVSYNC), 77 SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_PRESENTVSYNC),
78 (SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_COLOR | 78 (SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_COLOR |
79 SDL_TEXTUREMODULATE_ALPHA), 79 SDL_TEXTUREMODULATE_ALPHA),
80 (SDL_TEXTUREBLENDMODE_NONE | SDL_TEXTUREBLENDMODE_MASK | 80 (SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK |
81 SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | 81 SDL_BLENDMODE_BLEND | SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD),
82 SDL_TEXTUREBLENDMODE_MOD),
83 (SDL_TEXTURESCALEMODE_NONE | SDL_TEXTURESCALEMODE_FAST), 82 (SDL_TEXTURESCALEMODE_NONE | SDL_TEXTURESCALEMODE_FAST),
84 14, 83 14,
85 { 84 {
86 SDL_PIXELFORMAT_INDEX8, 85 SDL_PIXELFORMAT_INDEX8,
87 SDL_PIXELFORMAT_RGB555, 86 SDL_PIXELFORMAT_RGB555,
220 SDL_OutOfMemory(); 219 SDL_OutOfMemory();
221 return NULL; 220 return NULL;
222 } 221 }
223 renderer->ActivateRenderer = SW_ActivateRenderer; 222 renderer->ActivateRenderer = SW_ActivateRenderer;
224 renderer->DisplayModeChanged = SW_DisplayModeChanged; 223 renderer->DisplayModeChanged = SW_DisplayModeChanged;
224
225 renderer->SetDrawColor = SW_SetDrawColor;
226 /* FIXME : Implement
227 renderer->SetDrawBlendMode = GL_SetDrawBlendMode;
228 renderer->RenderLine = GL_RenderLine;
229 */
230
225 renderer->RenderFill = SW_RenderFill; 231 renderer->RenderFill = SW_RenderFill;
226 renderer->RenderCopy = SW_RenderCopy; 232 renderer->RenderCopy = SW_RenderCopy;
227 renderer->RenderPresent = SW_RenderPresent; 233 renderer->RenderPresent = SW_RenderPresent;
228 renderer->DestroyRenderer = SW_DestroyRenderer; 234 renderer->DestroyRenderer = SW_DestroyRenderer;
229 renderer->info.name = SW_RenderDriver.info.name; 235 renderer->info.name = SW_RenderDriver.info.name;
518 SDL_SW_UnlockYUVTexture((SDL_SW_YUVTexture *) texture->driverdata); 524 SDL_SW_UnlockYUVTexture((SDL_SW_YUVTexture *) texture->driverdata);
519 } 525 }
520 } 526 }
521 527
522 static int 528 static int
523 SW_RenderFill(SDL_Renderer * renderer, Uint8 r, Uint8 g, Uint8 b, Uint8 a, 529 SW_SetDrawColor(SDL_Renderer * renderer)
524 const SDL_Rect * rect) 530 {
531 return 0;
532 }
533
534 static int
535 SW_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect)
525 { 536 {
526 SW_RenderData *data = (SW_RenderData *) renderer->driverdata; 537 SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
527 Uint32 color; 538 Uint32 color;
528 SDL_Rect real_rect; 539 SDL_Rect real_rect;
529 int status; 540 int status;
530 541
531 if (data->renderer->info.flags & SDL_RENDERER_PRESENTCOPY) { 542 if (data->renderer->info.flags & SDL_RENDERER_PRESENTCOPY) {
532 SDL_AddDirtyRect(&data->dirty, rect); 543 SDL_AddDirtyRect(&data->dirty, rect);
533 } 544 }
534 545
535 color = SDL_MapRGBA(data->surface.format, r, g, b, a); 546 color = SDL_MapRGBA(data->surface.format,
547 renderer->r, renderer->g, renderer->b, renderer->a);
536 548
537 if (data->renderer->LockTexture(data->renderer, 549 if (data->renderer->LockTexture(data->renderer,
538 data->texture[data->current_texture], 550 data->texture[data->current_texture],
539 rect, 1, &data->surface.pixels, 551 rect, 1, &data->surface.pixels,
540 &data->surface.pitch) < 0) { 552 &data->surface.pitch) < 0) {