src/render/opengles2/SDL_render_gles2.c
changeset 7037 3fedf1f25b94
parent 6955 a3ebd92ff0b2
child 7075 f4a3c5a68119
     1.1 --- a/src/render/opengles2/SDL_render_gles2.c	Fri Mar 29 21:29:57 2013 -0400
     1.2 +++ b/src/render/opengles2/SDL_render_gles2.c	Sun Mar 31 12:48:50 2013 -0400
     1.3 @@ -189,8 +189,7 @@
     1.4      do { \
     1.5          data->func = SDL_GL_GetProcAddress(#func); \
     1.6          if ( ! data->func ) { \
     1.7 -            SDL_SetError("Couldn't load GLES2 function %s: %s\n", #func, SDL_GetError()); \
     1.8 -            return -1; \
     1.9 +            return SDL_SetError("Couldn't load GLES2 function %s: %s\n", #func, SDL_GetError()); \
    1.10          } \
    1.11      } while ( 0 );
    1.12  #endif /* _SDL_NOGETPROCADDR_ */
    1.13 @@ -372,16 +371,13 @@
    1.14          type = GL_UNSIGNED_BYTE;
    1.15          break;
    1.16      default:
    1.17 -        SDL_SetError("Texture format not supported");
    1.18 -        return -1;
    1.19 +        return SDL_SetError("Texture format not supported");
    1.20      }
    1.21  
    1.22      /* Allocate a texture struct */
    1.23      tdata = (GLES2_TextureData *)SDL_calloc(1, sizeof(GLES2_TextureData));
    1.24 -    if (!tdata)
    1.25 -    {
    1.26 -        SDL_OutOfMemory();
    1.27 -        return -1;
    1.28 +    if (!tdata) {
    1.29 +        return SDL_OutOfMemory();
    1.30      }
    1.31      tdata->texture = 0;
    1.32      tdata->texture_type = GL_TEXTURE_2D;
    1.33 @@ -390,15 +386,12 @@
    1.34      scaleMode = GetScaleQuality();
    1.35  
    1.36      /* Allocate a blob for image data */
    1.37 -    if (texture->access == SDL_TEXTUREACCESS_STREAMING)
    1.38 -    {
    1.39 +    if (texture->access == SDL_TEXTUREACCESS_STREAMING) {
    1.40          tdata->pitch = texture->w * SDL_BYTESPERPIXEL(texture->format);
    1.41          tdata->pixel_data = SDL_calloc(1, tdata->pitch * texture->h);
    1.42 -        if (!tdata->pixel_data)
    1.43 -        {
    1.44 -            SDL_OutOfMemory();
    1.45 +        if (!tdata->pixel_data) {
    1.46              SDL_free(tdata);
    1.47 -            return -1;
    1.48 +            return SDL_OutOfMemory();
    1.49          }
    1.50      }
    1.51  
    1.52 @@ -414,10 +407,9 @@
    1.53      rdata->glTexImage2D(tdata->texture_type, 0, format, texture->w, texture->h, 0, format, type, NULL);
    1.54      if (rdata->glGetError() != GL_NO_ERROR)
    1.55      {
    1.56 -        SDL_SetError("Texture creation failed");
    1.57          rdata->glDeleteTextures(1, &tdata->texture);
    1.58          SDL_free(tdata);
    1.59 -        return -1;
    1.60 +        return SDL_SetError("Texture creation failed");
    1.61      }
    1.62      texture->driverdata = tdata;
    1.63  
    1.64 @@ -497,13 +489,10 @@
    1.65      /* Reformat the texture data into a tightly packed array */
    1.66      srcPitch = rect->w * SDL_BYTESPERPIXEL(texture->format);
    1.67      src = (Uint8 *)pixels;
    1.68 -    if (pitch != srcPitch)
    1.69 -    {
    1.70 +    if (pitch != srcPitch) {
    1.71          blob = (Uint8 *)SDL_malloc(srcPitch * rect->h);
    1.72 -        if (!blob)
    1.73 -        {
    1.74 -            SDL_OutOfMemory();
    1.75 -            return -1;
    1.76 +        if (!blob) {
    1.77 +            return SDL_OutOfMemory();
    1.78          }
    1.79          src = blob;
    1.80          for (y = 0; y < rect->h; ++y)
    1.81 @@ -533,10 +522,8 @@
    1.82          SDL_free(blob);
    1.83      }
    1.84  
    1.85 -    if (rdata->glGetError() != GL_NO_ERROR)
    1.86 -    {
    1.87 -        SDL_SetError("Failed to update texture");
    1.88 -        return -1;
    1.89 +    if (rdata->glGetError() != GL_NO_ERROR) {
    1.90 +        return SDL_SetError("Failed to update texture");
    1.91      }
    1.92      return 0;
    1.93  }
    1.94 @@ -558,8 +545,7 @@
    1.95          /* Check FBO status */
    1.96          status = data->glCheckFramebufferStatus(GL_FRAMEBUFFER);
    1.97          if (status != GL_FRAMEBUFFER_COMPLETE) {
    1.98 -            SDL_SetError("glFramebufferTexture2D() failed");
    1.99 -            return -1;
   1.100 +            return SDL_SetError("glFramebufferTexture2D() failed");
   1.101          }
   1.102      }
   1.103      return 0;
   1.104 @@ -636,9 +622,9 @@
   1.105      rdata->glGetProgramiv(entry->id, GL_LINK_STATUS, &linkSuccessful);
   1.106      if (rdata->glGetError() != GL_NO_ERROR || !linkSuccessful)
   1.107      {
   1.108 -        SDL_SetError("Failed to link shader program");
   1.109          rdata->glDeleteProgram(entry->id);
   1.110          SDL_free(entry);
   1.111 +        SDL_SetError("Failed to link shader program");
   1.112          return NULL;
   1.113      }
   1.114  
   1.115 @@ -930,10 +916,8 @@
   1.116      locProjection = rdata->current_program->uniform_locations[GLES2_UNIFORM_PROJECTION];
   1.117      rdata->glGetError();
   1.118      rdata->glUniformMatrix4fv(locProjection, 1, GL_FALSE, (GLfloat *)projection);
   1.119 -    if (rdata->glGetError() != GL_NO_ERROR)
   1.120 -    {
   1.121 -        SDL_SetError("Failed to set orthographic projection");
   1.122 -        return -1;
   1.123 +    if (rdata->glGetError() != GL_NO_ERROR) {
   1.124 +        return SDL_SetError("Failed to set orthographic projection");
   1.125      }
   1.126      return 0;
   1.127  }
   1.128 @@ -1066,8 +1050,7 @@
   1.129  
   1.130      /* Emit the specified vertices as points */
   1.131      vertices = SDL_stack_alloc(GLfloat, count * 2);
   1.132 -    for (idx = 0; idx < count; ++idx)
   1.133 -    {
   1.134 +    for (idx = 0; idx < count; ++idx) {
   1.135          GLfloat x = points[idx].x + 0.5f;
   1.136          GLfloat y = points[idx].y + 0.5f;
   1.137  
   1.138 @@ -1078,10 +1061,8 @@
   1.139      rdata->glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);
   1.140      rdata->glDrawArrays(GL_POINTS, 0, count);
   1.141      SDL_stack_free(vertices);
   1.142 -    if (rdata->glGetError() != GL_NO_ERROR)
   1.143 -    {
   1.144 -        SDL_SetError("Failed to render lines");
   1.145 -        return -1;
   1.146 +    if (rdata->glGetError() != GL_NO_ERROR) {
   1.147 +        return SDL_SetError("Failed to render lines");
   1.148      }
   1.149      return 0;
   1.150  }
   1.151 @@ -1099,8 +1080,7 @@
   1.152  
   1.153      /* Emit a line strip including the specified vertices */
   1.154      vertices = SDL_stack_alloc(GLfloat, count * 2);
   1.155 -    for (idx = 0; idx < count; ++idx)
   1.156 -    {
   1.157 +    for (idx = 0; idx < count; ++idx) {
   1.158          GLfloat x = points[idx].x + 0.5f;
   1.159          GLfloat y = points[idx].y + 0.5f;
   1.160  
   1.161 @@ -1117,10 +1097,8 @@
   1.162          rdata->glDrawArrays(GL_POINTS, count-1, 1);
   1.163      }
   1.164      SDL_stack_free(vertices);
   1.165 -    if (rdata->glGetError() != GL_NO_ERROR)
   1.166 -    {
   1.167 -        SDL_SetError("Failed to render lines");
   1.168 -        return -1;
   1.169 +    if (rdata->glGetError() != GL_NO_ERROR) {
   1.170 +        return SDL_SetError("Failed to render lines");
   1.171      }
   1.172      return 0;
   1.173  }
   1.174 @@ -1157,10 +1135,8 @@
   1.175          rdata->glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices);
   1.176          rdata->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
   1.177      }
   1.178 -    if (rdata->glGetError() != GL_NO_ERROR)
   1.179 -    {
   1.180 -        SDL_SetError("Failed to render lines");
   1.181 -        return -1;
   1.182 +    if (rdata->glGetError() != GL_NO_ERROR) {
   1.183 +        return SDL_SetError("Failed to render lines");
   1.184      }
   1.185      return 0;
   1.186  }
   1.187 @@ -1315,10 +1291,8 @@
   1.188      texCoords[7] = (srcrect->y + srcrect->h) / (GLfloat)texture->h;
   1.189      rdata->glVertexAttribPointer(GLES2_ATTRIBUTE_TEXCOORD, 2, GL_FLOAT, GL_FALSE, 0, texCoords);
   1.190      rdata->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
   1.191 -    if (rdata->glGetError() != GL_NO_ERROR)
   1.192 -    {
   1.193 -        SDL_SetError("Failed to render texture");
   1.194 -        return -1;
   1.195 +    if (rdata->glGetError() != GL_NO_ERROR) {
   1.196 +        return SDL_SetError("Failed to render texture");
   1.197      }
   1.198      return 0;
   1.199  }
   1.200 @@ -1499,10 +1473,8 @@
   1.201      rdata->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
   1.202      rdata->glDisableVertexAttribArray(GLES2_ATTRIBUTE_CENTER);
   1.203      rdata->glDisableVertexAttribArray(GLES2_ATTRIBUTE_ANGLE);
   1.204 -    if (rdata->glGetError() != GL_NO_ERROR)
   1.205 -    {
   1.206 -        SDL_SetError("Failed to render texture");
   1.207 -        return -1;
   1.208 +    if (rdata->glGetError() != GL_NO_ERROR) {
   1.209 +        return SDL_SetError("Failed to render texture");
   1.210      }
   1.211      return 0;
   1.212  }
   1.213 @@ -1525,8 +1497,7 @@
   1.214      temp_pitch = rect->w * SDL_BYTESPERPIXEL(temp_format);
   1.215      temp_pixels = SDL_malloc(rect->h * temp_pitch);
   1.216      if (!temp_pixels) {
   1.217 -        SDL_OutOfMemory();
   1.218 -        return -1;
   1.219 +        return SDL_OutOfMemory();
   1.220      }
   1.221  
   1.222      SDL_GetWindowSize(window, &w, &h);