Mercurial > sdl-ios-xcode
comparison 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 |
comparison
equal
deleted
inserted
replaced
3456:6b182cbe38ac | 3457:06e948183b59 |
---|---|
1053 SDL_AddDirtyRect(&data->dirty, &rects[i]); | 1053 SDL_AddDirtyRect(&data->dirty, &rects[i]); |
1054 } | 1054 } |
1055 } | 1055 } |
1056 | 1056 |
1057 static void | 1057 static void |
1058 GL_SetBlendMode(GL_RenderData * data, int blendMode, int isprimitive) | 1058 GL_SetBlendMode(GL_RenderData * data, int blendMode) |
1059 { | 1059 { |
1060 if (blendMode != data->blendMode) { | 1060 if (blendMode != data->blendMode) { |
1061 switch (blendMode) { | 1061 switch (blendMode) { |
1062 case SDL_BLENDMODE_NONE: | 1062 case SDL_BLENDMODE_NONE: |
1063 data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); | 1063 data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
1064 data->glDisable(GL_BLEND); | 1064 data->glDisable(GL_BLEND); |
1065 break; | 1065 break; |
1066 case SDL_BLENDMODE_MASK: | 1066 case SDL_BLENDMODE_MASK: |
1067 if (isprimitive) { | 1067 data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
1068 data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); | 1068 data->glEnable(GL_BLEND); |
1069 data->glDisable(GL_BLEND); | 1069 data->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
1070 /* The same as SDL_BLENDMODE_NONE */ | 1070 break; |
1071 blendMode = SDL_BLENDMODE_NONE; | |
1072 break; | |
1073 } | |
1074 /* fall through */ | |
1075 case SDL_BLENDMODE_BLEND: | 1071 case SDL_BLENDMODE_BLEND: |
1076 data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); | 1072 data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); |
1077 data->glEnable(GL_BLEND); | 1073 data->glEnable(GL_BLEND); |
1078 data->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); | 1074 data->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
1079 break; | 1075 break; |
1095 static int | 1091 static int |
1096 GL_RenderPoint(SDL_Renderer * renderer, int x, int y) | 1092 GL_RenderPoint(SDL_Renderer * renderer, int x, int y) |
1097 { | 1093 { |
1098 GL_RenderData *data = (GL_RenderData *) renderer->driverdata; | 1094 GL_RenderData *data = (GL_RenderData *) renderer->driverdata; |
1099 | 1095 |
1100 GL_SetBlendMode(data, renderer->blendMode, 1); | 1096 GL_SetBlendMode(data, renderer->blendMode); |
1101 | 1097 |
1102 data->glColor4f((GLfloat) renderer->r * inv255f, | 1098 data->glColor4f((GLfloat) renderer->r * inv255f, |
1103 (GLfloat) renderer->g * inv255f, | 1099 (GLfloat) renderer->g * inv255f, |
1104 (GLfloat) renderer->b * inv255f, | 1100 (GLfloat) renderer->b * inv255f, |
1105 (GLfloat) renderer->a * inv255f); | 1101 (GLfloat) renderer->a * inv255f); |
1114 static int | 1110 static int |
1115 GL_RenderLine(SDL_Renderer * renderer, int x1, int y1, int x2, int y2) | 1111 GL_RenderLine(SDL_Renderer * renderer, int x1, int y1, int x2, int y2) |
1116 { | 1112 { |
1117 GL_RenderData *data = (GL_RenderData *) renderer->driverdata; | 1113 GL_RenderData *data = (GL_RenderData *) renderer->driverdata; |
1118 | 1114 |
1119 GL_SetBlendMode(data, renderer->blendMode, 1); | 1115 GL_SetBlendMode(data, renderer->blendMode); |
1120 | 1116 |
1121 data->glColor4f((GLfloat) renderer->r * inv255f, | 1117 data->glColor4f((GLfloat) renderer->r * inv255f, |
1122 (GLfloat) renderer->g * inv255f, | 1118 (GLfloat) renderer->g * inv255f, |
1123 (GLfloat) renderer->b * inv255f, | 1119 (GLfloat) renderer->b * inv255f, |
1124 (GLfloat) renderer->a * inv255f); | 1120 (GLfloat) renderer->a * inv255f); |
1139 static int | 1135 static int |
1140 GL_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect) | 1136 GL_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect) |
1141 { | 1137 { |
1142 GL_RenderData *data = (GL_RenderData *) renderer->driverdata; | 1138 GL_RenderData *data = (GL_RenderData *) renderer->driverdata; |
1143 | 1139 |
1144 GL_SetBlendMode(data, renderer->blendMode, 1); | 1140 GL_SetBlendMode(data, renderer->blendMode); |
1145 | 1141 |
1146 data->glColor4f((GLfloat) renderer->r * inv255f, | 1142 data->glColor4f((GLfloat) renderer->r * inv255f, |
1147 (GLfloat) renderer->g * inv255f, | 1143 (GLfloat) renderer->g * inv255f, |
1148 (GLfloat) renderer->b * inv255f, | 1144 (GLfloat) renderer->b * inv255f, |
1149 (GLfloat) renderer->a * inv255f); | 1145 (GLfloat) renderer->a * inv255f); |
1208 (GLfloat) texture->a * inv255f); | 1204 (GLfloat) texture->a * inv255f); |
1209 } else { | 1205 } else { |
1210 data->glColor4f(1.0f, 1.0f, 1.0f, 1.0f); | 1206 data->glColor4f(1.0f, 1.0f, 1.0f, 1.0f); |
1211 } | 1207 } |
1212 | 1208 |
1213 GL_SetBlendMode(data, texture->blendMode, 0); | 1209 GL_SetBlendMode(data, texture->blendMode); |
1214 | 1210 |
1215 if (texture->scaleMode != data->scaleMode) { | 1211 if (texture->scaleMode != data->scaleMode) { |
1216 switch (texture->scaleMode) { | 1212 switch (texture->scaleMode) { |
1217 case SDL_TEXTURESCALEMODE_NONE: | 1213 case SDL_TEXTURESCALEMODE_NONE: |
1218 case SDL_TEXTURESCALEMODE_FAST: | 1214 case SDL_TEXTURESCALEMODE_FAST: |