diff src/video/SDL_renderer_gl.c @ 3393:fe2f10481878

Fixed SDL_BLENDMODE_MASK for GL and GLES renderers, now blending works like in software renderer.
author Mike Gorchak <lestat@i.com.ua>
date Tue, 13 Oct 2009 06:51:20 +0000
parents 0f19b2fa4125
children c8fbb27627d9
line wrap: on
line diff
--- 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) {