comparison src/video/SDL_renderer_gles.c @ 3641:1e2e19d51265

Fixed iPhone build
author Sam Lantinga <slouken@libsdl.org>
date Wed, 13 Jan 2010 04:58:31 +0000
parents 8b18669c2663
children 64ce267332c6
comparison
equal deleted inserted replaced
3640:58c1b9ec7074 3641:1e2e19d51265
83 void **pixels, int *pitch); 83 void **pixels, int *pitch);
84 static void GLES_UnlockTexture(SDL_Renderer * renderer, 84 static void GLES_UnlockTexture(SDL_Renderer * renderer,
85 SDL_Texture * texture); 85 SDL_Texture * texture);
86 static void GLES_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture, 86 static void GLES_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture,
87 int numrects, const SDL_Rect * rects); 87 int numrects, const SDL_Rect * rects);
88 static int GLES_RenderPoints(SDL_Renderer * renderer, const SDL_Point * points, 88 static int GLES_RenderDrawPoints(SDL_Renderer * renderer,
89 int count); 89 const SDL_Point * points, int count);
90 static int GLES_RenderLines(SDL_Renderer * renderer, const SDL_Point * points, 90 static int GLES_RenderDrawLines(SDL_Renderer * renderer,
91 int count); 91 const SDL_Point * points, int count);
92 static int GLES_RenderRects(SDL_Renderer * renderer, const SDL_Rect ** rects, 92 static int GLES_RenderDrawRects(SDL_Renderer * renderer,
93 int count); 93 const SDL_Rect ** rects, int count);
94 static int GLES_RenderFillRects(SDL_Renderer * renderer,
95 const SDL_Rect ** rects, int count);
94 static int GLES_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, 96 static int GLES_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
95 const SDL_Rect * srcrect, 97 const SDL_Rect * srcrect,
96 const SDL_Rect * dstrect); 98 const SDL_Rect * dstrect);
97 static void GLES_RenderPresent(SDL_Renderer * renderer); 99 static void GLES_RenderPresent(SDL_Renderer * renderer);
98 static void GLES_DestroyTexture(SDL_Renderer * renderer, 100 static void GLES_DestroyTexture(SDL_Renderer * renderer,
242 renderer->SetTextureScaleMode = GLES_SetTextureScaleMode; 244 renderer->SetTextureScaleMode = GLES_SetTextureScaleMode;
243 renderer->UpdateTexture = GLES_UpdateTexture; 245 renderer->UpdateTexture = GLES_UpdateTexture;
244 renderer->LockTexture = GLES_LockTexture; 246 renderer->LockTexture = GLES_LockTexture;
245 renderer->UnlockTexture = GLES_UnlockTexture; 247 renderer->UnlockTexture = GLES_UnlockTexture;
246 renderer->DirtyTexture = GLES_DirtyTexture; 248 renderer->DirtyTexture = GLES_DirtyTexture;
247 renderer->RenderPoints = GLES_RenderPoints; 249 renderer->RenderDrawPoints = GLES_RenderDrawPoints;
248 renderer->RenderLines = GLES_RenderLines; 250 renderer->RenderDrawLines = GLES_RenderDrawLines;
249 renderer->RenderRects = GLES_RenderRects; 251 renderer->RenderDrawRects = GLES_RenderDrawRects;
252 renderer->RenderFillRects = GLES_RenderFillRects;
250 renderer->RenderCopy = GLES_RenderCopy; 253 renderer->RenderCopy = GLES_RenderCopy;
251 renderer->RenderPresent = GLES_RenderPresent; 254 renderer->RenderPresent = GLES_RenderPresent;
252 renderer->DestroyTexture = GLES_DestroyTexture; 255 renderer->DestroyTexture = GLES_DestroyTexture;
253 renderer->DestroyRenderer = GLES_DestroyRenderer; 256 renderer->DestroyRenderer = GLES_DestroyRenderer;
254 renderer->info = GL_ES_RenderDriver.info; 257 renderer->info = GL_ES_RenderDriver.info;
369 372
370 static int 373 static int
371 GLES_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) 374 GLES_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
372 { 375 {
373 GLES_RenderData *renderdata = (GLES_RenderData *) renderer->driverdata; 376 GLES_RenderData *renderdata = (GLES_RenderData *) renderer->driverdata;
374 SDL_Window *window = SDL_GetWindowFromID(renderer->window);
375 GLES_TextureData *data; 377 GLES_TextureData *data;
376 GLint internalFormat; 378 GLint internalFormat;
377 GLenum format, type; 379 GLenum format, type;
378 int texture_w, texture_h; 380 int texture_w, texture_h;
379 GLenum result; 381 GLenum result;
641 data->blendMode = blendMode; 643 data->blendMode = blendMode;
642 } 644 }
643 } 645 }
644 646
645 static int 647 static int
646 GLES_RenderPoints(SDL_Renderer * renderer, const SDL_Point * points, int count) 648 GLES_RenderDrawPoints(SDL_Renderer * renderer, const SDL_Point * points,
649 int count)
647 { 650 {
648 GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; 651 GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
649 int i; 652 int i;
650 GLshort *vertices; 653 GLshort *vertices;
651 654
669 672
670 return 0; 673 return 0;
671 } 674 }
672 675
673 static int 676 static int
674 GLES_RenderLines(SDL_Renderer * renderer, const SDL_Point * points, int count) 677 GLES_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points,
678 int count)
675 { 679 {
676 GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; 680 GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
677 int i; 681 int i;
678 GLshort *vertices; 682 GLshort *vertices;
679 683
704 708
705 return 0; 709 return 0;
706 } 710 }
707 711
708 static int 712 static int
709 GLES_RenderRects(SDL_Renderer * renderer, const SDL_Rect ** rects, int count) 713 GLES_RenderDrawRects(SDL_Renderer * renderer, const SDL_Rect ** rects,
714 int count)
710 { 715 {
711 GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; 716 GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
712 int i; 717 int i;
713 718
714 GLES_SetBlendMode(data, renderer->blendMode, 1); 719 GLES_SetBlendMode(data, renderer->blendMode, 1);
734 vertices[5] = maxy; 739 vertices[5] = maxy;
735 vertices[6] = maxx; 740 vertices[6] = maxx;
736 vertices[7] = maxy; 741 vertices[7] = maxy;
737 742
738 data->glVertexPointer(2, GL_SHORT, 0, vertices); 743 data->glVertexPointer(2, GL_SHORT, 0, vertices);
744 data->glDrawArrays(GL_LINE_LOOP, 0, 4);
745 }
746 data->glDisableClientState(GL_VERTEX_ARRAY);
747
748 return 0;
749 }
750
751 static int
752 GLES_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects,
753 int count)
754 {
755 GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
756 int i;
757
758 GLES_SetBlendMode(data, renderer->blendMode, 1);
759
760 data->glColor4f((GLfloat) renderer->r * inv255f,
761 (GLfloat) renderer->g * inv255f,
762 (GLfloat) renderer->b * inv255f,
763 (GLfloat) renderer->a * inv255f);
764
765 data->glEnableClientState(GL_VERTEX_ARRAY);
766 for (i = 0; i < count; ++i) {
767 const SDL_Rect *rect = rects[i];
768 GLshort minx = rect->x;
769 GLshort maxx = rect->x + rect->w;
770 GLshort miny = rect->y;
771 GLshort maxy = rect->y + rect->h;
772 GLshort vertices[8];
773 vertices[0] = minx;
774 vertices[1] = miny;
775 vertices[2] = maxx;
776 vertices[3] = miny;
777 vertices[4] = minx;
778 vertices[5] = maxy;
779 vertices[6] = maxx;
780 vertices[7] = maxy;
781
782 data->glVertexPointer(2, GL_SHORT, 0, vertices);
739 data->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); 783 data->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
740 } 784 }
741 data->glDisableClientState(GL_VERTEX_ARRAY); 785 data->glDisableClientState(GL_VERTEX_ARRAY);
742 786
743 return 0; 787 return 0;
896 } 940 }
897 941
898 static void 942 static void
899 GLES_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture) 943 GLES_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
900 { 944 {
901 GLES_RenderData *renderdata = (GLES_RenderData *) renderer->driverdata;
902 GLES_TextureData *data = (GLES_TextureData *) texture->driverdata; 945 GLES_TextureData *data = (GLES_TextureData *) texture->driverdata;
903 946
904 if (!data) { 947 if (!data) {
905 return; 948 return;
906 } 949 }