comparison 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
comparison
equal deleted inserted replaced
1923:d4572b97b08f 1924:69217fdd2c0a
831 display->num_windows++; 831 display->num_windows++;
832 832
833 return window.id; 833 return window.id;
834 } 834 }
835 835
836 int
837 SDL_RecreateWindow(SDL_Window * window)
838 {
839 if ((window->flags & SDL_WINDOW_OPENGL) && !_this->GL_CreateContext) {
840 window->flags &= ~SDL_WINDOW_OPENGL;
841 SDL_SetError("No OpenGL support in video driver");
842 return -1;
843 }
844 if (_this->DestroyWindow) {
845 _this->DestroyWindow(_this, window);
846 }
847 return _this->CreateWindow(_this, window);
848 }
849
836 SDL_Window * 850 SDL_Window *
837 SDL_GetWindowFromID(SDL_WindowID windowID) 851 SDL_GetWindowFromID(SDL_WindowID windowID)
838 { 852 {
839 int i, j; 853 int i, j;
840 854
1257 _this->DestroyWindow(_this, window); 1271 _this->DestroyWindow(_this, window);
1258 } 1272 }
1259 if (window->title) { 1273 if (window->title) {
1260 SDL_free(window->title); 1274 SDL_free(window->title);
1261 } 1275 }
1276 SDL_free(window);
1262 if (j != display->num_windows - 1) { 1277 if (j != display->num_windows - 1) {
1263 SDL_memcpy(&display->windows[i], 1278 SDL_memcpy(&display->windows[i],
1264 &display->windows[i + 1], 1279 &display->windows[i + 1],
1265 (display->num_windows - i - 1) * sizeof(*window)); 1280 (display->num_windows - i - 1) * sizeof(*window));
1266 } 1281 }
1419 texture->w = w; 1434 texture->w = w;
1420 texture->h = h; 1435 texture->h = h;
1421 texture->renderer = renderer; 1436 texture->renderer = renderer;
1422 1437
1423 if (renderer->CreateTexture(renderer, texture) < 0) { 1438 if (renderer->CreateTexture(renderer, texture) < 0) {
1439 if (renderer->DestroyTexture) {
1440 renderer->DestroyTexture(renderer, texture);
1441 }
1424 SDL_free(texture); 1442 SDL_free(texture);
1425 return 0; 1443 return 0;
1426 } 1444 }
1427 1445
1428 hash = (texture->id % SDL_arraysize(SDL_CurrentDisplay.textures)); 1446 hash = (texture->id % SDL_arraysize(SDL_CurrentDisplay.textures));