diff 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
line wrap: on
line diff
--- a/src/SDL_compat.c	Fri Jul 14 08:24:43 2006 +0000
+++ b/src/SDL_compat.c	Sat Jul 15 09:46:36 2006 +0000
@@ -31,6 +31,7 @@
 
 
 static SDL_WindowID SDL_VideoWindow;
+static SDL_RendererInfo SDL_VideoRendererInfo;
 static SDL_TextureID SDL_VideoTexture;
 static SDL_Surface *SDL_VideoSurface;
 static SDL_Surface *SDL_ShadowSurface;
@@ -442,10 +443,12 @@
     }
 
     /* Create a renderer for the window */
-    if (SDL_CreateRenderer(SDL_VideoWindow, -1, SDL_Renderer_SingleBuffer) <
-        0) {
+    if (SDL_CreateRenderer
+        (SDL_VideoWindow, -1,
+         SDL_Renderer_SingleBuffer | SDL_Renderer_PresentDiscard) < 0) {
         return NULL;
     }
+    SDL_GetRendererInfo(-1, &SDL_VideoRendererInfo);
 
     /* Create a texture for the screen surface */
     SDL_VideoTexture =
@@ -642,8 +645,19 @@
         screen = SDL_VideoSurface;
     }
     if (screen == SDL_VideoSurface) {
-        for (i = 0; i < numrects; ++i) {
-            SDL_RenderCopy(SDL_VideoTexture, &rects[i], &rects[i],
+        if (SDL_VideoRendererInfo.flags & SDL_Renderer_PresentCopy) {
+            for (i = 0; i < numrects; ++i) {
+                SDL_RenderCopy(SDL_VideoTexture, &rects[i], &rects[i],
+                               SDL_TextureBlendMode_None,
+                               SDL_TextureScaleMode_None);
+            }
+        } else {
+            SDL_Rect rect;
+            rect.x = 0;
+            rect.y = 0;
+            rect.w = screen->w;
+            rect.h = screen->h;
+            SDL_RenderCopy(SDL_VideoTexture, &rect, &rect,
                            SDL_TextureBlendMode_None,
                            SDL_TextureScaleMode_None);
         }