src/render/opengl/SDL_render_gl.c
changeset 5397 88ff1f463134
parent 5381 79e60256dbf7
child 5402 5d102cd8aef3
equal deleted inserted replaced
5396:109b7c071f70 5397:88ff1f463134
    96 
    96 
    97     /* OpenGL functions */
    97     /* OpenGL functions */
    98 #define SDL_PROC(ret,func,params) ret (APIENTRY *func) params;
    98 #define SDL_PROC(ret,func,params) ret (APIENTRY *func) params;
    99 #include "SDL_glfuncs.h"
    99 #include "SDL_glfuncs.h"
   100 #undef SDL_PROC
   100 #undef SDL_PROC
   101 
       
   102     void (*glTextureRangeAPPLE) (GLenum target, GLsizei length,
       
   103                                  const GLvoid * pointer);
       
   104 
   101 
   105     /* Multitexture support */
   102     /* Multitexture support */
   106     SDL_bool GL_ARB_multitexture_supported;
   103     SDL_bool GL_ARB_multitexture_supported;
   107     PFNGLACTIVETEXTUREARBPROC glActiveTextureARB;
   104     PFNGLACTIVETEXTUREARBPROC glActiveTextureARB;
   108     GLint num_texture_units;
   105     GLint num_texture_units;
   320 
   317 
   321     if (SDL_GL_ExtensionSupported("GL_ARB_texture_rectangle")
   318     if (SDL_GL_ExtensionSupported("GL_ARB_texture_rectangle")
   322         || SDL_GL_ExtensionSupported("GL_EXT_texture_rectangle")) {
   319         || SDL_GL_ExtensionSupported("GL_EXT_texture_rectangle")) {
   323         data->GL_ARB_texture_rectangle_supported = SDL_TRUE;
   320         data->GL_ARB_texture_rectangle_supported = SDL_TRUE;
   324     }
   321     }
   325     if (SDL_GL_ExtensionSupported("GL_APPLE_texture_range")) {
       
   326         data->glTextureRangeAPPLE =
       
   327             (void (*)(GLenum, GLsizei, const GLvoid *))
       
   328             SDL_GL_GetProcAddress("glTextureRangeAPPLE");
       
   329     }
       
   330 
   322 
   331     /* Check for multitexture support */
   323     /* Check for multitexture support */
   332     if (SDL_GL_ExtensionSupported("GL_ARB_multitexture")) {
   324     if (SDL_GL_ExtensionSupported("GL_ARB_multitexture")) {
   333         data->glActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC) SDL_GL_GetProcAddress("glActiveTextureARB");
   325         data->glActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC) SDL_GL_GetProcAddress("glActiveTextureARB");
   334         if (data->glActiveTextureARB) {
   326         if (data->glActiveTextureARB) {
   486     } else {
   478     } else {
   487         renderdata->glTexParameteri(data->type, GL_TEXTURE_STORAGE_HINT_APPLE,
   479         renderdata->glTexParameteri(data->type, GL_TEXTURE_STORAGE_HINT_APPLE,
   488                                     GL_STORAGE_CACHED_APPLE);
   480                                     GL_STORAGE_CACHED_APPLE);
   489     }
   481     }
   490     if (texture->access == SDL_TEXTUREACCESS_STREAMING
   482     if (texture->access == SDL_TEXTUREACCESS_STREAMING
   491         && texture->format == SDL_PIXELFORMAT_ARGB8888) {
   483         && texture->format == SDL_PIXELFORMAT_ARGB8888
       
   484         && (texture->w % 8) == 0) {
   492         renderdata->glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE);
   485         renderdata->glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE);
       
   486         renderdata->glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
       
   487         renderdata->glPixelStorei(GL_UNPACK_ROW_LENGTH,
       
   488                           (data->pitch / SDL_BYTESPERPIXEL(texture->format)));
   493         renderdata->glTexImage2D(data->type, 0, internalFormat, texture_w,
   489         renderdata->glTexImage2D(data->type, 0, internalFormat, texture_w,
   494                                  texture_h, 0, format, type, data->pixels);
   490                                  texture_h, 0, format, type, data->pixels);
       
   491         renderdata->glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_FALSE);
   495     }
   492     }
   496     else
   493     else
   497 #endif
   494 #endif
   498     {
   495     {
   499         renderdata->glTexImage2D(data->type, 0, internalFormat, texture_w,
   496         renderdata->glTexImage2D(data->type, 0, internalFormat, texture_w,
   544     GLenum result;
   541     GLenum result;
   545 
   542 
   546     GL_ActivateRenderer(renderer);
   543     GL_ActivateRenderer(renderer);
   547 
   544 
   548     renderdata->glGetError();
   545     renderdata->glGetError();
       
   546     renderdata->glEnable(data->type);
       
   547     renderdata->glBindTexture(data->type, data->texture);
   549     renderdata->glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
   548     renderdata->glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
   550     renderdata->glPixelStorei(GL_UNPACK_ROW_LENGTH,
   549     renderdata->glPixelStorei(GL_UNPACK_ROW_LENGTH,
   551                               (pitch / SDL_BYTESPERPIXEL(texture->format)));
   550                               (pitch / SDL_BYTESPERPIXEL(texture->format)));
   552     renderdata->glEnable(data->type);
       
   553     renderdata->glBindTexture(data->type, data->texture);
       
   554     renderdata->glTexSubImage2D(data->type, 0, rect->x, rect->y, rect->w,
   551     renderdata->glTexSubImage2D(data->type, 0, rect->x, rect->y, rect->w,
   555                                 rect->h, data->format, data->formattype,
   552                                 rect->h, data->format, data->formattype,
   556                                 pixels);
   553                                 pixels);
   557     if (data->yuv) {
   554     if (data->yuv) {
   558         const void *top;
   555         const void *top;