diff src/video/SDL_video.c @ 1924:69217fdd2c0a

If the OpenGL renderer is selected for a non-OpenGL window, recreate the window with OpenGL enabled. Added OpenGL renderer error checking. Use fast-path texture formats in the OpenGL renderer.
author Sam Lantinga <slouken@libsdl.org>
date Sat, 22 Jul 2006 21:02:57 +0000
parents d4572b97b08f
children 307355678142
line wrap: on
line diff
--- a/src/video/SDL_video.c	Sat Jul 22 19:51:48 2006 +0000
+++ b/src/video/SDL_video.c	Sat Jul 22 21:02:57 2006 +0000
@@ -833,6 +833,20 @@
     return window.id;
 }
 
+int
+SDL_RecreateWindow(SDL_Window * window)
+{
+    if ((window->flags & SDL_WINDOW_OPENGL) && !_this->GL_CreateContext) {
+        window->flags &= ~SDL_WINDOW_OPENGL;
+        SDL_SetError("No OpenGL support in video driver");
+        return -1;
+    }
+    if (_this->DestroyWindow) {
+        _this->DestroyWindow(_this, window);
+    }
+    return _this->CreateWindow(_this, window);
+}
+
 SDL_Window *
 SDL_GetWindowFromID(SDL_WindowID windowID)
 {
@@ -1259,6 +1273,7 @@
             if (window->title) {
                 SDL_free(window->title);
             }
+            SDL_free(window);
             if (j != display->num_windows - 1) {
                 SDL_memcpy(&display->windows[i],
                            &display->windows[i + 1],
@@ -1421,6 +1436,9 @@
     texture->renderer = renderer;
 
     if (renderer->CreateTexture(renderer, texture) < 0) {
+        if (renderer->DestroyTexture) {
+            renderer->DestroyTexture(renderer, texture);
+        }
         SDL_free(texture);
         return 0;
     }