diff src/video/SDL_surface.c @ 1678:90bf530ced8e SDL-1.3

SDL_SetVideoMode() compiles now...
author Sam Lantinga <slouken@libsdl.org>
date Wed, 14 Jun 2006 06:14:26 +0000
parents 8e754b82cecc
children 7ae8018b2e5d
line wrap: on
line diff
--- a/src/video/SDL_surface.c	Tue Jun 13 04:37:45 2006 +0000
+++ b/src/video/SDL_surface.c	Wed Jun 14 06:14:26 2006 +0000
@@ -134,6 +134,8 @@
     int w, h;
     int bpp;
     Uint32 Rmask, Gmask, Bmask, Amask;
+    void *pixels;
+    int pitch;
 
     if (SDL_QueryTexture(textureID, &format, NULL, &w, &h) < 0) {
         return NULL;
@@ -145,14 +147,22 @@
         return NULL;
     }
 
-    surface = SDL_CreateRGBSurface(0, 0, 0, bpp, Rmask, Gmask, Bmask, Amask);
-    if (surface != NULL) {
-        surface->flags |= (SDL_HWSURFACE | SDL_PREALLOC);
-        surface->w = w;
-        surface->h = h;
-        surface->lock_data = (void *) textureID;
-        SDL_SetClipRect(surface, NULL);
+    if (SDL_QueryTexturePixels(textureID, &pixels, &pitch) == 0) {
+        surface =
+            SDL_CreateRGBSurfaceFrom(pixels, w, h, bpp, pitch, Rmask, Gmask,
+                                     Bmask, Amask);
+    } else {
+        surface =
+            SDL_CreateRGBSurface(0, 0, 0, bpp, Rmask, Gmask, Bmask, Amask);
+        if (surface) {
+            surface->flags |= SDL_HWSURFACE;
+            surface->w = w;
+            surface->h = h;
+            surface->lock_data = (void *) textureID;
+            SDL_SetClipRect(surface, NULL);
+        }
     }
+
     return surface;
 }