comparison src/video/SDL_renderer_gles.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
79 int numrects, const SDL_Rect * rects); 79 int numrects, const SDL_Rect * rects);
80 static int GLES_RenderDrawPoints(SDL_Renderer * renderer, 80 static int GLES_RenderDrawPoints(SDL_Renderer * renderer,
81 const SDL_Point * points, int count); 81 const SDL_Point * points, int count);
82 static int GLES_RenderDrawLines(SDL_Renderer * renderer, 82 static int GLES_RenderDrawLines(SDL_Renderer * renderer,
83 const SDL_Point * points, int count); 83 const SDL_Point * points, int count);
84 static int GLES_RenderDrawRects(SDL_Renderer * renderer,
85 const SDL_Rect ** rects, int count);
86 static int GLES_RenderFillRects(SDL_Renderer * renderer, 84 static int GLES_RenderFillRects(SDL_Renderer * renderer,
87 const SDL_Rect ** rects, int count); 85 const SDL_Rect ** rects, int count);
88 static int GLES_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, 86 static int GLES_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
89 const SDL_Rect * srcrect, 87 const SDL_Rect * srcrect,
90 const SDL_Rect * dstrect); 88 const SDL_Rect * dstrect);
227 renderer->LockTexture = GLES_LockTexture; 225 renderer->LockTexture = GLES_LockTexture;
228 renderer->UnlockTexture = GLES_UnlockTexture; 226 renderer->UnlockTexture = GLES_UnlockTexture;
229 renderer->DirtyTexture = GLES_DirtyTexture; 227 renderer->DirtyTexture = GLES_DirtyTexture;
230 renderer->RenderDrawPoints = GLES_RenderDrawPoints; 228 renderer->RenderDrawPoints = GLES_RenderDrawPoints;
231 renderer->RenderDrawLines = GLES_RenderDrawLines; 229 renderer->RenderDrawLines = GLES_RenderDrawLines;
232 renderer->RenderDrawRects = GLES_RenderDrawRects;
233 renderer->RenderFillRects = GLES_RenderFillRects; 230 renderer->RenderFillRects = GLES_RenderFillRects;
234 renderer->RenderCopy = GLES_RenderCopy; 231 renderer->RenderCopy = GLES_RenderCopy;
235 renderer->RenderPresent = GLES_RenderPresent; 232 renderer->RenderPresent = GLES_RenderPresent;
236 renderer->DestroyTexture = GLES_DestroyTexture; 233 renderer->DestroyTexture = GLES_DestroyTexture;
237 renderer->DestroyRenderer = GLES_DestroyRenderer; 234 renderer->DestroyRenderer = GLES_DestroyRenderer;
666 663
667 return 0; 664 return 0;
668 } 665 }
669 666
670 static int 667 static int
671 GLES_RenderDrawRects(SDL_Renderer * renderer, const SDL_Rect ** rects, 668 GLES_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects,
672 int count) 669 int count)
673 { 670 {
674 GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; 671 GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
675 int i; 672 int i;
676 673
698 vertices[5] = maxy; 695 vertices[5] = maxy;
699 vertices[6] = maxx; 696 vertices[6] = maxx;
700 vertices[7] = maxy; 697 vertices[7] = maxy;
701 698
702 data->glVertexPointer(2, GL_SHORT, 0, vertices); 699 data->glVertexPointer(2, GL_SHORT, 0, vertices);
703 data->glDrawArrays(GL_LINE_LOOP, 0, 4);
704 }
705
706 return 0;
707 }
708
709 static int
710 GLES_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects,
711 int count)
712 {
713 GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
714 int i;
715
716 GLES_ActivateRenderer(renderer);
717
718 GLES_SetBlendMode(data, renderer->blendMode);
719
720 data->glColor4f((GLfloat) renderer->r * inv255f,
721 (GLfloat) renderer->g * inv255f,
722 (GLfloat) renderer->b * inv255f,
723 (GLfloat) renderer->a * inv255f);
724
725 for (i = 0; i < count; ++i) {
726 const SDL_Rect *rect = rects[i];
727 GLshort minx = rect->x;
728 GLshort maxx = rect->x + rect->w;
729 GLshort miny = rect->y;
730 GLshort maxy = rect->y + rect->h;
731 GLshort vertices[8];
732 vertices[0] = minx;
733 vertices[1] = miny;
734 vertices[2] = maxx;
735 vertices[3] = miny;
736 vertices[4] = minx;
737 vertices[5] = maxy;
738 vertices[6] = maxx;
739 vertices[7] = maxy;
740
741 data->glVertexPointer(2, GL_SHORT, 0, vertices);
742 data->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); 700 data->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
743 } 701 }
744 702
745 return 0; 703 return 0;
746 } 704 }