Fixed SDL_BLENDMODE_MASK for GL and GLES renderers, now blending works like in software renderer.
authorMike Gorchak <lestat@i.com.ua>
Tue, 13 Oct 2009 06:51:20 +0000
changeset 3393fe2f10481878
parent 3392 efc22582afc5
child 3394 2b0a3b2f2fc6
Fixed SDL_BLENDMODE_MASK for GL and GLES renderers, now blending works like in software renderer.
src/video/SDL_renderer_gl.c
src/video/SDL_renderer_gles.c
     1.1 --- a/src/video/SDL_renderer_gl.c	Tue Oct 13 06:49:29 2009 +0000
     1.2 +++ b/src/video/SDL_renderer_gl.c	Tue Oct 13 06:51:20 2009 +0000
     1.3 @@ -1038,7 +1038,7 @@
     1.4  }
     1.5  
     1.6  static void
     1.7 -GL_SetBlendMode(GL_RenderData * data, int blendMode)
     1.8 +GL_SetBlendMode(GL_RenderData * data, int blendMode, int isprimitive)
     1.9  {
    1.10      if (blendMode != data->blendMode) {
    1.11          switch (blendMode) {
    1.12 @@ -1047,6 +1047,14 @@
    1.13              data->glDisable(GL_BLEND);
    1.14              break;
    1.15          case SDL_BLENDMODE_MASK:
    1.16 +            if (isprimitive) {
    1.17 +                data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
    1.18 +                data->glDisable(GL_BLEND);
    1.19 +                /* The same as SDL_BLENDMODE_NONE */
    1.20 +                blendMode = SDL_BLENDMODE_NONE;
    1.21 +                break;
    1.22 +            }
    1.23 +            /* fall through */
    1.24          case SDL_BLENDMODE_BLEND:
    1.25              data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
    1.26              data->glEnable(GL_BLEND);
    1.27 @@ -1072,7 +1080,7 @@
    1.28  {
    1.29      GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
    1.30  
    1.31 -    GL_SetBlendMode(data, renderer->blendMode);
    1.32 +    GL_SetBlendMode(data, renderer->blendMode, 1);
    1.33  
    1.34      data->glColor4f((GLfloat) renderer->r * inv255f,
    1.35                      (GLfloat) renderer->g * inv255f,
    1.36 @@ -1091,7 +1099,7 @@
    1.37  {
    1.38      GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
    1.39  
    1.40 -    GL_SetBlendMode(data, renderer->blendMode);
    1.41 +    GL_SetBlendMode(data, renderer->blendMode, 1);
    1.42  
    1.43      data->glColor4f((GLfloat) renderer->r * inv255f,
    1.44                      (GLfloat) renderer->g * inv255f,
    1.45 @@ -1111,7 +1119,7 @@
    1.46  {
    1.47      GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
    1.48  
    1.49 -    GL_SetBlendMode(data, renderer->blendMode);
    1.50 +    GL_SetBlendMode(data, renderer->blendMode, 1);
    1.51  
    1.52      data->glColor4f((GLfloat) renderer->r * inv255f,
    1.53                      (GLfloat) renderer->g * inv255f,
    1.54 @@ -1180,7 +1188,7 @@
    1.55          data->glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
    1.56      }
    1.57  
    1.58 -    GL_SetBlendMode(data, texture->blendMode);
    1.59 +    GL_SetBlendMode(data, texture->blendMode, 0);
    1.60  
    1.61      if (texture->scaleMode != data->scaleMode) {
    1.62          switch (texture->scaleMode) {
     2.1 --- a/src/video/SDL_renderer_gles.c	Tue Oct 13 06:49:29 2009 +0000
     2.2 +++ b/src/video/SDL_renderer_gles.c	Tue Oct 13 06:51:20 2009 +0000
     2.3 @@ -611,7 +611,7 @@
     2.4  }
     2.5  
     2.6  static void
     2.7 -GLES_SetBlendMode(GLES_RenderData * data, int blendMode)
     2.8 +GLES_SetBlendMode(GLES_RenderData * data, int blendMode, int isprimitive)
     2.9  {
    2.10      if (blendMode != data->blendMode) {
    2.11          switch (blendMode) {
    2.12 @@ -620,6 +620,14 @@
    2.13              data->glDisable(GL_BLEND);
    2.14              break;
    2.15          case SDL_BLENDMODE_MASK:
    2.16 +            if (isprimitive) {
    2.17 +                data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
    2.18 +                data->glDisable(GL_BLEND);
    2.19 +                /* The same as SDL_BLENDMODE_NONE */
    2.20 +                blendMode = SDL_BLENDMODE_NONE;
    2.21 +                break;
    2.22 +            }
    2.23 +            /* fall through */
    2.24          case SDL_BLENDMODE_BLEND:
    2.25              data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
    2.26              data->glEnable(GL_BLEND);
    2.27 @@ -645,7 +653,7 @@
    2.28  {
    2.29      GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
    2.30  
    2.31 -    GLES_SetBlendMode(data, renderer->blendMode);
    2.32 +    GLES_SetBlendMode(data, renderer->blendMode, 1);
    2.33  
    2.34      data->glColor4f((GLfloat) renderer->r * inv255f,
    2.35                      (GLfloat) renderer->g * inv255f,
    2.36 @@ -669,7 +677,7 @@
    2.37  {
    2.38      GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
    2.39  
    2.40 -    GLES_SetBlendMode(data, renderer->blendMode);
    2.41 +    GLES_SetBlendMode(data, renderer->blendMode, 1);
    2.42  
    2.43      data->glColor4f((GLfloat) renderer->r * inv255f,
    2.44                      (GLfloat) renderer->g * inv255f,
    2.45 @@ -695,7 +703,7 @@
    2.46  {
    2.47      GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
    2.48  
    2.49 -    GLES_SetBlendMode(data, renderer->blendMode);
    2.50 +    GLES_SetBlendMode(data, renderer->blendMode, 1);
    2.51  
    2.52      data->glColor4f((GLfloat) renderer->r * inv255f,
    2.53                      (GLfloat) renderer->g * inv255f,
    2.54 @@ -789,7 +797,7 @@
    2.55          data->glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
    2.56      }
    2.57  
    2.58 -    GLES_SetBlendMode(data, texture->blendMode);
    2.59 +    GLES_SetBlendMode(data, texture->blendMode, 0);
    2.60  
    2.61      switch (texture->scaleMode) {
    2.62      case SDL_TEXTURESCALEMODE_NONE: