static int GLES_RenderDrawLines(SDL_Renderer * renderer, const SDL_FPoint * points, int count) { GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; GLfloat *vertices; int idx; GLES_SetDrawingState(renderer); /* Emit a line strip including the specified vertices */ vertices = SDL_stack_alloc(GLfloat, count * 2); for (idx = 0; idx < count; ++idx) { GLfloat x = points[idx].x + 0.5f; GLfloat y = points[idx].y + 0.5f; vertices[idx * 2] = x; vertices[(idx * 2) + 1] = y; } data->glVertexPointer(2, GL_FLOAT, 0, vertices); if (count > 2 && points[0].x == points[count-1].x && points[0].y == points[count-1].y) { /* GL_LINE_LOOP takes care of the final segment */ --count; data->glDrawArrays(GL_LINE_LOOP, 0, count); } else { data->glDrawArrays(GL_LINE_STRIP, 0, count); /* We need to close the endpoint of the line */ data->glDrawArrays(GL_POINTS, count-1, 1); } SDL_stack_free(vertices); return 0; }
static int GLES_RenderFillRects(SDL_Renderer * renderer, const SDL_FRect * rects, int count) { GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; int i; GLES_SetDrawingState(renderer); for (i = 0; i < count; ++i) { const SDL_FRect *rect = &rects[i]; GLfloat minx = rect->x; GLfloat maxx = rect->x + rect->w; GLfloat miny = rect->y; GLfloat maxy = rect->y + rect->h; GLfloat vertices[8]; vertices[0] = minx; vertices[1] = miny; vertices[2] = maxx; vertices[3] = miny; vertices[4] = minx; vertices[5] = maxy; vertices[6] = maxx; vertices[7] = maxy; data->glVertexPointer(2, GL_FLOAT, 0, vertices); data->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); } return 0; }
static int GLES_RenderDrawPoints(SDL_Renderer * renderer, const SDL_FPoint * points, int count) { GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; GLfloat *vertices; int idx; GLES_SetDrawingState(renderer); /* Emit the specified vertices as points */ vertices = SDL_stack_alloc(GLfloat, count * 2); for (idx = 0; idx < count; ++idx) { GLfloat x = points[idx].x + 0.5f; GLfloat y = points[idx].y + 0.5f; vertices[idx * 2] = x; vertices[(idx * 2) + 1] = y; } data->glVertexPointer(2, GL_FLOAT, 0, vertices); data->glDrawArrays(GL_POINTS, 0, count); SDL_stack_free(vertices); return 0; }
static int GLES_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points, int count) { GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; int i; GLshort *vertices; GLES_SetDrawingState(renderer); vertices = SDL_stack_alloc(GLshort, count*2); for (i = 0; i < count; ++i) { vertices[2*i+0] = (GLshort)points[i].x; vertices[2*i+1] = (GLshort)points[i].y; } data->glVertexPointer(2, GL_SHORT, 0, vertices); if (count > 2 && points[0].x == points[count-1].x && points[0].y == points[count-1].y) { /* GL_LINE_LOOP takes care of the final segment */ --count; data->glDrawArrays(GL_LINE_LOOP, 0, count); } else { data->glDrawArrays(GL_LINE_STRIP, 0, count); /* We need to close the endpoint of the line */ data->glDrawArrays(GL_POINTS, count-1, 1); } SDL_stack_free(vertices); return 0; }
static int GLES_RenderDrawPoints(SDL_Renderer * renderer, const SDL_FPoint * points, int count) { GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; GLES_SetDrawingState(renderer); data->glVertexPointer(2, GL_FLOAT, 0, points); data->glDrawArrays(GL_POINTS, 0, count); return 0; }
static int GLES_RenderDrawPoints(SDL_Renderer * renderer, const SDL_Point * points, int count) { GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; int i; GLshort *vertices; GLES_SetDrawingState(renderer); vertices = SDL_stack_alloc(GLshort, count*2); for (i = 0; i < count; ++i) { vertices[2*i+0] = (GLshort)points[i].x; vertices[2*i+1] = (GLshort)points[i].y; } data->glVertexPointer(2, GL_SHORT, 0, vertices); data->glDrawArrays(GL_POINTS, 0, count); SDL_stack_free(vertices); return 0; }
static int GLES_RenderDrawLines(SDL_Renderer * renderer, const SDL_FPoint * points, int count) { GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; GLES_SetDrawingState(renderer); data->glVertexPointer(2, GL_FLOAT, 0, points); if (count > 2 && points[0].x == points[count-1].x && points[0].y == points[count-1].y) { /* GL_LINE_LOOP takes care of the final segment */ --count; data->glDrawArrays(GL_LINE_LOOP, 0, count); } else { data->glDrawArrays(GL_LINE_STRIP, 0, count); /* We need to close the endpoint of the line */ data->glDrawArrays(GL_POINTS, count-1, 1); } return 0; }