Mercurial > sdl-ios-xcode
comparison src/SDL_compat.c @ 1907:06c27a737b7a
Streamlined the API a bit and optimized the software renderer.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sat, 15 Jul 2006 09:46:36 +0000 |
parents | c2a27da60b18 |
children | 8d384b647307 |
comparison
equal
deleted
inserted
replaced
1906:0c49855a7a3e | 1907:06c27a737b7a |
---|---|
29 #include "video/SDL_sysvideo.h" | 29 #include "video/SDL_sysvideo.h" |
30 #include "video/SDL_pixels_c.h" | 30 #include "video/SDL_pixels_c.h" |
31 | 31 |
32 | 32 |
33 static SDL_WindowID SDL_VideoWindow; | 33 static SDL_WindowID SDL_VideoWindow; |
34 static SDL_RendererInfo SDL_VideoRendererInfo; | |
34 static SDL_TextureID SDL_VideoTexture; | 35 static SDL_TextureID SDL_VideoTexture; |
35 static SDL_Surface *SDL_VideoSurface; | 36 static SDL_Surface *SDL_VideoSurface; |
36 static SDL_Surface *SDL_ShadowSurface; | 37 static SDL_Surface *SDL_ShadowSurface; |
37 static SDL_Surface *SDL_PublicSurface; | 38 static SDL_Surface *SDL_PublicSurface; |
38 static char *wm_title; | 39 static char *wm_title; |
440 SDL_PublicSurface = SDL_VideoSurface; | 441 SDL_PublicSurface = SDL_VideoSurface; |
441 return SDL_PublicSurface; | 442 return SDL_PublicSurface; |
442 } | 443 } |
443 | 444 |
444 /* Create a renderer for the window */ | 445 /* Create a renderer for the window */ |
445 if (SDL_CreateRenderer(SDL_VideoWindow, -1, SDL_Renderer_SingleBuffer) < | 446 if (SDL_CreateRenderer |
446 0) { | 447 (SDL_VideoWindow, -1, |
448 SDL_Renderer_SingleBuffer | SDL_Renderer_PresentDiscard) < 0) { | |
447 return NULL; | 449 return NULL; |
448 } | 450 } |
451 SDL_GetRendererInfo(-1, &SDL_VideoRendererInfo); | |
449 | 452 |
450 /* Create a texture for the screen surface */ | 453 /* Create a texture for the screen surface */ |
451 SDL_VideoTexture = | 454 SDL_VideoTexture = |
452 SDL_CreateTexture(desired_format, SDL_TextureAccess_Local, width, | 455 SDL_CreateTexture(desired_format, SDL_TextureAccess_Local, width, |
453 height); | 456 height); |
640 | 643 |
641 /* Fall through to video surface update */ | 644 /* Fall through to video surface update */ |
642 screen = SDL_VideoSurface; | 645 screen = SDL_VideoSurface; |
643 } | 646 } |
644 if (screen == SDL_VideoSurface) { | 647 if (screen == SDL_VideoSurface) { |
645 for (i = 0; i < numrects; ++i) { | 648 if (SDL_VideoRendererInfo.flags & SDL_Renderer_PresentCopy) { |
646 SDL_RenderCopy(SDL_VideoTexture, &rects[i], &rects[i], | 649 for (i = 0; i < numrects; ++i) { |
650 SDL_RenderCopy(SDL_VideoTexture, &rects[i], &rects[i], | |
651 SDL_TextureBlendMode_None, | |
652 SDL_TextureScaleMode_None); | |
653 } | |
654 } else { | |
655 SDL_Rect rect; | |
656 rect.x = 0; | |
657 rect.y = 0; | |
658 rect.w = screen->w; | |
659 rect.h = screen->h; | |
660 SDL_RenderCopy(SDL_VideoTexture, &rect, &rect, | |
647 SDL_TextureBlendMode_None, | 661 SDL_TextureBlendMode_None, |
648 SDL_TextureScaleMode_None); | 662 SDL_TextureScaleMode_None); |
649 } | 663 } |
650 SDL_RenderPresent(); | 664 SDL_RenderPresent(); |
651 } | 665 } |