Mercurial > sdl-ios-xcode
comparison src/video/SDL_renderer_gl.c @ 5151:5429daf5e3f9
The DrawRect API is implemented using lines
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Tue, 01 Feb 2011 20:50:04 -0800 |
parents | ad50b3db78bd |
children | be02be2ea897 |
comparison
equal
deleted
inserted
replaced
5150:ad50b3db78bd | 5151:5429daf5e3f9 |
---|---|
91 static int GL_RenderClear(SDL_Renderer * renderer); | 91 static int GL_RenderClear(SDL_Renderer * renderer); |
92 static int GL_RenderDrawPoints(SDL_Renderer * renderer, | 92 static int GL_RenderDrawPoints(SDL_Renderer * renderer, |
93 const SDL_Point * points, int count); | 93 const SDL_Point * points, int count); |
94 static int GL_RenderDrawLines(SDL_Renderer * renderer, | 94 static int GL_RenderDrawLines(SDL_Renderer * renderer, |
95 const SDL_Point * points, int count); | 95 const SDL_Point * points, int count); |
96 static int GL_RenderDrawRects(SDL_Renderer * renderer, | |
97 const SDL_Rect ** rects, int count); | |
98 static int GL_RenderFillRects(SDL_Renderer * renderer, | 96 static int GL_RenderFillRects(SDL_Renderer * renderer, |
99 const SDL_Rect ** rects, int count); | 97 const SDL_Rect ** rects, int count); |
100 static int GL_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, | 98 static int GL_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, |
101 const SDL_Rect * srcrect, const SDL_Rect * dstrect); | 99 const SDL_Rect * srcrect, const SDL_Rect * dstrect); |
102 static int GL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, | 100 static int GL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, |
287 renderer->UnlockTexture = GL_UnlockTexture; | 285 renderer->UnlockTexture = GL_UnlockTexture; |
288 renderer->DirtyTexture = GL_DirtyTexture; | 286 renderer->DirtyTexture = GL_DirtyTexture; |
289 renderer->RenderClear = GL_RenderClear; | 287 renderer->RenderClear = GL_RenderClear; |
290 renderer->RenderDrawPoints = GL_RenderDrawPoints; | 288 renderer->RenderDrawPoints = GL_RenderDrawPoints; |
291 renderer->RenderDrawLines = GL_RenderDrawLines; | 289 renderer->RenderDrawLines = GL_RenderDrawLines; |
292 renderer->RenderDrawRects = GL_RenderDrawRects; | |
293 renderer->RenderFillRects = GL_RenderFillRects; | 290 renderer->RenderFillRects = GL_RenderFillRects; |
294 renderer->RenderCopy = GL_RenderCopy; | 291 renderer->RenderCopy = GL_RenderCopy; |
295 renderer->RenderReadPixels = GL_RenderReadPixels; | 292 renderer->RenderReadPixels = GL_RenderReadPixels; |
296 renderer->RenderWritePixels = GL_RenderWritePixels; | 293 renderer->RenderWritePixels = GL_RenderWritePixels; |
297 renderer->RenderPresent = GL_RenderPresent; | 294 renderer->RenderPresent = GL_RenderPresent; |
1137 | 1134 |
1138 return 0; | 1135 return 0; |
1139 } | 1136 } |
1140 | 1137 |
1141 static int | 1138 static int |
1142 GL_RenderDrawRects(SDL_Renderer * renderer, const SDL_Rect ** rects, int count) | |
1143 { | |
1144 GL_RenderData *data = (GL_RenderData *) renderer->driverdata; | |
1145 int i, x, y; | |
1146 | |
1147 GL_ActivateRenderer(renderer); | |
1148 | |
1149 GL_SetBlendMode(data, renderer->blendMode); | |
1150 | |
1151 data->glColor4f((GLfloat) renderer->r * inv255f, | |
1152 (GLfloat) renderer->g * inv255f, | |
1153 (GLfloat) renderer->b * inv255f, | |
1154 (GLfloat) renderer->a * inv255f); | |
1155 | |
1156 data->glBegin(GL_LINE_LOOP); | |
1157 for (i = 0; i < count; ++i) { | |
1158 const SDL_Rect *rect = rects[i]; | |
1159 | |
1160 x = rect->x; | |
1161 y = rect->y; | |
1162 data->glVertex2f(0.5f + x, 0.5f + y); | |
1163 | |
1164 x = rect->x+rect->w-1; | |
1165 y = rect->y; | |
1166 data->glVertex2f(0.5f + x, 0.5f + y); | |
1167 | |
1168 x = rect->x+rect->w-1; | |
1169 y = rect->y+rect->h-1; | |
1170 data->glVertex2f(0.5f + x, 0.5f + y); | |
1171 | |
1172 x = rect->x; | |
1173 y = rect->y+rect->h-1; | |
1174 data->glVertex2f(0.5f + x, 0.5f + y); | |
1175 } | |
1176 data->glEnd(); | |
1177 | |
1178 return 0; | |
1179 } | |
1180 | |
1181 static int | |
1182 GL_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects, int count) | 1139 GL_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects, int count) |
1183 { | 1140 { |
1184 GL_RenderData *data = (GL_RenderData *) renderer->driverdata; | 1141 GL_RenderData *data = (GL_RenderData *) renderer->driverdata; |
1185 int i; | 1142 int i; |
1186 | 1143 |