diff src/video/SDL_renderer_gl.c @ 1926:307355678142

Added SDL_GL_ExtensionSupported() Use GL_ARB_texture_rectangle in the OpenGL renderer, if supported.
author Sam Lantinga <slouken@libsdl.org>
date Sat, 22 Jul 2006 21:58:17 +0000
parents 69217fdd2c0a
children aeb8263d377a
line wrap: on
line diff
--- a/src/video/SDL_renderer_gl.c	Sat Jul 22 21:17:37 2006 +0000
+++ b/src/video/SDL_renderer_gl.c	Sat Jul 22 21:58:17 2006 +0000
@@ -97,6 +97,7 @@
 typedef struct
 {
     SDL_GLContext context;
+    SDL_bool GL_ARB_texture_rectangle_supported;
 } GL_RenderData;
 
 typedef struct
@@ -226,16 +227,19 @@
     glGetIntegerv(GL_MAX_TEXTURE_SIZE, &renderer->info.max_texture_width);
     glGetIntegerv(GL_MAX_TEXTURE_SIZE, &renderer->info.max_texture_height);
 
-    /* FIXME: Check for GL_ARB_texture_rectangle and GL_EXT_texture_rectangle */
+    if (SDL_GL_ExtensionSupported("GL_ARB_texture_rectangle")
+        || SDL_GL_ExtensionSupported("GL_EXT_texture_rectangle")) {
+        data->GL_ARB_texture_rectangle_supported = SDL_TRUE;
+    }
 
     /* Set up parameters for rendering */
     glDisable(GL_DEPTH_TEST);
     glDisable(GL_CULL_FACE);
-#ifdef USE_GL_TEXTURE_RECTANGLE
-    glEnable(GL_TEXTURE_RECTANGLE_ARB);
-#else
-    glEnable(GL_TEXTURE_2D);
-#endif
+    if (data->GL_ARB_texture_rectangle_supported) {
+        glEnable(GL_TEXTURE_RECTANGLE_ARB);
+    } else {
+        glEnable(GL_TEXTURE_2D);
+    }
     glMatrixMode(GL_PROJECTION);
     glLoadIdentity();
     glMatrixMode(GL_MODELVIEW);
@@ -369,19 +373,19 @@
 
     glGetError();
     glGenTextures(1, &data->texture);
-#ifdef USE_GL_TEXTURE_RECTANGLE
-    data->type = GL_TEXTURE_RECTANGLE_ARB;
-    texture_w = texture->w;
-    texture_h = texture->h;
-    data->texw = (GLfloat) texture->w;
-    data->texh = (GLfloat) texture->h;
-#else
-    data->type = GL_TEXTURE_2D;
-    texture_w = power_of_2(texture->w);
-    texture_h = power_of_2(texture->h);
-    data->texw = (GLfloat) texture->w / texture_w;
-    data->texh = (GLfloat) texture->h / texture_h;
-#endif
+    if (renderdata->GL_ARB_texture_rectangle_supported) {
+        data->type = GL_TEXTURE_RECTANGLE_ARB;
+        texture_w = texture->w;
+        texture_h = texture->h;
+        data->texw = (GLfloat) texture->w;
+        data->texh = (GLfloat) texture->h;
+    } else {
+        data->type = GL_TEXTURE_2D;
+        texture_w = power_of_2(texture->w);
+        texture_h = power_of_2(texture->h);
+        data->texw = (GLfloat) texture->w / texture_w;
+        data->texh = (GLfloat) texture->h / texture_h;
+    }
     data->format = format;
     data->formattype = type;
     glBindTexture(data->type, data->texture);