comparison 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
comparison
equal deleted inserted replaced
3392:efc22582afc5 3393:fe2f10481878
1036 SDL_AddDirtyRect(&data->dirty, &rects[i]); 1036 SDL_AddDirtyRect(&data->dirty, &rects[i]);
1037 } 1037 }
1038 } 1038 }
1039 1039
1040 static void 1040 static void
1041 GL_SetBlendMode(GL_RenderData * data, int blendMode) 1041 GL_SetBlendMode(GL_RenderData * data, int blendMode, int isprimitive)
1042 { 1042 {
1043 if (blendMode != data->blendMode) { 1043 if (blendMode != data->blendMode) {
1044 switch (blendMode) { 1044 switch (blendMode) {
1045 case SDL_BLENDMODE_NONE: 1045 case SDL_BLENDMODE_NONE:
1046 data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); 1046 data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
1047 data->glDisable(GL_BLEND); 1047 data->glDisable(GL_BLEND);
1048 break; 1048 break;
1049 case SDL_BLENDMODE_MASK: 1049 case SDL_BLENDMODE_MASK:
1050 if (isprimitive) {
1051 data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
1052 data->glDisable(GL_BLEND);
1053 /* The same as SDL_BLENDMODE_NONE */
1054 blendMode = SDL_BLENDMODE_NONE;
1055 break;
1056 }
1057 /* fall through */
1050 case SDL_BLENDMODE_BLEND: 1058 case SDL_BLENDMODE_BLEND:
1051 data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); 1059 data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
1052 data->glEnable(GL_BLEND); 1060 data->glEnable(GL_BLEND);
1053 data->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 1061 data->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
1054 break; 1062 break;
1070 static int 1078 static int
1071 GL_RenderPoint(SDL_Renderer * renderer, int x, int y) 1079 GL_RenderPoint(SDL_Renderer * renderer, int x, int y)
1072 { 1080 {
1073 GL_RenderData *data = (GL_RenderData *) renderer->driverdata; 1081 GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
1074 1082
1075 GL_SetBlendMode(data, renderer->blendMode); 1083 GL_SetBlendMode(data, renderer->blendMode, 1);
1076 1084
1077 data->glColor4f((GLfloat) renderer->r * inv255f, 1085 data->glColor4f((GLfloat) renderer->r * inv255f,
1078 (GLfloat) renderer->g * inv255f, 1086 (GLfloat) renderer->g * inv255f,
1079 (GLfloat) renderer->b * inv255f, 1087 (GLfloat) renderer->b * inv255f,
1080 (GLfloat) renderer->a * inv255f); 1088 (GLfloat) renderer->a * inv255f);
1089 static int 1097 static int
1090 GL_RenderLine(SDL_Renderer * renderer, int x1, int y1, int x2, int y2) 1098 GL_RenderLine(SDL_Renderer * renderer, int x1, int y1, int x2, int y2)
1091 { 1099 {
1092 GL_RenderData *data = (GL_RenderData *) renderer->driverdata; 1100 GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
1093 1101
1094 GL_SetBlendMode(data, renderer->blendMode); 1102 GL_SetBlendMode(data, renderer->blendMode, 1);
1095 1103
1096 data->glColor4f((GLfloat) renderer->r * inv255f, 1104 data->glColor4f((GLfloat) renderer->r * inv255f,
1097 (GLfloat) renderer->g * inv255f, 1105 (GLfloat) renderer->g * inv255f,
1098 (GLfloat) renderer->b * inv255f, 1106 (GLfloat) renderer->b * inv255f,
1099 (GLfloat) renderer->a * inv255f); 1107 (GLfloat) renderer->a * inv255f);
1109 static int 1117 static int
1110 GL_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect) 1118 GL_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect)
1111 { 1119 {
1112 GL_RenderData *data = (GL_RenderData *) renderer->driverdata; 1120 GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
1113 1121
1114 GL_SetBlendMode(data, renderer->blendMode); 1122 GL_SetBlendMode(data, renderer->blendMode, 1);
1115 1123
1116 data->glColor4f((GLfloat) renderer->r * inv255f, 1124 data->glColor4f((GLfloat) renderer->r * inv255f,
1117 (GLfloat) renderer->g * inv255f, 1125 (GLfloat) renderer->g * inv255f,
1118 (GLfloat) renderer->b * inv255f, 1126 (GLfloat) renderer->b * inv255f,
1119 (GLfloat) renderer->a * inv255f); 1127 (GLfloat) renderer->a * inv255f);
1178 (GLfloat) texture->a * inv255f); 1186 (GLfloat) texture->a * inv255f);
1179 } else { 1187 } else {
1180 data->glColor4f(1.0f, 1.0f, 1.0f, 1.0f); 1188 data->glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
1181 } 1189 }
1182 1190
1183 GL_SetBlendMode(data, texture->blendMode); 1191 GL_SetBlendMode(data, texture->blendMode, 0);
1184 1192
1185 if (texture->scaleMode != data->scaleMode) { 1193 if (texture->scaleMode != data->scaleMode) {
1186 switch (texture->scaleMode) { 1194 switch (texture->scaleMode) {
1187 case SDL_TEXTURESCALEMODE_NONE: 1195 case SDL_TEXTURESCALEMODE_NONE:
1188 case SDL_TEXTURESCALEMODE_FAST: 1196 case SDL_TEXTURESCALEMODE_FAST: