changeset 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 efc22582afc5
children 2b0a3b2f2fc6
files src/video/SDL_renderer_gl.c src/video/SDL_renderer_gles.c
diffstat 2 files changed, 26 insertions(+), 10 deletions(-) [+]
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) {
--- 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: