src/render/opengles2/SDL_render_gles2.c
changeset 5484 e20c93bc9122
parent 5402 5d102cd8aef3
child 5503 be88d105e91c
equal deleted inserted replaced
5483:ccec742c9b7d 5484:e20c93bc9122
    22 */
    22 */
    23 #include "SDL_config.h"
    23 #include "SDL_config.h"
    24 
    24 
    25 #if SDL_VIDEO_RENDER_OGL_ES2 && !SDL_RENDER_DISABLED
    25 #if SDL_VIDEO_RENDER_OGL_ES2 && !SDL_RENDER_DISABLED
    26 
    26 
       
    27 #include "SDL_hints.h"
    27 #include "SDL_opengles2.h"
    28 #include "SDL_opengles2.h"
    28 #include "../SDL_sysrender.h"
    29 #include "../SDL_sysrender.h"
    29 #include "SDL_shaders_gles2.h"
    30 #include "SDL_shaders_gles2.h"
    30 
    31 
    31 /*************************************************************************************************
    32 /*************************************************************************************************
   232                              void **pixels, int *pitch);
   233                              void **pixels, int *pitch);
   233 static void GLES2_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture);
   234 static void GLES2_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture);
   234 static int GLES2_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect,
   235 static int GLES2_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect,
   235                                const void *pixels, int pitch);
   236                                const void *pixels, int pitch);
   236 
   237 
       
   238 static GLenum
       
   239 GetScaleQuality(void)
       
   240 {
       
   241     const char *hint = SDL_GetHint(SDL_HINT_RENDER_SCALE_QUALITY);
       
   242 
       
   243     if (!hint || *hint == '0' || SDL_strcasecmp(hint, "nearest") == 0) {
       
   244         return GL_NEAREST;
       
   245     } else {
       
   246         return GL_LINEAR;
       
   247     }
       
   248 }
       
   249 
   237 static int
   250 static int
   238 GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
   251 GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
   239 {
   252 {
   240     GLES2_TextureData *tdata;
   253     GLES2_TextureData *tdata;
   241     GLenum format;
   254     GLenum format;
   264     }
   277     }
   265     tdata->texture = 0;
   278     tdata->texture = 0;
   266     tdata->texture_type = GL_TEXTURE_2D;
   279     tdata->texture_type = GL_TEXTURE_2D;
   267     tdata->pixel_format = format;
   280     tdata->pixel_format = format;
   268     tdata->pixel_type = type;
   281     tdata->pixel_type = type;
   269     tdata->scaleMode = GL_LINEAR;
   282     tdata->scaleMode = GetScaleQuality();
   270 
   283 
   271     /* Allocate a blob for image data */
   284     /* Allocate a blob for image data */
   272     if (texture->access == SDL_TEXTUREACCESS_STREAMING)
   285     if (texture->access == SDL_TEXTUREACCESS_STREAMING)
   273     {
   286     {
   274         tdata->pitch = texture->w * SDL_BYTESPERPIXEL(texture->format);
   287         tdata->pitch = texture->w * SDL_BYTESPERPIXEL(texture->format);
   284     /* Allocate the texture */
   297     /* Allocate the texture */
   285     glGetError();
   298     glGetError();
   286     glGenTextures(1, &tdata->texture);
   299     glGenTextures(1, &tdata->texture);
   287     glActiveTexture(GL_TEXTURE0);
   300     glActiveTexture(GL_TEXTURE0);
   288     glBindTexture(tdata->texture_type, tdata->texture);
   301     glBindTexture(tdata->texture_type, tdata->texture);
   289     glTexParameteri(tdata->texture_type, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
       
   290     glTexParameteri(tdata->texture_type, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
       
   291     glTexParameteri(tdata->texture_type, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
   302     glTexParameteri(tdata->texture_type, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
   292     glTexParameteri(tdata->texture_type, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
   303     glTexParameteri(tdata->texture_type, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
   293     glTexImage2D(tdata->texture_type, 0, format, texture->w, texture->h, 0, format, type, NULL);
   304     glTexImage2D(tdata->texture_type, 0, format, texture->w, texture->h, 0, format, type, NULL);
   294     if (glGetError() != GL_NO_ERROR)
   305     if (glGetError() != GL_NO_ERROR)
   295     {
   306     {