comparison src/video/SDL_renderer_gles.c @ 3547:8b18669c2663

Fixed building on iPhone
author Sam Lantinga <slouken@libsdl.org>
date Sat, 12 Dec 2009 00:55:13 +0000
parents 0267b8b1595c
children 1e2e19d51265
comparison
equal deleted inserted replaced
3546:65848493e08e 3547:8b18669c2663
644 644
645 static int 645 static int
646 GLES_RenderPoints(SDL_Renderer * renderer, const SDL_Point * points, int count) 646 GLES_RenderPoints(SDL_Renderer * renderer, const SDL_Point * points, int count)
647 { 647 {
648 GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; 648 GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
649 int i;
650 GLshort *vertices;
649 651
650 GLES_SetBlendMode(data, renderer->blendMode, 1); 652 GLES_SetBlendMode(data, renderer->blendMode, 1);
651 653
652 data->glColor4f((GLfloat) renderer->r * inv255f, 654 data->glColor4f((GLfloat) renderer->r * inv255f,
653 (GLfloat) renderer->g * inv255f, 655 (GLfloat) renderer->g * inv255f,
654 (GLfloat) renderer->b * inv255f, 656 (GLfloat) renderer->b * inv255f,
655 (GLfloat) renderer->a * inv255f); 657 (GLfloat) renderer->a * inv255f);
656 658
657 data->glVertexPointer(2, GL_INT, 0, points); 659 vertices = SDL_stack_alloc(GLshort, count*2);
660 for (i = 0; i < count; ++i) {
661 vertices[2*i+0] = (GLshort)points[i].x;
662 vertices[2*i+1] = (GLshort)points[i].y;
663 }
664 data->glVertexPointer(2, GL_SHORT, 0, vertices);
658 data->glEnableClientState(GL_VERTEX_ARRAY); 665 data->glEnableClientState(GL_VERTEX_ARRAY);
659 data->glDrawArrays(GL_POINTS, 0, count); 666 data->glDrawArrays(GL_POINTS, 0, count);
660 data->glDisableClientState(GL_VERTEX_ARRAY); 667 data->glDisableClientState(GL_VERTEX_ARRAY);
668 SDL_stack_free(vertices);
661 669
662 return 0; 670 return 0;
663 } 671 }
664 672
665 static int 673 static int
666 GLES_RenderLines(SDL_Renderer * renderer, const SDL_Point * points, int count) 674 GLES_RenderLines(SDL_Renderer * renderer, const SDL_Point * points, int count)
667 { 675 {
668 GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; 676 GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
677 int i;
678 GLshort *vertices;
669 679
670 GLES_SetBlendMode(data, renderer->blendMode, 1); 680 GLES_SetBlendMode(data, renderer->blendMode, 1);
671 681
672 data->glColor4f((GLfloat) renderer->r * inv255f, 682 data->glColor4f((GLfloat) renderer->r * inv255f,
673 (GLfloat) renderer->g * inv255f, 683 (GLfloat) renderer->g * inv255f,
674 (GLfloat) renderer->b * inv255f, 684 (GLfloat) renderer->b * inv255f,
675 (GLfloat) renderer->a * inv255f); 685 (GLfloat) renderer->a * inv255f);
676 686
677 data->glVertexPointer(2, GL_INT, 0, points); 687 vertices = SDL_stack_alloc(GLshort, count*2);
688 for (i = 0; i < count; ++i) {
689 vertices[2*i+0] = (GLshort)points[i].x;
690 vertices[2*i+1] = (GLshort)points[i].y;
691 }
692 data->glVertexPointer(2, GL_SHORT, 0, vertices);
678 data->glEnableClientState(GL_VERTEX_ARRAY); 693 data->glEnableClientState(GL_VERTEX_ARRAY);
679 if (count > 2 && 694 if (count > 2 &&
680 points[0].x == points[count-1].x && points[0].y == points[count-1].y) { 695 points[0].x == points[count-1].x && points[0].y == points[count-1].y) {
681 /* GL_LINE_LOOP takes care of the final segment */ 696 /* GL_LINE_LOOP takes care of the final segment */
682 --count; 697 --count;
683 data->glDrawArrays(GL_LINE_LOOP, 0, count); 698 data->glDrawArrays(GL_LINE_LOOP, 0, count);
684 } else { 699 } else {
685 data->glDrawArrays(GL_LINE_STRIP, 0, count); 700 data->glDrawArrays(GL_LINE_STRIP, 0, count);
686 } 701 }
687 data->glDisableClientState(GL_VERTEX_ARRAY); 702 data->glDisableClientState(GL_VERTEX_ARRAY);
703 SDL_stack_free(vertices);
688 704
689 return 0; 705 return 0;
690 } 706 }
691 707
692 static int 708 static int