comparison src/video/SDL_renderer_gl.c @ 2901:133601e3b255

Added RenderPiont() API Merged the drawing tests into a single test program
author Sam Lantinga <slouken@libsdl.org>
date Sun, 21 Dec 2008 17:39:41 +0000
parents e67f3f3bf221
children bd518fc76f28
comparison
equal deleted inserted replaced
2900:3a9636c83849 2901:133601e3b255
96 static void GL_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture); 96 static void GL_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
97 static void GL_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture, 97 static void GL_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture,
98 int numrects, const SDL_Rect * rects); 98 int numrects, const SDL_Rect * rects);
99 static int GL_SetDrawColor(SDL_Renderer * renderer); 99 static int GL_SetDrawColor(SDL_Renderer * renderer);
100 static int GL_SetDrawBlendMode(SDL_Renderer * renderer); 100 static int GL_SetDrawBlendMode(SDL_Renderer * renderer);
101 static int GL_RenderPoint(SDL_Renderer * renderer, int x, int y);
101 static int GL_RenderLine(SDL_Renderer * renderer, int x1, int y1, int x2, 102 static int GL_RenderLine(SDL_Renderer * renderer, int x1, int y1, int x2,
102 int y2); 103 int y2);
103 static int GL_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect); 104 static int GL_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect);
104 static int GL_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, 105 static int GL_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
105 const SDL_Rect * srcrect, const SDL_Rect * dstrect); 106 const SDL_Rect * srcrect, const SDL_Rect * dstrect);
311 renderer->LockTexture = GL_LockTexture; 312 renderer->LockTexture = GL_LockTexture;
312 renderer->UnlockTexture = GL_UnlockTexture; 313 renderer->UnlockTexture = GL_UnlockTexture;
313 renderer->DirtyTexture = GL_DirtyTexture; 314 renderer->DirtyTexture = GL_DirtyTexture;
314 renderer->SetDrawColor = GL_SetDrawColor; 315 renderer->SetDrawColor = GL_SetDrawColor;
315 renderer->SetDrawBlendMode = GL_SetDrawBlendMode; 316 renderer->SetDrawBlendMode = GL_SetDrawBlendMode;
317 renderer->RenderPoint = GL_RenderPoint;
316 renderer->RenderLine = GL_RenderLine; 318 renderer->RenderLine = GL_RenderLine;
317 renderer->RenderFill = GL_RenderFill; 319 renderer->RenderFill = GL_RenderFill;
318 renderer->RenderCopy = GL_RenderCopy; 320 renderer->RenderCopy = GL_RenderCopy;
319 renderer->RenderPresent = GL_RenderPresent; 321 renderer->RenderPresent = GL_RenderPresent;
320 renderer->DestroyTexture = GL_DestroyTexture; 322 renderer->DestroyTexture = GL_DestroyTexture;
1095 1097
1096 return 0; 1098 return 0;
1097 } 1099 }
1098 1100
1099 static int 1101 static int
1100 GL_RenderLine(SDL_Renderer * renderer, int x1, int y1, int x2, int y2) 1102 GL_RenderPoint(SDL_Renderer * renderer, int x, int y)
1101 { 1103 {
1102 GL_RenderData *data = (GL_RenderData *) renderer->driverdata; 1104 GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
1103 //data->glLineWidth(1.0);
1104 //data->glPointSize(1.0);
1105 1105
1106 SetBlendMode(data, renderer->blendMode); 1106 SetBlendMode(data, renderer->blendMode);
1107 1107
1108 data->glColor4f((GLfloat) renderer->r * inv255f, 1108 data->glColor4f((GLfloat) renderer->r * inv255f,
1109 (GLfloat) renderer->g * inv255f, 1109 (GLfloat) renderer->g * inv255f,
1110 (GLfloat) renderer->b * inv255f, 1110 (GLfloat) renderer->b * inv255f,
1111 (GLfloat) renderer->a * inv255f); 1111 (GLfloat) renderer->a * inv255f);
1112 1112
1113 if ((x1 == x2) && (y1 == y2)) { 1113 data->glBegin(GL_POINTS);
1114 data->glBegin(GL_POINTS); 1114 data->glVertex2i(x, y);
1115 data->glVertex2i(x1, y1); 1115 data->glEnd();
1116 data->glEnd(); 1116
1117 } else { 1117 return 0;
1118 data->glBegin(GL_LINES); 1118 }
1119 data->glVertex2i(x1, y1); 1119
1120 data->glVertex2i(x2, y2); 1120 static int
1121 data->glEnd(); 1121 GL_RenderLine(SDL_Renderer * renderer, int x1, int y1, int x2, int y2)
1122 } 1122 {
1123 GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
1124
1125 SetBlendMode(data, renderer->blendMode);
1126
1127 data->glColor4f((GLfloat) renderer->r * inv255f,
1128 (GLfloat) renderer->g * inv255f,
1129 (GLfloat) renderer->b * inv255f,
1130 (GLfloat) renderer->a * inv255f);
1131
1132 data->glBegin(GL_LINES);
1133 data->glVertex2i(x1, y1);
1134 data->glVertex2i(x2, y2);
1135 data->glEnd();
1136
1123 return 0; 1137 return 0;
1124 } 1138 }
1125 1139
1126 static int 1140 static int
1127 GL_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, 1141 GL_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,