diff src/video/SDL_renderer_gl.c @ 3457:06e948183b59

Found a way to implement mask semantics in OpenGL
author Sam Lantinga <slouken@libsdl.org>
date Thu, 19 Nov 2009 05:33:41 +0000
parents 5a7b5760c875
children 0aed0755d1f1
line wrap: on
line diff
--- a/src/video/SDL_renderer_gl.c	Thu Nov 19 05:06:01 2009 +0000
+++ b/src/video/SDL_renderer_gl.c	Thu Nov 19 05:33:41 2009 +0000
@@ -1055,7 +1055,7 @@
 }
 
 static void
-GL_SetBlendMode(GL_RenderData * data, int blendMode, int isprimitive)
+GL_SetBlendMode(GL_RenderData * data, int blendMode)
 {
     if (blendMode != data->blendMode) {
         switch (blendMode) {
@@ -1064,14 +1064,10 @@
             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 */
+            data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+            data->glEnable(GL_BLEND);
+            data->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+            break;
         case SDL_BLENDMODE_BLEND:
             data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
             data->glEnable(GL_BLEND);
@@ -1097,7 +1093,7 @@
 {
     GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
 
-    GL_SetBlendMode(data, renderer->blendMode, 1);
+    GL_SetBlendMode(data, renderer->blendMode);
 
     data->glColor4f((GLfloat) renderer->r * inv255f,
                     (GLfloat) renderer->g * inv255f,
@@ -1116,7 +1112,7 @@
 {
     GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
 
-    GL_SetBlendMode(data, renderer->blendMode, 1);
+    GL_SetBlendMode(data, renderer->blendMode);
 
     data->glColor4f((GLfloat) renderer->r * inv255f,
                     (GLfloat) renderer->g * inv255f,
@@ -1141,7 +1137,7 @@
 {
     GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
 
-    GL_SetBlendMode(data, renderer->blendMode, 1);
+    GL_SetBlendMode(data, renderer->blendMode);
 
     data->glColor4f((GLfloat) renderer->r * inv255f,
                     (GLfloat) renderer->g * inv255f,
@@ -1210,7 +1206,7 @@
         data->glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
     }
 
-    GL_SetBlendMode(data, texture->blendMode, 0);
+    GL_SetBlendMode(data, texture->blendMode);
 
     if (texture->scaleMode != data->scaleMode) {
         switch (texture->scaleMode) {