comparison src/video/SDL_surface.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 8f4ed5ec2b06
comparison
equal deleted inserted replaced
2883:11626a53e7bc 2884:9dde605c7540
138 } 138 }
139 SDL_FormatChanged(surface); 139 SDL_FormatChanged(surface);
140 140
141 /* By default surface with an alpha mask are set up for blending */ 141 /* By default surface with an alpha mask are set up for blending */
142 if (Amask) { 142 if (Amask) {
143 SDL_SetSurfaceBlendMode(surface, SDL_TEXTUREBLENDMODE_BLEND); 143 SDL_SetSurfaceBlendMode(surface, SDL_BLENDMODE_BLEND);
144 } 144 }
145 145
146 /* The surface is ready to go */ 146 /* The surface is ready to go */
147 surface->refcount = 1; 147 surface->refcount = 1;
148 #ifdef CHECK_LEAKS 148 #ifdef CHECK_LEAKS
334 } 334 }
335 335
336 SDL_UnlockSurface(surface); 336 SDL_UnlockSurface(surface);
337 337
338 SDL_SetColorKey(surface, 0, 0); 338 SDL_SetColorKey(surface, 0, 0);
339 SDL_SetSurfaceBlendMode(surface, SDL_TEXTUREBLENDMODE_BLEND); 339 SDL_SetSurfaceBlendMode(surface, SDL_BLENDMODE_BLEND);
340 } 340 }
341 341
342 int 342 int
343 SDL_SetSurfaceColorMod(SDL_Surface * surface, Uint8 r, Uint8 g, Uint8 b) 343 SDL_SetSurfaceColorMod(SDL_Surface * surface, Uint8 r, Uint8 g, Uint8 b)
344 { 344 {
432 status = 0; 432 status = 0;
433 flags = surface->map->info.flags; 433 flags = surface->map->info.flags;
434 surface->map->info.flags &= 434 surface->map->info.flags &=
435 ~(SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD); 435 ~(SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD);
436 switch (blendMode) { 436 switch (blendMode) {
437 case SDL_TEXTUREBLENDMODE_NONE: 437 case SDL_BLENDMODE_NONE:
438 break; 438 break;
439 case SDL_TEXTUREBLENDMODE_MASK: 439 case SDL_BLENDMODE_MASK:
440 surface->map->info.flags |= SDL_COPY_MASK; 440 surface->map->info.flags |= SDL_COPY_MASK;
441 break; 441 break;
442 case SDL_TEXTUREBLENDMODE_BLEND: 442 case SDL_BLENDMODE_BLEND:
443 surface->map->info.flags |= SDL_COPY_BLEND; 443 surface->map->info.flags |= SDL_COPY_BLEND;
444 break; 444 break;
445 case SDL_TEXTUREBLENDMODE_ADD: 445 case SDL_BLENDMODE_ADD:
446 surface->map->info.flags |= SDL_COPY_ADD; 446 surface->map->info.flags |= SDL_COPY_ADD;
447 break; 447 break;
448 case SDL_TEXTUREBLENDMODE_MOD: 448 case SDL_BLENDMODE_MOD:
449 surface->map->info.flags |= SDL_COPY_MOD; 449 surface->map->info.flags |= SDL_COPY_MOD;
450 break; 450 break;
451 default: 451 default:
452 SDL_Unsupported(); 452 SDL_Unsupported();
453 status = -1; 453 status = -1;
481 481
482 switch (surface->map-> 482 switch (surface->map->
483 info.flags & (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | 483 info.flags & (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD |
484 SDL_COPY_MOD)) { 484 SDL_COPY_MOD)) {
485 case SDL_COPY_MASK: 485 case SDL_COPY_MASK:
486 *blendMode = SDL_TEXTUREBLENDMODE_MASK; 486 *blendMode = SDL_BLENDMODE_MASK;
487 break; 487 break;
488 case SDL_COPY_BLEND: 488 case SDL_COPY_BLEND:
489 *blendMode = SDL_TEXTUREBLENDMODE_BLEND; 489 *blendMode = SDL_BLENDMODE_BLEND;
490 break; 490 break;
491 case SDL_COPY_ADD: 491 case SDL_COPY_ADD:
492 *blendMode = SDL_TEXTUREBLENDMODE_ADD; 492 *blendMode = SDL_BLENDMODE_ADD;
493 break; 493 break;
494 case SDL_COPY_MOD: 494 case SDL_COPY_MOD:
495 *blendMode = SDL_TEXTUREBLENDMODE_MOD; 495 *blendMode = SDL_BLENDMODE_MOD;
496 break; 496 break;
497 default: 497 default:
498 *blendMode = SDL_TEXTUREBLENDMODE_NONE; 498 *blendMode = SDL_BLENDMODE_NONE;
499 break; 499 break;
500 } 500 }
501 return 0; 501 return 0;
502 } 502 }
503 503
833 833
834 /* Enable alpha blending by default if the new surface has an 834 /* Enable alpha blending by default if the new surface has an
835 * alpha channel or alpha modulation */ 835 * alpha channel or alpha modulation */
836 if ((surface->format->Amask && format->Amask) || 836 if ((surface->format->Amask && format->Amask) ||
837 (copy_flags & SDL_COPY_MODULATE_ALPHA)) { 837 (copy_flags & SDL_COPY_MODULATE_ALPHA)) {
838 SDL_SetSurfaceBlendMode(convert, SDL_TEXTUREBLENDMODE_BLEND); 838 SDL_SetSurfaceBlendMode(convert, SDL_BLENDMODE_BLEND);
839 } 839 }
840 if ((copy_flags & SDL_COPY_RLE_DESIRED) || (flags & SDL_RLEACCEL)) { 840 if ((copy_flags & SDL_COPY_RLE_DESIRED) || (flags & SDL_RLEACCEL)) {
841 SDL_SetSurfaceRLE(convert, SDL_RLEACCEL); 841 SDL_SetSurfaceRLE(convert, SDL_RLEACCEL);
842 } 842 }
843 843