Fixed bug 1331 - SDL_CreateTextureFromSurface fails for OpenGL + Win XP 64 NVidia 285.58 with GL_INVALID_ENUM
authorSam Lantinga
Tue, 10 Jan 2012 21:00:47 -0500
changeset 620715ff38383cb7
parent 6205 7dd8ea9f282d
child 6208 291fea716f09
Fixed bug 1331 - SDL_CreateTextureFromSurface fails for OpenGL + Win XP 64 NVidia 285.58 with GL_INVALID_ENUM

I think this fixes the bug. I'm not sure why it would fail, and it may have something to do with the version of OpenGL that we initialize and use by default. Regardless, this should take care of the problem.
src/render/opengl/SDL_render_gl.c
     1.1 --- a/src/render/opengl/SDL_render_gl.c	Mon Jan 09 21:11:11 2012 -0500
     1.2 +++ b/src/render/opengl/SDL_render_gl.c	Tue Jan 10 21:00:47 2012 -0500
     1.3 @@ -470,10 +470,15 @@
     1.4      renderdata->glBindTexture(data->type, data->texture);
     1.5      renderdata->glTexParameteri(data->type, GL_TEXTURE_MIN_FILTER, scaleMode);
     1.6      renderdata->glTexParameteri(data->type, GL_TEXTURE_MAG_FILTER, scaleMode);
     1.7 -    renderdata->glTexParameteri(data->type, GL_TEXTURE_WRAP_S,
     1.8 -                                GL_CLAMP_TO_EDGE);
     1.9 -    renderdata->glTexParameteri(data->type, GL_TEXTURE_WRAP_T,
    1.10 -                                GL_CLAMP_TO_EDGE);
    1.11 +    /* According to the spec, CLAMP_TO_EDGE is the default for TEXTURE_RECTANGLE
    1.12 +       and setting it causes an INVALID_ENUM error in the latest NVidia drivers.
    1.13 +    */
    1.14 +    if (data->type != GL_TEXTURE_RECTANGLE_ARB) {
    1.15 +        renderdata->glTexParameteri(data->type, GL_TEXTURE_WRAP_S,
    1.16 +                                    GL_CLAMP_TO_EDGE);
    1.17 +        renderdata->glTexParameteri(data->type, GL_TEXTURE_WRAP_T,
    1.18 +                                    GL_CLAMP_TO_EDGE);
    1.19 +    }
    1.20  #ifdef __MACOSX__
    1.21  #ifndef GL_TEXTURE_STORAGE_HINT_APPLE
    1.22  #define GL_TEXTURE_STORAGE_HINT_APPLE       0x85BC