Mercurial > sdl-ios-xcode
comparison src/video/SDL_renderer_gl.c @ 2936:066384910f50
iPhone build compiles again (drawing routines need to be implemented)
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Wed, 31 Dec 2008 07:56:56 +0000 |
parents | 2133d2d300fd |
children | 017d4334accf |
comparison
equal
deleted
inserted
replaced
2935:59e3e0aaa725 | 2936:066384910f50 |
---|---|
430 data->glEnable(GL_TEXTURE_2D); | 430 data->glEnable(GL_TEXTURE_2D); |
431 } | 431 } |
432 data->updateSize = SDL_TRUE; | 432 data->updateSize = SDL_TRUE; |
433 | 433 |
434 return renderer; | 434 return renderer; |
435 } | |
436 | |
437 static void | |
438 SetBlendMode(GL_RenderData * data, int blendMode) | |
439 { | |
440 if (blendMode != data->blendMode) { | |
441 switch (blendMode) { | |
442 case SDL_BLENDMODE_NONE: | |
443 data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); | |
444 data->glDisable(GL_BLEND); | |
445 break; | |
446 case SDL_BLENDMODE_MASK: | |
447 case SDL_BLENDMODE_BLEND: | |
448 data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); | |
449 data->glEnable(GL_BLEND); | |
450 data->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); | |
451 break; | |
452 case SDL_BLENDMODE_ADD: | |
453 data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); | |
454 data->glEnable(GL_BLEND); | |
455 data->glBlendFunc(GL_SRC_ALPHA, GL_ONE); | |
456 break; | |
457 case SDL_BLENDMODE_MOD: | |
458 data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); | |
459 data->glEnable(GL_BLEND); | |
460 data->glBlendFunc(GL_ZERO, GL_SRC_COLOR); | |
461 break; | |
462 } | |
463 data->blendMode = blendMode; | |
464 } | |
465 } | 435 } |
466 | 436 |
467 static int | 437 static int |
468 GL_ActivateRenderer(SDL_Renderer * renderer) | 438 GL_ActivateRenderer(SDL_Renderer * renderer) |
469 { | 439 { |
1064 for (i = 0; i < numrects; ++i) { | 1034 for (i = 0; i < numrects; ++i) { |
1065 SDL_AddDirtyRect(&data->dirty, &rects[i]); | 1035 SDL_AddDirtyRect(&data->dirty, &rects[i]); |
1066 } | 1036 } |
1067 } | 1037 } |
1068 | 1038 |
1039 static void | |
1040 GL_SetBlendMode(GL_RenderData * data, int blendMode) | |
1041 { | |
1042 if (blendMode != data->blendMode) { | |
1043 switch (blendMode) { | |
1044 case SDL_BLENDMODE_NONE: | |
1045 data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); | |
1046 data->glDisable(GL_BLEND); | |
1047 break; | |
1048 case SDL_BLENDMODE_MASK: | |
1049 case SDL_BLENDMODE_BLEND: | |
1050 data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); | |
1051 data->glEnable(GL_BLEND); | |
1052 data->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); | |
1053 break; | |
1054 case SDL_BLENDMODE_ADD: | |
1055 data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); | |
1056 data->glEnable(GL_BLEND); | |
1057 data->glBlendFunc(GL_SRC_ALPHA, GL_ONE); | |
1058 break; | |
1059 case SDL_BLENDMODE_MOD: | |
1060 data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); | |
1061 data->glEnable(GL_BLEND); | |
1062 data->glBlendFunc(GL_ZERO, GL_SRC_COLOR); | |
1063 break; | |
1064 } | |
1065 data->blendMode = blendMode; | |
1066 } | |
1067 } | |
1068 | |
1069 static int | 1069 static int |
1070 GL_RenderPoint(SDL_Renderer * renderer, int x, int y) | 1070 GL_RenderPoint(SDL_Renderer * renderer, int x, int y) |
1071 { | 1071 { |
1072 GL_RenderData *data = (GL_RenderData *) renderer->driverdata; | 1072 GL_RenderData *data = (GL_RenderData *) renderer->driverdata; |
1073 | 1073 |
1074 SetBlendMode(data, renderer->blendMode); | 1074 GL_SetBlendMode(data, renderer->blendMode); |
1075 | 1075 |
1076 data->glColor4f((GLfloat) renderer->r * inv255f, | 1076 data->glColor4f((GLfloat) renderer->r * inv255f, |
1077 (GLfloat) renderer->g * inv255f, | 1077 (GLfloat) renderer->g * inv255f, |
1078 (GLfloat) renderer->b * inv255f, | 1078 (GLfloat) renderer->b * inv255f, |
1079 (GLfloat) renderer->a * inv255f); | 1079 (GLfloat) renderer->a * inv255f); |
1088 static int | 1088 static int |
1089 GL_RenderLine(SDL_Renderer * renderer, int x1, int y1, int x2, int y2) | 1089 GL_RenderLine(SDL_Renderer * renderer, int x1, int y1, int x2, int y2) |
1090 { | 1090 { |
1091 GL_RenderData *data = (GL_RenderData *) renderer->driverdata; | 1091 GL_RenderData *data = (GL_RenderData *) renderer->driverdata; |
1092 | 1092 |
1093 SetBlendMode(data, renderer->blendMode); | 1093 GL_SetBlendMode(data, renderer->blendMode); |
1094 | 1094 |
1095 data->glColor4f((GLfloat) renderer->r * inv255f, | 1095 data->glColor4f((GLfloat) renderer->r * inv255f, |
1096 (GLfloat) renderer->g * inv255f, | 1096 (GLfloat) renderer->g * inv255f, |
1097 (GLfloat) renderer->b * inv255f, | 1097 (GLfloat) renderer->b * inv255f, |
1098 (GLfloat) renderer->a * inv255f); | 1098 (GLfloat) renderer->a * inv255f); |
1109 GL_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect) | 1109 GL_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect) |
1110 { | 1110 { |
1111 GL_RenderData *data = (GL_RenderData *) renderer->driverdata; | 1111 GL_RenderData *data = (GL_RenderData *) renderer->driverdata; |
1112 SDL_Window *window = SDL_GetWindowFromID(renderer->window); | 1112 SDL_Window *window = SDL_GetWindowFromID(renderer->window); |
1113 | 1113 |
1114 GL_SetBlendMode(data, renderer->blendMode); | |
1115 | |
1114 data->glColor4f((GLfloat) renderer->r * inv255f, | 1116 data->glColor4f((GLfloat) renderer->r * inv255f, |
1115 (GLfloat) renderer->g * inv255f, | 1117 (GLfloat) renderer->g * inv255f, |
1116 (GLfloat) renderer->b * inv255f, | 1118 (GLfloat) renderer->b * inv255f, |
1117 (GLfloat) renderer->a * inv255f); | 1119 (GLfloat) renderer->a * inv255f); |
1118 SetBlendMode(data, renderer->blendMode); | 1120 |
1119 data->glRecti(rect->x, rect->y, rect->x + rect->w, rect->y + rect->h); | 1121 data->glRecti(rect->x, rect->y, rect->x + rect->w, rect->y + rect->h); |
1120 | 1122 |
1121 return 0; | 1123 return 0; |
1122 } | 1124 } |
1123 | 1125 |
1176 (GLfloat) texture->a * inv255f); | 1178 (GLfloat) texture->a * inv255f); |
1177 } else { | 1179 } else { |
1178 data->glColor4f(1.0f, 1.0f, 1.0f, 1.0f); | 1180 data->glColor4f(1.0f, 1.0f, 1.0f, 1.0f); |
1179 } | 1181 } |
1180 | 1182 |
1181 SetBlendMode(data, texture->blendMode); | 1183 GL_SetBlendMode(data, texture->blendMode); |
1182 | 1184 |
1183 if (texture->scaleMode != data->scaleMode) { | 1185 if (texture->scaleMode != data->scaleMode) { |
1184 switch (texture->scaleMode) { | 1186 switch (texture->scaleMode) { |
1185 case SDL_TEXTURESCALEMODE_NONE: | 1187 case SDL_TEXTURESCALEMODE_NONE: |
1186 case SDL_TEXTURESCALEMODE_FAST: | 1188 case SDL_TEXTURESCALEMODE_FAST: |