src/video/SDL_renderer_gl.c
changeset 1926 307355678142
parent 1924 69217fdd2c0a
child 1927 aeb8263d377a
     1.1 --- a/src/video/SDL_renderer_gl.c	Sat Jul 22 21:17:37 2006 +0000
     1.2 +++ b/src/video/SDL_renderer_gl.c	Sat Jul 22 21:58:17 2006 +0000
     1.3 @@ -97,6 +97,7 @@
     1.4  typedef struct
     1.5  {
     1.6      SDL_GLContext context;
     1.7 +    SDL_bool GL_ARB_texture_rectangle_supported;
     1.8  } GL_RenderData;
     1.9  
    1.10  typedef struct
    1.11 @@ -226,16 +227,19 @@
    1.12      glGetIntegerv(GL_MAX_TEXTURE_SIZE, &renderer->info.max_texture_width);
    1.13      glGetIntegerv(GL_MAX_TEXTURE_SIZE, &renderer->info.max_texture_height);
    1.14  
    1.15 -    /* FIXME: Check for GL_ARB_texture_rectangle and GL_EXT_texture_rectangle */
    1.16 +    if (SDL_GL_ExtensionSupported("GL_ARB_texture_rectangle")
    1.17 +        || SDL_GL_ExtensionSupported("GL_EXT_texture_rectangle")) {
    1.18 +        data->GL_ARB_texture_rectangle_supported = SDL_TRUE;
    1.19 +    }
    1.20  
    1.21      /* Set up parameters for rendering */
    1.22      glDisable(GL_DEPTH_TEST);
    1.23      glDisable(GL_CULL_FACE);
    1.24 -#ifdef USE_GL_TEXTURE_RECTANGLE
    1.25 -    glEnable(GL_TEXTURE_RECTANGLE_ARB);
    1.26 -#else
    1.27 -    glEnable(GL_TEXTURE_2D);
    1.28 -#endif
    1.29 +    if (data->GL_ARB_texture_rectangle_supported) {
    1.30 +        glEnable(GL_TEXTURE_RECTANGLE_ARB);
    1.31 +    } else {
    1.32 +        glEnable(GL_TEXTURE_2D);
    1.33 +    }
    1.34      glMatrixMode(GL_PROJECTION);
    1.35      glLoadIdentity();
    1.36      glMatrixMode(GL_MODELVIEW);
    1.37 @@ -369,19 +373,19 @@
    1.38  
    1.39      glGetError();
    1.40      glGenTextures(1, &data->texture);
    1.41 -#ifdef USE_GL_TEXTURE_RECTANGLE
    1.42 -    data->type = GL_TEXTURE_RECTANGLE_ARB;
    1.43 -    texture_w = texture->w;
    1.44 -    texture_h = texture->h;
    1.45 -    data->texw = (GLfloat) texture->w;
    1.46 -    data->texh = (GLfloat) texture->h;
    1.47 -#else
    1.48 -    data->type = GL_TEXTURE_2D;
    1.49 -    texture_w = power_of_2(texture->w);
    1.50 -    texture_h = power_of_2(texture->h);
    1.51 -    data->texw = (GLfloat) texture->w / texture_w;
    1.52 -    data->texh = (GLfloat) texture->h / texture_h;
    1.53 -#endif
    1.54 +    if (renderdata->GL_ARB_texture_rectangle_supported) {
    1.55 +        data->type = GL_TEXTURE_RECTANGLE_ARB;
    1.56 +        texture_w = texture->w;
    1.57 +        texture_h = texture->h;
    1.58 +        data->texw = (GLfloat) texture->w;
    1.59 +        data->texh = (GLfloat) texture->h;
    1.60 +    } else {
    1.61 +        data->type = GL_TEXTURE_2D;
    1.62 +        texture_w = power_of_2(texture->w);
    1.63 +        texture_h = power_of_2(texture->h);
    1.64 +        data->texw = (GLfloat) texture->w / texture_w;
    1.65 +        data->texh = (GLfloat) texture->h / texture_h;
    1.66 +    }
    1.67      data->format = format;
    1.68      data->formattype = type;
    1.69      glBindTexture(data->type, data->texture);