# HG changeset patch # User Mike Gorchak # Date 1255416680 0 # Node ID fe2f10481878f220e1fa5bddcd56ed7584b7e6a2 # Parent efc22582afc5e6101fba593a9a8833b1320bdb71 Fixed SDL_BLENDMODE_MASK for GL and GLES renderers, now blending works like in software renderer. diff -r efc22582afc5 -r fe2f10481878 src/video/SDL_renderer_gl.c --- a/src/video/SDL_renderer_gl.c Tue Oct 13 06:49:29 2009 +0000 +++ b/src/video/SDL_renderer_gl.c Tue Oct 13 06:51:20 2009 +0000 @@ -1038,7 +1038,7 @@ } static void -GL_SetBlendMode(GL_RenderData * data, int blendMode) +GL_SetBlendMode(GL_RenderData * data, int blendMode, int isprimitive) { if (blendMode != data->blendMode) { switch (blendMode) { @@ -1047,6 +1047,14 @@ data->glDisable(GL_BLEND); break; case SDL_BLENDMODE_MASK: + if (isprimitive) { + data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); + data->glDisable(GL_BLEND); + /* The same as SDL_BLENDMODE_NONE */ + blendMode = SDL_BLENDMODE_NONE; + break; + } + /* fall through */ case SDL_BLENDMODE_BLEND: data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); data->glEnable(GL_BLEND); @@ -1072,7 +1080,7 @@ { GL_RenderData *data = (GL_RenderData *) renderer->driverdata; - GL_SetBlendMode(data, renderer->blendMode); + GL_SetBlendMode(data, renderer->blendMode, 1); data->glColor4f((GLfloat) renderer->r * inv255f, (GLfloat) renderer->g * inv255f, @@ -1091,7 +1099,7 @@ { GL_RenderData *data = (GL_RenderData *) renderer->driverdata; - GL_SetBlendMode(data, renderer->blendMode); + GL_SetBlendMode(data, renderer->blendMode, 1); data->glColor4f((GLfloat) renderer->r * inv255f, (GLfloat) renderer->g * inv255f, @@ -1111,7 +1119,7 @@ { GL_RenderData *data = (GL_RenderData *) renderer->driverdata; - GL_SetBlendMode(data, renderer->blendMode); + GL_SetBlendMode(data, renderer->blendMode, 1); data->glColor4f((GLfloat) renderer->r * inv255f, (GLfloat) renderer->g * inv255f, @@ -1180,7 +1188,7 @@ data->glColor4f(1.0f, 1.0f, 1.0f, 1.0f); } - GL_SetBlendMode(data, texture->blendMode); + GL_SetBlendMode(data, texture->blendMode, 0); if (texture->scaleMode != data->scaleMode) { switch (texture->scaleMode) { diff -r efc22582afc5 -r fe2f10481878 src/video/SDL_renderer_gles.c --- a/src/video/SDL_renderer_gles.c Tue Oct 13 06:49:29 2009 +0000 +++ b/src/video/SDL_renderer_gles.c Tue Oct 13 06:51:20 2009 +0000 @@ -611,7 +611,7 @@ } static void -GLES_SetBlendMode(GLES_RenderData * data, int blendMode) +GLES_SetBlendMode(GLES_RenderData * data, int blendMode, int isprimitive) { if (blendMode != data->blendMode) { switch (blendMode) { @@ -620,6 +620,14 @@ data->glDisable(GL_BLEND); break; case SDL_BLENDMODE_MASK: + if (isprimitive) { + data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); + data->glDisable(GL_BLEND); + /* The same as SDL_BLENDMODE_NONE */ + blendMode = SDL_BLENDMODE_NONE; + break; + } + /* fall through */ case SDL_BLENDMODE_BLEND: data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); data->glEnable(GL_BLEND); @@ -645,7 +653,7 @@ { GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; - GLES_SetBlendMode(data, renderer->blendMode); + GLES_SetBlendMode(data, renderer->blendMode, 1); data->glColor4f((GLfloat) renderer->r * inv255f, (GLfloat) renderer->g * inv255f, @@ -669,7 +677,7 @@ { GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; - GLES_SetBlendMode(data, renderer->blendMode); + GLES_SetBlendMode(data, renderer->blendMode, 1); data->glColor4f((GLfloat) renderer->r * inv255f, (GLfloat) renderer->g * inv255f, @@ -695,7 +703,7 @@ { GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; - GLES_SetBlendMode(data, renderer->blendMode); + GLES_SetBlendMode(data, renderer->blendMode, 1); data->glColor4f((GLfloat) renderer->r * inv255f, (GLfloat) renderer->g * inv255f, @@ -789,7 +797,7 @@ data->glColor4f(1.0f, 1.0f, 1.0f, 1.0f); } - GLES_SetBlendMode(data, texture->blendMode); + GLES_SetBlendMode(data, texture->blendMode, 0); switch (texture->scaleMode) { case SDL_TEXTURESCALEMODE_NONE: