comparison src/SDL_compat.c @ 2266:e61ad15a205f

More work in progress integrating SDL_Surface and the new SDL_Texture API
author Sam Lantinga <slouken@libsdl.org>
date Sat, 18 Aug 2007 01:44:21 +0000
parents eebaa05f8bd9
children c785543d1843
comparison
equal deleted inserted replaced
2265:265bb136af92 2266:e61ad15a205f
587 SDL_GetVideoSurface(void) 587 SDL_GetVideoSurface(void)
588 { 588 {
589 return SDL_PublicSurface; 589 return SDL_PublicSurface;
590 } 590 }
591 591
592 int
593 SDL_SetAlpha(SDL_Surface * surface, Uint32 flag, Uint8 value)
594 {
595 if (flag & SDL_RLEACCEL) {
596 SDL_SetSurfaceRLE(surface, 1);
597 }
598 if (flag) {
599 SDL_SetSurfaceAlphaMod(surface, value);
600 SDL_SetSurfaceBlendMode(surface, SDL_TEXTUREBLENDMODE_BLEND);
601 } else {
602 SDL_SetSurfaceAlphaMod(surface, 0xFF);
603 SDL_SetSurfaceBlendMode(surface, SDL_TEXTUREBLENDMODE_NONE);
604 }
605 return 0;
606 }
607
592 SDL_Surface * 608 SDL_Surface *
593 SDL_DisplayFormat(SDL_Surface * surface) 609 SDL_DisplayFormat(SDL_Surface * surface)
594 { 610 {
595 Uint32 flags; 611 Uint32 flags;
596 612
598 SDL_SetError("No video mode has been set"); 614 SDL_SetError("No video mode has been set");
599 return NULL; 615 return NULL;
600 } 616 }
601 617
602 /* Set the flags appropriate for copying to display surface */ 618 /* Set the flags appropriate for copying to display surface */
603 flags = SDL_SWSURFACE; 619 return SDL_ConvertSurface(surface, SDL_PublicSurface->format, SDL_RLEACCELOK);
604 #ifdef AUTORLE_DISPLAYFORMAT
605 flags |= (surface->flags & (SDL_SRCCOLORKEY | SDL_SRCALPHA));
606 flags |= SDL_RLEACCELOK;
607 #else
608 flags |=
609 surface->flags & (SDL_SRCCOLORKEY | SDL_SRCALPHA | SDL_RLEACCELOK);
610 #endif
611 return SDL_ConvertSurface(surface, SDL_PublicSurface->format, flags);
612 } 620 }
613 621
614 SDL_Surface * 622 SDL_Surface *
615 SDL_DisplayFormatAlpha(SDL_Surface * surface) 623 SDL_DisplayFormatAlpha(SDL_Surface * surface)
616 { 624 {
656 /* We have no other optimised formats right now. When/if a new 664 /* We have no other optimised formats right now. When/if a new
657 optimised alpha format is written, add the converter here */ 665 optimised alpha format is written, add the converter here */
658 break; 666 break;
659 } 667 }
660 format = SDL_AllocFormat(32, rmask, gmask, bmask, amask); 668 format = SDL_AllocFormat(32, rmask, gmask, bmask, amask);
661 flags = surface->flags & (SDL_SRCALPHA | SDL_RLEACCELOK); 669 converted = SDL_ConvertSurface(surface, format, SDL_RLEACCELOK);
662 converted = SDL_ConvertSurface(surface, format, flags);
663 SDL_FreeFormat(format); 670 SDL_FreeFormat(format);
664 return converted; 671 return converted;
665 } 672 }
666 673
667 int 674 int