Mercurial > sdl-ios-xcode
comparison src/video/SDL_renderer_gl.c @ 3458:0aed0755d1f1
Mike Gorchak to Sam
Hello Sam!
You have reverted back my patches for OpenGL renderer :)
To reproduce an issue, compare graphics output while running these tests:
testdraw2 --renderer opengl --blend mask --cyclealpha
and
testdraw2 --renderer software --blend mask --cyclealpha
You will see, that software renderer output is different from opengl renderer output.
Thanks!
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Thu, 19 Nov 2009 08:02:00 +0000 |
parents | 06e948183b59 |
children | 789b97008d8a |
comparison
equal
deleted
inserted
replaced
3457:06e948183b59 | 3458:0aed0755d1f1 |
---|---|
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) | 1058 GL_SetBlendMode(GL_RenderData * data, int blendMode, int isprimitive) |
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 data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); | 1067 if (isprimitive) { |
1068 data->glEnable(GL_BLEND); | 1068 /* The same as SDL_BLENDMODE_NONE */ |
1069 data->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); | 1069 blendMode = SDL_BLENDMODE_NONE; |
1070 data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); | |
1071 data->glDisable(GL_BLEND); | |
1072 } else { | |
1073 data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); | |
1074 data->glEnable(GL_BLEND); | |
1075 data->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); | |
1076 } | |
1070 break; | 1077 break; |
1071 case SDL_BLENDMODE_BLEND: | 1078 case SDL_BLENDMODE_BLEND: |
1072 data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); | 1079 data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); |
1073 data->glEnable(GL_BLEND); | 1080 data->glEnable(GL_BLEND); |
1074 data->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); | 1081 data->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); |
1091 static int | 1098 static int |
1092 GL_RenderPoint(SDL_Renderer * renderer, int x, int y) | 1099 GL_RenderPoint(SDL_Renderer * renderer, int x, int y) |
1093 { | 1100 { |
1094 GL_RenderData *data = (GL_RenderData *) renderer->driverdata; | 1101 GL_RenderData *data = (GL_RenderData *) renderer->driverdata; |
1095 | 1102 |
1096 GL_SetBlendMode(data, renderer->blendMode); | 1103 GL_SetBlendMode(data, renderer->blendMode, 1); |
1097 | 1104 |
1098 data->glColor4f((GLfloat) renderer->r * inv255f, | 1105 data->glColor4f((GLfloat) renderer->r * inv255f, |
1099 (GLfloat) renderer->g * inv255f, | 1106 (GLfloat) renderer->g * inv255f, |
1100 (GLfloat) renderer->b * inv255f, | 1107 (GLfloat) renderer->b * inv255f, |
1101 (GLfloat) renderer->a * inv255f); | 1108 (GLfloat) renderer->a * inv255f); |
1110 static int | 1117 static int |
1111 GL_RenderLine(SDL_Renderer * renderer, int x1, int y1, int x2, int y2) | 1118 GL_RenderLine(SDL_Renderer * renderer, int x1, int y1, int x2, int y2) |
1112 { | 1119 { |
1113 GL_RenderData *data = (GL_RenderData *) renderer->driverdata; | 1120 GL_RenderData *data = (GL_RenderData *) renderer->driverdata; |
1114 | 1121 |
1115 GL_SetBlendMode(data, renderer->blendMode); | 1122 GL_SetBlendMode(data, renderer->blendMode, 1); |
1116 | 1123 |
1117 data->glColor4f((GLfloat) renderer->r * inv255f, | 1124 data->glColor4f((GLfloat) renderer->r * inv255f, |
1118 (GLfloat) renderer->g * inv255f, | 1125 (GLfloat) renderer->g * inv255f, |
1119 (GLfloat) renderer->b * inv255f, | 1126 (GLfloat) renderer->b * inv255f, |
1120 (GLfloat) renderer->a * inv255f); | 1127 (GLfloat) renderer->a * inv255f); |
1135 static int | 1142 static int |
1136 GL_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect) | 1143 GL_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect) |
1137 { | 1144 { |
1138 GL_RenderData *data = (GL_RenderData *) renderer->driverdata; | 1145 GL_RenderData *data = (GL_RenderData *) renderer->driverdata; |
1139 | 1146 |
1140 GL_SetBlendMode(data, renderer->blendMode); | 1147 GL_SetBlendMode(data, renderer->blendMode, 1); |
1141 | 1148 |
1142 data->glColor4f((GLfloat) renderer->r * inv255f, | 1149 data->glColor4f((GLfloat) renderer->r * inv255f, |
1143 (GLfloat) renderer->g * inv255f, | 1150 (GLfloat) renderer->g * inv255f, |
1144 (GLfloat) renderer->b * inv255f, | 1151 (GLfloat) renderer->b * inv255f, |
1145 (GLfloat) renderer->a * inv255f); | 1152 (GLfloat) renderer->a * inv255f); |
1204 (GLfloat) texture->a * inv255f); | 1211 (GLfloat) texture->a * inv255f); |
1205 } else { | 1212 } else { |
1206 data->glColor4f(1.0f, 1.0f, 1.0f, 1.0f); | 1213 data->glColor4f(1.0f, 1.0f, 1.0f, 1.0f); |
1207 } | 1214 } |
1208 | 1215 |
1209 GL_SetBlendMode(data, texture->blendMode); | 1216 GL_SetBlendMode(data, texture->blendMode, 0); |
1210 | 1217 |
1211 if (texture->scaleMode != data->scaleMode) { | 1218 if (texture->scaleMode != data->scaleMode) { |
1212 switch (texture->scaleMode) { | 1219 switch (texture->scaleMode) { |
1213 case SDL_TEXTURESCALEMODE_NONE: | 1220 case SDL_TEXTURESCALEMODE_NONE: |
1214 case SDL_TEXTURESCALEMODE_FAST: | 1221 case SDL_TEXTURESCALEMODE_FAST: |