comparison src/SDL_compat.c @ 5145:c8e049de174c

Making the API simpler, the renderer present semantics are always having a backbuffer and then discarding it. This is best for hardware accelerated rendering.
author Sam Lantinga <slouken@libsdl.org>
date Tue, 01 Feb 2011 12:19:46 -0800
parents 481dabb098ef
children ad50b3db78bd
comparison
equal deleted inserted replaced
5144:31e7f523ab3d 5145:c8e049de174c
665 SDL_PublicSurface = SDL_VideoSurface; 665 SDL_PublicSurface = SDL_VideoSurface;
666 return SDL_PublicSurface; 666 return SDL_PublicSurface;
667 } 667 }
668 668
669 /* Create a renderer for the window */ 669 /* Create a renderer for the window */
670 if (SDL_CreateRenderer 670 if (SDL_CreateRenderer(SDL_VideoWindow, -1, 0) < 0) {
671 (SDL_VideoWindow, -1,
672 SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTDISCARD) < 0) {
673 return NULL; 671 return NULL;
674 } 672 }
675 SDL_GetRendererInfo(&SDL_VideoRendererInfo); 673 SDL_GetRendererInfo(&SDL_VideoRendererInfo);
676 674
677 /* Create a texture for the screen surface */ 675 /* Create a texture for the screen surface */
859 857
860 void 858 void
861 SDL_UpdateRects(SDL_Surface * screen, int numrects, SDL_Rect * rects) 859 SDL_UpdateRects(SDL_Surface * screen, int numrects, SDL_Rect * rects)
862 { 860 {
863 int i; 861 int i;
862 SDL_Rect rect;
864 863
865 if (screen == SDL_ShadowSurface) { 864 if (screen == SDL_ShadowSurface) {
866 for (i = 0; i < numrects; ++i) { 865 for (i = 0; i < numrects; ++i) {
867 SDL_LowerBlit(SDL_ShadowSurface, &rects[i], SDL_VideoSurface, 866 SDL_LowerBlit(SDL_ShadowSurface, &rects[i], SDL_VideoSurface,
868 &rects[i]); 867 &rects[i]);
885 (Uint8 *) screen->pixels + rect->y * pitch + 884 (Uint8 *) screen->pixels + rect->y * pitch +
886 rect->x * psize; 885 rect->x * psize;
887 SDL_UpdateTexture(SDL_VideoTexture, rect, pixels, pitch); 886 SDL_UpdateTexture(SDL_VideoTexture, rect, pixels, pitch);
888 } 887 }
889 } 888 }
890 if (SDL_VideoRendererInfo.flags & SDL_RENDERER_PRESENTCOPY) { 889 rect.x = 0;
891 for (i = 0; i < numrects; ++i) { 890 rect.y = 0;
892 SDL_RenderCopy(SDL_VideoTexture, &rects[i], &rects[i]); 891 rect.w = screen->w;
893 } 892 rect.h = screen->h;
894 } else { 893 SDL_RenderCopy(SDL_VideoTexture, &rect, &rect);
895 SDL_Rect rect;
896 rect.x = 0;
897 rect.y = 0;
898 rect.w = screen->w;
899 rect.h = screen->h;
900 SDL_RenderCopy(SDL_VideoTexture, &rect, &rect);
901 }
902 SDL_RenderPresent(); 894 SDL_RenderPresent();
903 } 895 }
904 } 896 }
905 897
906 void 898 void