annotate src/video/SDL_renderer_gles.c @ 5144:31e7f523ab3d

Making the API simpler, texture color and alpha modulation are supported by all renderers.
author Sam Lantinga <slouken@libsdl.org>
date Mon, 31 Jan 2011 23:37:30 -0800
parents e743b9c3f6d6
children c8e049de174c
rev   line source
2739
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
1 /*
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
3697
f7b03b6838cb Fixed bug #926
Sam Lantinga <slouken@libsdl.org>
parents: 3688
diff changeset
3 Copyright (C) 1997-2010 Sam Lantinga
2739
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
4
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
6 modify it under the terms of the GNU Lesser General Public
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
8 version 2.1 of the License, or (at your option) any later version.
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
9
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
13 Lesser General Public License for more details.
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
14
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
15 You should have received a copy of the GNU Lesser General Public
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
16 License along with this library; if not, write to the Free Software
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
18
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
19 Sam Lantinga
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
20 slouken@libsdl.org
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
21 */
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
22 #include "SDL_config.h"
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
23
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
24 #if SDL_VIDEO_RENDER_OGL_ES
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
25
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
26 #include "SDL_video.h"
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
27 #include "SDL_opengles.h"
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
28 #include "SDL_sysvideo.h"
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
29 #include "SDL_pixels_c.h"
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
30 #include "SDL_rect_c.h"
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
31 #include "SDL_yuv_sw_c.h"
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
32
3165
7168651d5706 QNX quirk has been added, QNX OpenGL ES implementation is broken regarding support of textures with packed pixel formats.
Mike Gorchak <lestat@i.com.ua>
parents: 3163
diff changeset
33 #if defined(__QNXNTO__)
7168651d5706 QNX quirk has been added, QNX OpenGL ES implementation is broken regarding support of textures with packed pixel formats.
Mike Gorchak <lestat@i.com.ua>
parents: 3163
diff changeset
34 /* Include QNX system header to check QNX version later */
7168651d5706 QNX quirk has been added, QNX OpenGL ES implementation is broken regarding support of textures with packed pixel formats.
Mike Gorchak <lestat@i.com.ua>
parents: 3163
diff changeset
35 #include <sys/neutrino.h>
7168651d5706 QNX quirk has been added, QNX OpenGL ES implementation is broken regarding support of textures with packed pixel formats.
Mike Gorchak <lestat@i.com.ua>
parents: 3163
diff changeset
36 #endif /* __QNXNTO__ */
3099
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2964
diff changeset
37
3165
7168651d5706 QNX quirk has been added, QNX OpenGL ES implementation is broken regarding support of textures with packed pixel formats.
Mike Gorchak <lestat@i.com.ua>
parents: 3163
diff changeset
38 #if defined(SDL_VIDEO_DRIVER_QNXGF) || \
7168651d5706 QNX quirk has been added, QNX OpenGL ES implementation is broken regarding support of textures with packed pixel formats.
Mike Gorchak <lestat@i.com.ua>
parents: 3163
diff changeset
39 defined(SDL_VIDEO_DRIVER_PHOTON) || \
7168651d5706 QNX quirk has been added, QNX OpenGL ES implementation is broken regarding support of textures with packed pixel formats.
Mike Gorchak <lestat@i.com.ua>
parents: 3163
diff changeset
40 defined(SDL_VIDEO_DRIVER_PANDORA)
7168651d5706 QNX quirk has been added, QNX OpenGL ES implementation is broken regarding support of textures with packed pixel formats.
Mike Gorchak <lestat@i.com.ua>
parents: 3163
diff changeset
41
7168651d5706 QNX quirk has been added, QNX OpenGL ES implementation is broken regarding support of textures with packed pixel formats.
Mike Gorchak <lestat@i.com.ua>
parents: 3163
diff changeset
42 /* Empty function stub to get OpenGL ES 1.x support without */
7168651d5706 QNX quirk has been added, QNX OpenGL ES implementation is broken regarding support of textures with packed pixel formats.
Mike Gorchak <lestat@i.com.ua>
parents: 3163
diff changeset
43 /* OpenGL ES extension GL_OES_draw_texture supported */
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3122
diff changeset
44 GL_API void GL_APIENTRY
Sam Lantinga <slouken@libsdl.org>
parents: 3122
diff changeset
45 glDrawTexiOES(GLint x, GLint y, GLint z, GLint width, GLint height)
3099
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2964
diff changeset
46 {
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3122
diff changeset
47 return;
3099
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2964
diff changeset
48 }
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2964
diff changeset
49
3165
7168651d5706 QNX quirk has been added, QNX OpenGL ES implementation is broken regarding support of textures with packed pixel formats.
Mike Gorchak <lestat@i.com.ua>
parents: 3163
diff changeset
50 #endif /* QNXGF || PHOTON || PANDORA */
3161
494559cc723b OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
51
2739
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
52 /* OpenGL ES 1.1 renderer implementation, based on the OpenGL renderer */
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
53
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
54 static const float inv255f = 1.0f / 255.0f;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
55
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
56 static SDL_Renderer *GLES_CreateRenderer(SDL_Window * window, Uint32 flags);
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
57 static int GLES_ActivateRenderer(SDL_Renderer * renderer);
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
58 static int GLES_DisplayModeChanged(SDL_Renderer * renderer);
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
59 static int GLES_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture);
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
60 static int GLES_QueryTexturePixels(SDL_Renderer * renderer,
2753
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
61 SDL_Texture * texture, void **pixels,
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
62 int *pitch);
2739
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
63 static int GLES_SetTexturePalette(SDL_Renderer * renderer,
2753
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
64 SDL_Texture * texture,
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
65 const SDL_Color * colors, int firstcolor,
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
66 int ncolors);
2739
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
67 static int GLES_GetTexturePalette(SDL_Renderer * renderer,
2753
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
68 SDL_Texture * texture, SDL_Color * colors,
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
69 int firstcolor, int ncolors);
2739
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
70 static int GLES_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
2753
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
71 const SDL_Rect * rect, const void *pixels,
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
72 int pitch);
2739
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
73 static int GLES_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
2753
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
74 const SDL_Rect * rect, int markDirty,
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
75 void **pixels, int *pitch);
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
76 static void GLES_UnlockTexture(SDL_Renderer * renderer,
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
77 SDL_Texture * texture);
2739
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
78 static void GLES_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture,
2753
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
79 int numrects, const SDL_Rect * rects);
3641
1e2e19d51265 Fixed iPhone build
Sam Lantinga <slouken@libsdl.org>
parents: 3547
diff changeset
80 static int GLES_RenderDrawPoints(SDL_Renderer * renderer,
1e2e19d51265 Fixed iPhone build
Sam Lantinga <slouken@libsdl.org>
parents: 3547
diff changeset
81 const SDL_Point * points, int count);
1e2e19d51265 Fixed iPhone build
Sam Lantinga <slouken@libsdl.org>
parents: 3547
diff changeset
82 static int GLES_RenderDrawLines(SDL_Renderer * renderer,
1e2e19d51265 Fixed iPhone build
Sam Lantinga <slouken@libsdl.org>
parents: 3547
diff changeset
83 const SDL_Point * points, int count);
1e2e19d51265 Fixed iPhone build
Sam Lantinga <slouken@libsdl.org>
parents: 3547
diff changeset
84 static int GLES_RenderDrawRects(SDL_Renderer * renderer,
1e2e19d51265 Fixed iPhone build
Sam Lantinga <slouken@libsdl.org>
parents: 3547
diff changeset
85 const SDL_Rect ** rects, int count);
1e2e19d51265 Fixed iPhone build
Sam Lantinga <slouken@libsdl.org>
parents: 3547
diff changeset
86 static int GLES_RenderFillRects(SDL_Renderer * renderer,
1e2e19d51265 Fixed iPhone build
Sam Lantinga <slouken@libsdl.org>
parents: 3547
diff changeset
87 const SDL_Rect ** rects, int count);
2739
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
88 static int GLES_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
2753
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
89 const SDL_Rect * srcrect,
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
90 const SDL_Rect * dstrect);
2739
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
91 static void GLES_RenderPresent(SDL_Renderer * renderer);
2753
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
92 static void GLES_DestroyTexture(SDL_Renderer * renderer,
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
93 SDL_Texture * texture);
2739
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
94 static void GLES_DestroyRenderer(SDL_Renderer * renderer);
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
95
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
96
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
97 SDL_RenderDriver GL_ES_RenderDriver = {
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
98 GLES_CreateRenderer,
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
99 {
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
100 "opengl_es",
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
101 (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTDISCARD |
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
102 SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED),
2753
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
103 {
3122
6c98826d88b0 OpenGL ES renderer state fixes. Now GL_TEXTURE_2D is not enabled by default.
Mike Gorchak <lestat@i.com.ua>
parents: 3099
diff changeset
104 /* OpenGL ES 1.x supported formats list */
4985
047a580d30f3 Fixed blue-red channel swap in OpenGL ES 16-bit texture formats
Sam Lantinga <slouken@libsdl.org>
parents: 4963
diff changeset
105 SDL_PIXELFORMAT_RGBA4444,
047a580d30f3 Fixed blue-red channel swap in OpenGL ES 16-bit texture formats
Sam Lantinga <slouken@libsdl.org>
parents: 4963
diff changeset
106 SDL_PIXELFORMAT_RGBA5551,
047a580d30f3 Fixed blue-red channel swap in OpenGL ES 16-bit texture formats
Sam Lantinga <slouken@libsdl.org>
parents: 4963
diff changeset
107 SDL_PIXELFORMAT_RGB565,
4963
604077962776 Fixed screen texture format on Android
Sam Lantinga <slouken@libsdl.org>
parents: 4929
diff changeset
108 SDL_PIXELFORMAT_RGB24,
604077962776 Fixed screen texture format on Android
Sam Lantinga <slouken@libsdl.org>
parents: 4929
diff changeset
109 SDL_PIXELFORMAT_BGR888,
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3122
diff changeset
110 SDL_PIXELFORMAT_ABGR8888},
2753
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
111 0,
2739
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
112 0}
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
113 };
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
114
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
115 typedef struct
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
116 {
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
117 SDL_GLContext context;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
118 SDL_bool updateSize;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
119 int blendMode;
2753
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
120
2739
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
121 #ifndef APIENTRY
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
122 #define APIENTRY
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
123 #endif
2753
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
124
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
125 SDL_bool useDrawTexture;
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
126 SDL_bool GL_OES_draw_texture_supported;
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
127
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
128 /* OpenGL ES functions */
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
129 #define SDL_PROC(ret,func,params) ret (APIENTRY *func) params;
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
130 #include "SDL_glesfuncs.h"
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
131 #undef SDL_PROC
2739
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
132
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
133 } GLES_RenderData;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
134
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
135 typedef struct
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
136 {
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
137 GLuint texture;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
138 GLenum type;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
139 GLfloat texw;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
140 GLfloat texh;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
141 GLenum format;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
142 GLenum formattype;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
143 void *pixels;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
144 int pitch;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
145 SDL_DirtyRectList dirty;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
146 } GLES_TextureData;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
147
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
148 static void
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
149 GLES_SetError(const char *prefix, GLenum result)
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
150 {
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
151 const char *error;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
152
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
153 switch (result) {
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
154 case GL_NO_ERROR:
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
155 error = "GL_NO_ERROR";
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
156 break;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
157 case GL_INVALID_ENUM:
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
158 error = "GL_INVALID_ENUM";
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
159 break;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
160 case GL_INVALID_VALUE:
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
161 error = "GL_INVALID_VALUE";
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
162 break;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
163 case GL_INVALID_OPERATION:
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
164 error = "GL_INVALID_OPERATION";
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
165 break;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
166 case GL_STACK_OVERFLOW:
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
167 error = "GL_STACK_OVERFLOW";
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
168 break;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
169 case GL_STACK_UNDERFLOW:
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
170 error = "GL_STACK_UNDERFLOW";
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
171 break;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
172 case GL_OUT_OF_MEMORY:
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
173 error = "GL_OUT_OF_MEMORY";
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
174 break;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
175 default:
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
176 error = "UNKNOWN";
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
177 break;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
178 }
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
179 SDL_SetError("%s: %s", prefix, error);
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
180 }
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
181
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
182 static int
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
183 GLES_LoadFunctions(GLES_RenderData * data)
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
184 {
2753
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
185
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
186 #define SDL_PROC(ret,func,params) \
3122
6c98826d88b0 OpenGL ES renderer state fixes. Now GL_TEXTURE_2D is not enabled by default.
Mike Gorchak <lestat@i.com.ua>
parents: 3099
diff changeset
187 data->func = func;
2753
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
188 #include "SDL_glesfuncs.h"
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
189 #undef SDL_PROC
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
190
2739
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
191 return 0;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
192 }
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
193
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
194 SDL_Renderer *
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
195 GLES_CreateRenderer(SDL_Window * window, Uint32 flags)
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
196 {
2753
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
197
2739
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
198 SDL_Renderer *renderer;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
199 GLES_RenderData *data;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
200 GLint value;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
201 int doublebuffer;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
202
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
203 if (!(window->flags & SDL_WINDOW_OPENGL)) {
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
204 if (SDL_RecreateWindow(window, window->flags | SDL_WINDOW_OPENGL) < 0) {
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
205 return NULL;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
206 }
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
207 }
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
208
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
209 renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
210 if (!renderer) {
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
211 SDL_OutOfMemory();
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
212 return NULL;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
213 }
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
214
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
215 data = (GLES_RenderData *) SDL_calloc(1, sizeof(*data));
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
216 if (!data) {
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
217 GLES_DestroyRenderer(renderer);
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
218 SDL_OutOfMemory();
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
219 return NULL;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
220 }
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
221
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
222 renderer->ActivateRenderer = GLES_ActivateRenderer;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
223 renderer->DisplayModeChanged = GLES_DisplayModeChanged;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
224 renderer->CreateTexture = GLES_CreateTexture;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
225 renderer->QueryTexturePixels = GLES_QueryTexturePixels;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
226 renderer->SetTexturePalette = GLES_SetTexturePalette;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
227 renderer->GetTexturePalette = GLES_GetTexturePalette;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
228 renderer->UpdateTexture = GLES_UpdateTexture;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
229 renderer->LockTexture = GLES_LockTexture;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
230 renderer->UnlockTexture = GLES_UnlockTexture;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
231 renderer->DirtyTexture = GLES_DirtyTexture;
3641
1e2e19d51265 Fixed iPhone build
Sam Lantinga <slouken@libsdl.org>
parents: 3547
diff changeset
232 renderer->RenderDrawPoints = GLES_RenderDrawPoints;
1e2e19d51265 Fixed iPhone build
Sam Lantinga <slouken@libsdl.org>
parents: 3547
diff changeset
233 renderer->RenderDrawLines = GLES_RenderDrawLines;
1e2e19d51265 Fixed iPhone build
Sam Lantinga <slouken@libsdl.org>
parents: 3547
diff changeset
234 renderer->RenderDrawRects = GLES_RenderDrawRects;
1e2e19d51265 Fixed iPhone build
Sam Lantinga <slouken@libsdl.org>
parents: 3547
diff changeset
235 renderer->RenderFillRects = GLES_RenderFillRects;
2739
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
236 renderer->RenderCopy = GLES_RenderCopy;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
237 renderer->RenderPresent = GLES_RenderPresent;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
238 renderer->DestroyTexture = GLES_DestroyTexture;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
239 renderer->DestroyRenderer = GLES_DestroyRenderer;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
240 renderer->info = GL_ES_RenderDriver.info;
3688
6512cba48440 Fixed Cocoa and OpenGL builds
Sam Lantinga <slouken@libsdl.org>
parents: 3685
diff changeset
241 renderer->window = window;
2739
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
242 renderer->driverdata = data;
2753
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
243
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
244 renderer->info.flags =
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
245 (SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_ACCELERATED);
2739
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
246
3165
7168651d5706 QNX quirk has been added, QNX OpenGL ES implementation is broken regarding support of textures with packed pixel formats.
Mike Gorchak <lestat@i.com.ua>
parents: 3163
diff changeset
247 #if defined(__QNXNTO__)
7168651d5706 QNX quirk has been added, QNX OpenGL ES implementation is broken regarding support of textures with packed pixel formats.
Mike Gorchak <lestat@i.com.ua>
parents: 3163
diff changeset
248 #if _NTO_VERSION<=641
7168651d5706 QNX quirk has been added, QNX OpenGL ES implementation is broken regarding support of textures with packed pixel formats.
Mike Gorchak <lestat@i.com.ua>
parents: 3163
diff changeset
249 /* QNX's OpenGL ES implementation is broken regarding */
7168651d5706 QNX quirk has been added, QNX OpenGL ES implementation is broken regarding support of textures with packed pixel formats.
Mike Gorchak <lestat@i.com.ua>
parents: 3163
diff changeset
250 /* packed textures support, affected versions 6.3.2, 6.4.0, 6.4.1 */
3169
Sam Lantinga <slouken@libsdl.org>
parents: 3165
diff changeset
251 renderer->info.num_texture_formats = 2;
Sam Lantinga <slouken@libsdl.org>
parents: 3165
diff changeset
252 renderer->info.texture_formats[0] = SDL_PIXELFORMAT_ABGR8888;
Sam Lantinga <slouken@libsdl.org>
parents: 3165
diff changeset
253 renderer->info.texture_formats[1] = SDL_PIXELFORMAT_BGR24;
3165
7168651d5706 QNX quirk has been added, QNX OpenGL ES implementation is broken regarding support of textures with packed pixel formats.
Mike Gorchak <lestat@i.com.ua>
parents: 3163
diff changeset
254 #endif /* _NTO_VERSION */
7168651d5706 QNX quirk has been added, QNX OpenGL ES implementation is broken regarding support of textures with packed pixel formats.
Mike Gorchak <lestat@i.com.ua>
parents: 3163
diff changeset
255 #endif /* __QNXNTO__ */
7168651d5706 QNX quirk has been added, QNX OpenGL ES implementation is broken regarding support of textures with packed pixel formats.
Mike Gorchak <lestat@i.com.ua>
parents: 3163
diff changeset
256
2739
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
257 if (GLES_LoadFunctions(data) < 0) {
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
258 GLES_DestroyRenderer(renderer);
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
259 return NULL;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
260 }
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
261
3688
6512cba48440 Fixed Cocoa and OpenGL builds
Sam Lantinga <slouken@libsdl.org>
parents: 3685
diff changeset
262 data->context = SDL_GL_CreateContext(window);
2739
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
263 if (!data->context) {
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
264 GLES_DestroyRenderer(renderer);
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
265 return NULL;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
266 }
3688
6512cba48440 Fixed Cocoa and OpenGL builds
Sam Lantinga <slouken@libsdl.org>
parents: 3685
diff changeset
267 if (SDL_GL_MakeCurrent(window, data->context) < 0) {
2739
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
268 GLES_DestroyRenderer(renderer);
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
269 return NULL;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
270 }
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
271
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
272 if (flags & SDL_RENDERER_PRESENTVSYNC) {
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
273 SDL_GL_SetSwapInterval(1);
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
274 } else {
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
275 SDL_GL_SetSwapInterval(0);
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
276 }
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
277 if (SDL_GL_GetSwapInterval() > 0) {
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
278 renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
279 }
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
280
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
281 if (SDL_GL_GetAttribute(SDL_GL_DOUBLEBUFFER, &doublebuffer) == 0) {
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
282 if (!doublebuffer) {
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
283 renderer->info.flags |= SDL_RENDERER_SINGLEBUFFER;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
284 }
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
285 }
3161
494559cc723b OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
286 #if SDL_VIDEO_DRIVER_PANDORA
494559cc723b OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
287 data->GL_OES_draw_texture_supported = SDL_FALSE;
494559cc723b OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
288 data->useDrawTexture = SDL_FALSE;
494559cc723b OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
289 #else
2753
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
290 if (SDL_GL_ExtensionSupported("GL_OES_draw_texture")) {
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
291 data->GL_OES_draw_texture_supported = SDL_TRUE;
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
292 data->useDrawTexture = SDL_TRUE;
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
293 } else {
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
294 data->GL_OES_draw_texture_supported = SDL_FALSE;
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
295 data->useDrawTexture = SDL_FALSE;
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
296 }
3161
494559cc723b OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents: 3139
diff changeset
297 #endif
2739
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
298
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
299 data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value);
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
300 renderer->info.max_texture_width = value;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
301 data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value);
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
302 renderer->info.max_texture_height = value;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
303
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
304 /* Set up parameters for rendering */
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
305 data->blendMode = -1;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
306 data->glDisable(GL_DEPTH_TEST);
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
307 data->glDisable(GL_CULL_FACE);
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
308 data->updateSize = SDL_TRUE;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
309
5053
b5b42be9333c Fixed bug #1026
Sam Lantinga <slouken@libsdl.org>
parents: 5052
diff changeset
310 data->glEnableClientState(GL_VERTEX_ARRAY);
b5b42be9333c Fixed bug #1026
Sam Lantinga <slouken@libsdl.org>
parents: 5052
diff changeset
311 data->glEnableClientState(GL_TEXTURE_COORD_ARRAY);
b5b42be9333c Fixed bug #1026
Sam Lantinga <slouken@libsdl.org>
parents: 5052
diff changeset
312
2739
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
313 return renderer;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
314 }
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
315
2753
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
316 static int
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
317 GLES_ActivateRenderer(SDL_Renderer * renderer)
2739
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
318 {
2753
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
319
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
320 GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
3685
64ce267332c6 Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents: 3641
diff changeset
321 SDL_Window *window = renderer->window;
2753
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
322
3688
6512cba48440 Fixed Cocoa and OpenGL builds
Sam Lantinga <slouken@libsdl.org>
parents: 3685
diff changeset
323 if (SDL_GL_MakeCurrent(window, data->context) < 0) {
2739
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
324 return -1;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
325 }
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
326 if (data->updateSize) {
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
327 data->glMatrixMode(GL_PROJECTION);
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
328 data->glLoadIdentity();
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
329 data->glMatrixMode(GL_MODELVIEW);
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
330 data->glLoadIdentity();
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
331 data->glViewport(0, 0, window->w, window->h);
2753
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
332 data->glOrthof(0.0, (GLfloat) window->w, (GLfloat) window->h, 0.0,
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
333 0.0, 1.0);
2739
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
334 data->updateSize = SDL_FALSE;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
335 }
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
336 return 0;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
337 }
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
338
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
339 static int
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
340 GLES_DisplayModeChanged(SDL_Renderer * renderer)
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
341 {
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
342 GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
343
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
344 data->updateSize = SDL_TRUE;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
345 return 0;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
346 }
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
347
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
348 static __inline__ int
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
349 power_of_2(int input)
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
350 {
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
351 int value = 1;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
352
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
353 while (value < input) {
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
354 value <<= 1;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
355 }
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
356 return value;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
357 }
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
358
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
359 static int
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3122
diff changeset
360 GLES_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
2739
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
361 {
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
362 GLES_RenderData *renderdata = (GLES_RenderData *) renderer->driverdata;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
363 GLES_TextureData *data;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
364 GLint internalFormat;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
365 GLenum format, type;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
366 int texture_w, texture_h;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
367 GLenum result;
3099
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2964
diff changeset
368
2753
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
369 switch (texture->format) {
4963
604077962776 Fixed screen texture format on Android
Sam Lantinga <slouken@libsdl.org>
parents: 4929
diff changeset
370 case SDL_PIXELFORMAT_RGB24:
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3122
diff changeset
371 internalFormat = GL_RGB;
Sam Lantinga <slouken@libsdl.org>
parents: 3122
diff changeset
372 format = GL_RGB;
Sam Lantinga <slouken@libsdl.org>
parents: 3122
diff changeset
373 type = GL_UNSIGNED_BYTE;
Sam Lantinga <slouken@libsdl.org>
parents: 3122
diff changeset
374 break;
4963
604077962776 Fixed screen texture format on Android
Sam Lantinga <slouken@libsdl.org>
parents: 4929
diff changeset
375 case SDL_PIXELFORMAT_BGR888:
2753
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
376 case SDL_PIXELFORMAT_ABGR8888:
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3122
diff changeset
377 internalFormat = GL_RGBA;
Sam Lantinga <slouken@libsdl.org>
parents: 3122
diff changeset
378 format = GL_RGBA;
Sam Lantinga <slouken@libsdl.org>
parents: 3122
diff changeset
379 type = GL_UNSIGNED_BYTE;
Sam Lantinga <slouken@libsdl.org>
parents: 3122
diff changeset
380 break;
4985
047a580d30f3 Fixed blue-red channel swap in OpenGL ES 16-bit texture formats
Sam Lantinga <slouken@libsdl.org>
parents: 4963
diff changeset
381 case SDL_PIXELFORMAT_RGB565:
3163
a252014ce27d Support for BGR565 pixel format has been added, mainly for OpenGL ES renderer. OpenGL ES renderer now have new texture formats.
Mike Gorchak <lestat@i.com.ua>
parents: 3161
diff changeset
382 internalFormat = GL_RGB;
a252014ce27d Support for BGR565 pixel format has been added, mainly for OpenGL ES renderer. OpenGL ES renderer now have new texture formats.
Mike Gorchak <lestat@i.com.ua>
parents: 3161
diff changeset
383 format = GL_RGB;
a252014ce27d Support for BGR565 pixel format has been added, mainly for OpenGL ES renderer. OpenGL ES renderer now have new texture formats.
Mike Gorchak <lestat@i.com.ua>
parents: 3161
diff changeset
384 type = GL_UNSIGNED_SHORT_5_6_5;
a252014ce27d Support for BGR565 pixel format has been added, mainly for OpenGL ES renderer. OpenGL ES renderer now have new texture formats.
Mike Gorchak <lestat@i.com.ua>
parents: 3161
diff changeset
385 break;
4985
047a580d30f3 Fixed blue-red channel swap in OpenGL ES 16-bit texture formats
Sam Lantinga <slouken@libsdl.org>
parents: 4963
diff changeset
386 case SDL_PIXELFORMAT_RGBA5551:
3163
a252014ce27d Support for BGR565 pixel format has been added, mainly for OpenGL ES renderer. OpenGL ES renderer now have new texture formats.
Mike Gorchak <lestat@i.com.ua>
parents: 3161
diff changeset
387 internalFormat = GL_RGBA;
a252014ce27d Support for BGR565 pixel format has been added, mainly for OpenGL ES renderer. OpenGL ES renderer now have new texture formats.
Mike Gorchak <lestat@i.com.ua>
parents: 3161
diff changeset
388 format = GL_RGBA;
a252014ce27d Support for BGR565 pixel format has been added, mainly for OpenGL ES renderer. OpenGL ES renderer now have new texture formats.
Mike Gorchak <lestat@i.com.ua>
parents: 3161
diff changeset
389 type = GL_UNSIGNED_SHORT_5_5_5_1;
a252014ce27d Support for BGR565 pixel format has been added, mainly for OpenGL ES renderer. OpenGL ES renderer now have new texture formats.
Mike Gorchak <lestat@i.com.ua>
parents: 3161
diff changeset
390 break;
4985
047a580d30f3 Fixed blue-red channel swap in OpenGL ES 16-bit texture formats
Sam Lantinga <slouken@libsdl.org>
parents: 4963
diff changeset
391 case SDL_PIXELFORMAT_RGBA4444:
3163
a252014ce27d Support for BGR565 pixel format has been added, mainly for OpenGL ES renderer. OpenGL ES renderer now have new texture formats.
Mike Gorchak <lestat@i.com.ua>
parents: 3161
diff changeset
392 internalFormat = GL_RGBA;
a252014ce27d Support for BGR565 pixel format has been added, mainly for OpenGL ES renderer. OpenGL ES renderer now have new texture formats.
Mike Gorchak <lestat@i.com.ua>
parents: 3161
diff changeset
393 format = GL_RGBA;
a252014ce27d Support for BGR565 pixel format has been added, mainly for OpenGL ES renderer. OpenGL ES renderer now have new texture formats.
Mike Gorchak <lestat@i.com.ua>
parents: 3161
diff changeset
394 type = GL_UNSIGNED_SHORT_4_4_4_4;
a252014ce27d Support for BGR565 pixel format has been added, mainly for OpenGL ES renderer. OpenGL ES renderer now have new texture formats.
Mike Gorchak <lestat@i.com.ua>
parents: 3161
diff changeset
395 break;
2753
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
396 default:
4990
397e748d901a Improved error message for unsupported texture format
Sam Lantinga <slouken@libsdl.org>
parents: 4986
diff changeset
397 SDL_SetError("Texture format %s not supported by OpenGL ES",
397e748d901a Improved error message for unsupported texture format
Sam Lantinga <slouken@libsdl.org>
parents: 4986
diff changeset
398 SDL_GetPixelFormatName(texture->format));
2753
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
399 return -1;
2739
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
400 }
2753
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
401
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
402 data = (GLES_TextureData *) SDL_calloc(1, sizeof(*data));
2739
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
403 if (!data) {
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
404 SDL_OutOfMemory();
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
405 return -1;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
406 }
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
407
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
408 if (texture->access == SDL_TEXTUREACCESS_STREAMING) {
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
409 data->pitch = texture->w * SDL_BYTESPERPIXEL(texture->format);
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
410 data->pixels = SDL_malloc(texture->h * data->pitch);
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
411 if (!data->pixels) {
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
412 SDL_OutOfMemory();
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
413 SDL_free(data);
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
414 return -1;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
415 }
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
416 }
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
417
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
418 texture->driverdata = data;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
419
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
420 renderdata->glGetError();
3122
6c98826d88b0 OpenGL ES renderer state fixes. Now GL_TEXTURE_2D is not enabled by default.
Mike Gorchak <lestat@i.com.ua>
parents: 3099
diff changeset
421 renderdata->glEnable(GL_TEXTURE_2D);
2739
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
422 renderdata->glGenTextures(1, &data->texture);
2753
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
423
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
424 data->type = GL_TEXTURE_2D;
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
425 /* no NPOV textures allowed in OpenGL ES (yet) */
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
426 texture_w = power_of_2(texture->w);
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
427 texture_h = power_of_2(texture->h);
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
428 data->texw = (GLfloat) texture->w / texture_w;
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
429 data->texh = (GLfloat) texture->h / texture_h;
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
430
2739
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
431 data->format = format;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
432 data->formattype = type;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
433 renderdata->glBindTexture(data->type, data->texture);
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
434 renderdata->glTexParameteri(data->type, GL_TEXTURE_MIN_FILTER,
5141
da10636e5eca Making the API simpler, scaling is always defined as linear interpolation and should be supported as much as possible on all renderers.
Sam Lantinga <slouken@libsdl.org>
parents: 5053
diff changeset
435 GL_LINEAR);
2739
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
436 renderdata->glTexParameteri(data->type, GL_TEXTURE_MAG_FILTER,
5141
da10636e5eca Making the API simpler, scaling is always defined as linear interpolation and should be supported as much as possible on all renderers.
Sam Lantinga <slouken@libsdl.org>
parents: 5053
diff changeset
437 GL_LINEAR);
2739
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
438 renderdata->glTexParameteri(data->type, GL_TEXTURE_WRAP_S,
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
439 GL_CLAMP_TO_EDGE);
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
440 renderdata->glTexParameteri(data->type, GL_TEXTURE_WRAP_T,
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
441 GL_CLAMP_TO_EDGE);
2753
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
442
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
443 renderdata->glTexImage2D(data->type, 0, internalFormat, texture_w,
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
444 texture_h, 0, format, type, NULL);
3122
6c98826d88b0 OpenGL ES renderer state fixes. Now GL_TEXTURE_2D is not enabled by default.
Mike Gorchak <lestat@i.com.ua>
parents: 3099
diff changeset
445 renderdata->glDisable(GL_TEXTURE_2D);
2739
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
446
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
447 result = renderdata->glGetError();
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
448 if (result != GL_NO_ERROR) {
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
449 GLES_SetError("glTexImage2D()", result);
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
450 return -1;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
451 }
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
452 return 0;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
453 }
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
454
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
455 static int
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
456 GLES_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture,
2753
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
457 void **pixels, int *pitch)
2739
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
458 {
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
459 GLES_TextureData *data = (GLES_TextureData *) texture->driverdata;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
460
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
461 *pixels = data->pixels;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
462 *pitch = data->pitch;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
463 return 0;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
464 }
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
465
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
466 static int
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
467 GLES_SetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
2753
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
468 const SDL_Color * colors, int firstcolor, int ncolors)
2739
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
469 {
2753
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
470 SDL_SetError("OpenGL ES does not support paletted textures");
2739
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
471 return -1;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
472 }
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
473
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
474 static int
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
475 GLES_GetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
2753
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
476 SDL_Color * colors, int firstcolor, int ncolors)
2739
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
477 {
2753
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
478 SDL_SetError("OpenGL ES does not support paletted textures");
2739
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
479 return -1;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
480 }
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
481
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
482 static void
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
483 SetupTextureUpdate(GLES_RenderData * renderdata, SDL_Texture * texture,
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
484 int pitch)
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
485 {
2753
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
486 GLES_TextureData *data = (GLES_TextureData *) texture->driverdata;
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
487 renderdata->glBindTexture(data->type, data->texture);
2739
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
488 renderdata->glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
489 }
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
490
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
491 static int
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3122
diff changeset
492 GLES_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
Sam Lantinga <slouken@libsdl.org>
parents: 3122
diff changeset
493 const SDL_Rect * rect, const void *pixels, int pitch)
2739
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
494 {
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
495 GLES_RenderData *renderdata = (GLES_RenderData *) renderer->driverdata;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
496 GLES_TextureData *data = (GLES_TextureData *) texture->driverdata;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
497 GLenum result;
5052
4cb4b18cbae3 Fixed bug #1028
Sam Lantinga <slouken@libsdl.org>
parents: 4990
diff changeset
498 int bpp = SDL_BYTESPERPIXEL(texture->format);
4cb4b18cbae3 Fixed bug #1028
Sam Lantinga <slouken@libsdl.org>
parents: 4990
diff changeset
499 void * temp_buffer;
4cb4b18cbae3 Fixed bug #1028
Sam Lantinga <slouken@libsdl.org>
parents: 4990
diff changeset
500 void * temp_ptr;
4cb4b18cbae3 Fixed bug #1028
Sam Lantinga <slouken@libsdl.org>
parents: 4990
diff changeset
501 int i;
2739
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
502
3122
6c98826d88b0 OpenGL ES renderer state fixes. Now GL_TEXTURE_2D is not enabled by default.
Mike Gorchak <lestat@i.com.ua>
parents: 3099
diff changeset
503 renderdata->glGetError();
6c98826d88b0 OpenGL ES renderer state fixes. Now GL_TEXTURE_2D is not enabled by default.
Mike Gorchak <lestat@i.com.ua>
parents: 3099
diff changeset
504 renderdata->glEnable(data->type);
2739
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
505 SetupTextureUpdate(renderdata, texture, pitch);
5052
4cb4b18cbae3 Fixed bug #1028
Sam Lantinga <slouken@libsdl.org>
parents: 4990
diff changeset
506
4cb4b18cbae3 Fixed bug #1028
Sam Lantinga <slouken@libsdl.org>
parents: 4990
diff changeset
507 if( rect->w * bpp == pitch ) {
4cb4b18cbae3 Fixed bug #1028
Sam Lantinga <slouken@libsdl.org>
parents: 4990
diff changeset
508 temp_buffer = (void *)pixels; /* No need to reformat */
4cb4b18cbae3 Fixed bug #1028
Sam Lantinga <slouken@libsdl.org>
parents: 4990
diff changeset
509 } else {
4cb4b18cbae3 Fixed bug #1028
Sam Lantinga <slouken@libsdl.org>
parents: 4990
diff changeset
510 /* Reformatting of mem area required */
4cb4b18cbae3 Fixed bug #1028
Sam Lantinga <slouken@libsdl.org>
parents: 4990
diff changeset
511 temp_buffer = SDL_malloc(rect->w * rect->h * bpp);
4cb4b18cbae3 Fixed bug #1028
Sam Lantinga <slouken@libsdl.org>
parents: 4990
diff changeset
512 temp_ptr = temp_buffer;
4cb4b18cbae3 Fixed bug #1028
Sam Lantinga <slouken@libsdl.org>
parents: 4990
diff changeset
513 for (i = 0; i < rect->h; i++) {
4cb4b18cbae3 Fixed bug #1028
Sam Lantinga <slouken@libsdl.org>
parents: 4990
diff changeset
514 SDL_memcpy(temp_ptr, pixels, rect->w * bpp);
4cb4b18cbae3 Fixed bug #1028
Sam Lantinga <slouken@libsdl.org>
parents: 4990
diff changeset
515 temp_ptr += rect->w * bpp;
4cb4b18cbae3 Fixed bug #1028
Sam Lantinga <slouken@libsdl.org>
parents: 4990
diff changeset
516 pixels += pitch;
4cb4b18cbae3 Fixed bug #1028
Sam Lantinga <slouken@libsdl.org>
parents: 4990
diff changeset
517 }
4cb4b18cbae3 Fixed bug #1028
Sam Lantinga <slouken@libsdl.org>
parents: 4990
diff changeset
518 }
4cb4b18cbae3 Fixed bug #1028
Sam Lantinga <slouken@libsdl.org>
parents: 4990
diff changeset
519
2753
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
520 renderdata->glTexSubImage2D(data->type, 0, rect->x, rect->y, rect->w,
2739
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
521 rect->h, data->format, data->formattype,
5052
4cb4b18cbae3 Fixed bug #1028
Sam Lantinga <slouken@libsdl.org>
parents: 4990
diff changeset
522 temp_buffer);
4cb4b18cbae3 Fixed bug #1028
Sam Lantinga <slouken@libsdl.org>
parents: 4990
diff changeset
523
4cb4b18cbae3 Fixed bug #1028
Sam Lantinga <slouken@libsdl.org>
parents: 4990
diff changeset
524 if( temp_buffer != pixels ) {
4cb4b18cbae3 Fixed bug #1028
Sam Lantinga <slouken@libsdl.org>
parents: 4990
diff changeset
525 SDL_free(temp_buffer);
4cb4b18cbae3 Fixed bug #1028
Sam Lantinga <slouken@libsdl.org>
parents: 4990
diff changeset
526 }
4cb4b18cbae3 Fixed bug #1028
Sam Lantinga <slouken@libsdl.org>
parents: 4990
diff changeset
527
3122
6c98826d88b0 OpenGL ES renderer state fixes. Now GL_TEXTURE_2D is not enabled by default.
Mike Gorchak <lestat@i.com.ua>
parents: 3099
diff changeset
528 renderdata->glDisable(data->type);
2739
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
529 result = renderdata->glGetError();
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
530 if (result != GL_NO_ERROR) {
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
531 GLES_SetError("glTexSubImage2D()", result);
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
532 return -1;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
533 }
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
534 return 0;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
535 }
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
536
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
537 static int
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
538 GLES_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
2753
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
539 const SDL_Rect * rect, int markDirty, void **pixels,
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
540 int *pitch)
2739
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
541 {
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
542 GLES_TextureData *data = (GLES_TextureData *) texture->driverdata;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
543
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
544 if (markDirty) {
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
545 SDL_AddDirtyRect(&data->dirty, rect);
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
546 }
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
547
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
548 *pixels =
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
549 (void *) ((Uint8 *) data->pixels + rect->y * data->pitch +
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
550 rect->x * SDL_BYTESPERPIXEL(texture->format));
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
551 *pitch = data->pitch;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
552 return 0;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
553 }
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
554
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
555 static void
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
556 GLES_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
557 {
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
558 }
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
559
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
560 static void
2753
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
561 GLES_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture,
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
562 int numrects, const SDL_Rect * rects)
2739
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
563 {
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
564 GLES_TextureData *data = (GLES_TextureData *) texture->driverdata;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
565 int i;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
566
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
567 for (i = 0; i < numrects; ++i) {
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
568 SDL_AddDirtyRect(&data->dirty, &rects[i]);
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
569 }
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
570 }
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
571
2936
066384910f50 iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
572 static void
5143
e743b9c3f6d6 Making the API simpler, the blend modes are "none, blend, add" and are supported by all renderers.
Sam Lantinga <slouken@libsdl.org>
parents: 5141
diff changeset
573 GLES_SetBlendMode(GLES_RenderData * data, int blendMode)
2936
066384910f50 iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
574 {
066384910f50 iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
575 if (blendMode != data->blendMode) {
066384910f50 iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
576 switch (blendMode) {
066384910f50 iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
577 case SDL_BLENDMODE_NONE:
066384910f50 iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
578 data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
066384910f50 iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
579 data->glDisable(GL_BLEND);
066384910f50 iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
580 break;
066384910f50 iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
581 case SDL_BLENDMODE_BLEND:
066384910f50 iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
582 data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
066384910f50 iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
583 data->glEnable(GL_BLEND);
066384910f50 iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
584 data->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
066384910f50 iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
585 break;
066384910f50 iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
586 case SDL_BLENDMODE_ADD:
066384910f50 iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
587 data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
066384910f50 iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
588 data->glEnable(GL_BLEND);
066384910f50 iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
589 data->glBlendFunc(GL_SRC_ALPHA, GL_ONE);
066384910f50 iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
590 break;
066384910f50 iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
591 }
066384910f50 iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
592 data->blendMode = blendMode;
066384910f50 iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
593 }
066384910f50 iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
594 }
066384910f50 iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
595
2739
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
596 static int
3641
1e2e19d51265 Fixed iPhone build
Sam Lantinga <slouken@libsdl.org>
parents: 3547
diff changeset
597 GLES_RenderDrawPoints(SDL_Renderer * renderer, const SDL_Point * points,
1e2e19d51265 Fixed iPhone build
Sam Lantinga <slouken@libsdl.org>
parents: 3547
diff changeset
598 int count)
2936
066384910f50 iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
599 {
066384910f50 iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
600 GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
3547
8b18669c2663 Fixed building on iPhone
Sam Lantinga <slouken@libsdl.org>
parents: 3536
diff changeset
601 int i;
8b18669c2663 Fixed building on iPhone
Sam Lantinga <slouken@libsdl.org>
parents: 3536
diff changeset
602 GLshort *vertices;
2936
066384910f50 iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
603
5143
e743b9c3f6d6 Making the API simpler, the blend modes are "none, blend, add" and are supported by all renderers.
Sam Lantinga <slouken@libsdl.org>
parents: 5141
diff changeset
604 GLES_SetBlendMode(data, renderer->blendMode);
2936
066384910f50 iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
605
066384910f50 iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
606 data->glColor4f((GLfloat) renderer->r * inv255f,
066384910f50 iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
607 (GLfloat) renderer->g * inv255f,
066384910f50 iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
608 (GLfloat) renderer->b * inv255f,
066384910f50 iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
609 (GLfloat) renderer->a * inv255f);
066384910f50 iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
610
3547
8b18669c2663 Fixed building on iPhone
Sam Lantinga <slouken@libsdl.org>
parents: 3536
diff changeset
611 vertices = SDL_stack_alloc(GLshort, count*2);
8b18669c2663 Fixed building on iPhone
Sam Lantinga <slouken@libsdl.org>
parents: 3536
diff changeset
612 for (i = 0; i < count; ++i) {
8b18669c2663 Fixed building on iPhone
Sam Lantinga <slouken@libsdl.org>
parents: 3536
diff changeset
613 vertices[2*i+0] = (GLshort)points[i].x;
8b18669c2663 Fixed building on iPhone
Sam Lantinga <slouken@libsdl.org>
parents: 3536
diff changeset
614 vertices[2*i+1] = (GLshort)points[i].y;
8b18669c2663 Fixed building on iPhone
Sam Lantinga <slouken@libsdl.org>
parents: 3536
diff changeset
615 }
8b18669c2663 Fixed building on iPhone
Sam Lantinga <slouken@libsdl.org>
parents: 3536
diff changeset
616 data->glVertexPointer(2, GL_SHORT, 0, vertices);
3536
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
617 data->glDrawArrays(GL_POINTS, 0, count);
3547
8b18669c2663 Fixed building on iPhone
Sam Lantinga <slouken@libsdl.org>
parents: 3536
diff changeset
618 SDL_stack_free(vertices);
2964
Sam Lantinga <slouken@libsdl.org>
parents: 2949
diff changeset
619
2936
066384910f50 iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
620 return 0;
066384910f50 iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
621 }
066384910f50 iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
622
066384910f50 iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
623 static int
3641
1e2e19d51265 Fixed iPhone build
Sam Lantinga <slouken@libsdl.org>
parents: 3547
diff changeset
624 GLES_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points,
1e2e19d51265 Fixed iPhone build
Sam Lantinga <slouken@libsdl.org>
parents: 3547
diff changeset
625 int count)
2739
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
626 {
2936
066384910f50 iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
627 GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
3547
8b18669c2663 Fixed building on iPhone
Sam Lantinga <slouken@libsdl.org>
parents: 3536
diff changeset
628 int i;
8b18669c2663 Fixed building on iPhone
Sam Lantinga <slouken@libsdl.org>
parents: 3536
diff changeset
629 GLshort *vertices;
2753
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
630
5143
e743b9c3f6d6 Making the API simpler, the blend modes are "none, blend, add" and are supported by all renderers.
Sam Lantinga <slouken@libsdl.org>
parents: 5141
diff changeset
631 GLES_SetBlendMode(data, renderer->blendMode);
2936
066384910f50 iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
632
066384910f50 iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
633 data->glColor4f((GLfloat) renderer->r * inv255f,
066384910f50 iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
634 (GLfloat) renderer->g * inv255f,
066384910f50 iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
635 (GLfloat) renderer->b * inv255f,
066384910f50 iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
636 (GLfloat) renderer->a * inv255f);
066384910f50 iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
637
3547
8b18669c2663 Fixed building on iPhone
Sam Lantinga <slouken@libsdl.org>
parents: 3536
diff changeset
638 vertices = SDL_stack_alloc(GLshort, count*2);
8b18669c2663 Fixed building on iPhone
Sam Lantinga <slouken@libsdl.org>
parents: 3536
diff changeset
639 for (i = 0; i < count; ++i) {
8b18669c2663 Fixed building on iPhone
Sam Lantinga <slouken@libsdl.org>
parents: 3536
diff changeset
640 vertices[2*i+0] = (GLshort)points[i].x;
8b18669c2663 Fixed building on iPhone
Sam Lantinga <slouken@libsdl.org>
parents: 3536
diff changeset
641 vertices[2*i+1] = (GLshort)points[i].y;
8b18669c2663 Fixed building on iPhone
Sam Lantinga <slouken@libsdl.org>
parents: 3536
diff changeset
642 }
8b18669c2663 Fixed building on iPhone
Sam Lantinga <slouken@libsdl.org>
parents: 3536
diff changeset
643 data->glVertexPointer(2, GL_SHORT, 0, vertices);
3536
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
644 if (count > 2 &&
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
645 points[0].x == points[count-1].x && points[0].y == points[count-1].y) {
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
646 /* GL_LINE_LOOP takes care of the final segment */
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
647 --count;
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
648 data->glDrawArrays(GL_LINE_LOOP, 0, count);
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
649 } else {
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
650 data->glDrawArrays(GL_LINE_STRIP, 0, count);
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
651 }
3547
8b18669c2663 Fixed building on iPhone
Sam Lantinga <slouken@libsdl.org>
parents: 3536
diff changeset
652 SDL_stack_free(vertices);
2949
4eabc35fbb4a Modified OpenGL ES render driver to support new SDL_RenderFill, SDL_RenderLine, and SDL_RenderPoint.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents: 2937
diff changeset
653
2936
066384910f50 iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
654 return 0;
066384910f50 iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
655 }
066384910f50 iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
656
066384910f50 iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
657 static int
3641
1e2e19d51265 Fixed iPhone build
Sam Lantinga <slouken@libsdl.org>
parents: 3547
diff changeset
658 GLES_RenderDrawRects(SDL_Renderer * renderer, const SDL_Rect ** rects,
1e2e19d51265 Fixed iPhone build
Sam Lantinga <slouken@libsdl.org>
parents: 3547
diff changeset
659 int count)
1e2e19d51265 Fixed iPhone build
Sam Lantinga <slouken@libsdl.org>
parents: 3547
diff changeset
660 {
1e2e19d51265 Fixed iPhone build
Sam Lantinga <slouken@libsdl.org>
parents: 3547
diff changeset
661 GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
1e2e19d51265 Fixed iPhone build
Sam Lantinga <slouken@libsdl.org>
parents: 3547
diff changeset
662 int i;
1e2e19d51265 Fixed iPhone build
Sam Lantinga <slouken@libsdl.org>
parents: 3547
diff changeset
663
5143
e743b9c3f6d6 Making the API simpler, the blend modes are "none, blend, add" and are supported by all renderers.
Sam Lantinga <slouken@libsdl.org>
parents: 5141
diff changeset
664 GLES_SetBlendMode(data, renderer->blendMode);
3641
1e2e19d51265 Fixed iPhone build
Sam Lantinga <slouken@libsdl.org>
parents: 3547
diff changeset
665
1e2e19d51265 Fixed iPhone build
Sam Lantinga <slouken@libsdl.org>
parents: 3547
diff changeset
666 data->glColor4f((GLfloat) renderer->r * inv255f,
1e2e19d51265 Fixed iPhone build
Sam Lantinga <slouken@libsdl.org>
parents: 3547
diff changeset
667 (GLfloat) renderer->g * inv255f,
1e2e19d51265 Fixed iPhone build
Sam Lantinga <slouken@libsdl.org>
parents: 3547
diff changeset
668 (GLfloat) renderer->b * inv255f,
1e2e19d51265 Fixed iPhone build
Sam Lantinga <slouken@libsdl.org>
parents: 3547
diff changeset
669 (GLfloat) renderer->a * inv255f);
1e2e19d51265 Fixed iPhone build
Sam Lantinga <slouken@libsdl.org>
parents: 3547
diff changeset
670
1e2e19d51265 Fixed iPhone build
Sam Lantinga <slouken@libsdl.org>
parents: 3547
diff changeset
671 for (i = 0; i < count; ++i) {
1e2e19d51265 Fixed iPhone build
Sam Lantinga <slouken@libsdl.org>
parents: 3547
diff changeset
672 const SDL_Rect *rect = rects[i];
1e2e19d51265 Fixed iPhone build
Sam Lantinga <slouken@libsdl.org>
parents: 3547
diff changeset
673 GLshort minx = rect->x;
1e2e19d51265 Fixed iPhone build
Sam Lantinga <slouken@libsdl.org>
parents: 3547
diff changeset
674 GLshort maxx = rect->x + rect->w;
1e2e19d51265 Fixed iPhone build
Sam Lantinga <slouken@libsdl.org>
parents: 3547
diff changeset
675 GLshort miny = rect->y;
1e2e19d51265 Fixed iPhone build
Sam Lantinga <slouken@libsdl.org>
parents: 3547
diff changeset
676 GLshort maxy = rect->y + rect->h;
1e2e19d51265 Fixed iPhone build
Sam Lantinga <slouken@libsdl.org>
parents: 3547
diff changeset
677 GLshort vertices[8];
1e2e19d51265 Fixed iPhone build
Sam Lantinga <slouken@libsdl.org>
parents: 3547
diff changeset
678 vertices[0] = minx;
1e2e19d51265 Fixed iPhone build
Sam Lantinga <slouken@libsdl.org>
parents: 3547
diff changeset
679 vertices[1] = miny;
1e2e19d51265 Fixed iPhone build
Sam Lantinga <slouken@libsdl.org>
parents: 3547
diff changeset
680 vertices[2] = maxx;
1e2e19d51265 Fixed iPhone build
Sam Lantinga <slouken@libsdl.org>
parents: 3547
diff changeset
681 vertices[3] = miny;
1e2e19d51265 Fixed iPhone build
Sam Lantinga <slouken@libsdl.org>
parents: 3547
diff changeset
682 vertices[4] = minx;
1e2e19d51265 Fixed iPhone build
Sam Lantinga <slouken@libsdl.org>
parents: 3547
diff changeset
683 vertices[5] = maxy;
1e2e19d51265 Fixed iPhone build
Sam Lantinga <slouken@libsdl.org>
parents: 3547
diff changeset
684 vertices[6] = maxx;
1e2e19d51265 Fixed iPhone build
Sam Lantinga <slouken@libsdl.org>
parents: 3547
diff changeset
685 vertices[7] = maxy;
1e2e19d51265 Fixed iPhone build
Sam Lantinga <slouken@libsdl.org>
parents: 3547
diff changeset
686
1e2e19d51265 Fixed iPhone build
Sam Lantinga <slouken@libsdl.org>
parents: 3547
diff changeset
687 data->glVertexPointer(2, GL_SHORT, 0, vertices);
1e2e19d51265 Fixed iPhone build
Sam Lantinga <slouken@libsdl.org>
parents: 3547
diff changeset
688 data->glDrawArrays(GL_LINE_LOOP, 0, 4);
1e2e19d51265 Fixed iPhone build
Sam Lantinga <slouken@libsdl.org>
parents: 3547
diff changeset
689 }
1e2e19d51265 Fixed iPhone build
Sam Lantinga <slouken@libsdl.org>
parents: 3547
diff changeset
690
1e2e19d51265 Fixed iPhone build
Sam Lantinga <slouken@libsdl.org>
parents: 3547
diff changeset
691 return 0;
1e2e19d51265 Fixed iPhone build
Sam Lantinga <slouken@libsdl.org>
parents: 3547
diff changeset
692 }
1e2e19d51265 Fixed iPhone build
Sam Lantinga <slouken@libsdl.org>
parents: 3547
diff changeset
693
1e2e19d51265 Fixed iPhone build
Sam Lantinga <slouken@libsdl.org>
parents: 3547
diff changeset
694 static int
1e2e19d51265 Fixed iPhone build
Sam Lantinga <slouken@libsdl.org>
parents: 3547
diff changeset
695 GLES_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects,
1e2e19d51265 Fixed iPhone build
Sam Lantinga <slouken@libsdl.org>
parents: 3547
diff changeset
696 int count)
2936
066384910f50 iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
697 {
2753
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
698 GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
3536
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
699 int i;
2753
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
700
5143
e743b9c3f6d6 Making the API simpler, the blend modes are "none, blend, add" and are supported by all renderers.
Sam Lantinga <slouken@libsdl.org>
parents: 5141
diff changeset
701 GLES_SetBlendMode(data, renderer->blendMode);
2753
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
702
2936
066384910f50 iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
703 data->glColor4f((GLfloat) renderer->r * inv255f,
066384910f50 iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
704 (GLfloat) renderer->g * inv255f,
066384910f50 iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
705 (GLfloat) renderer->b * inv255f,
066384910f50 iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents: 2884
diff changeset
706 (GLfloat) renderer->a * inv255f);
2753
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
707
3536
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
708 for (i = 0; i < count; ++i) {
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
709 const SDL_Rect *rect = rects[i];
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
710 GLshort minx = rect->x;
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
711 GLshort maxx = rect->x + rect->w;
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
712 GLshort miny = rect->y;
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
713 GLshort maxy = rect->y + rect->h;
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
714 GLshort vertices[8];
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
715 vertices[0] = minx;
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
716 vertices[1] = miny;
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
717 vertices[2] = maxx;
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
718 vertices[3] = miny;
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
719 vertices[4] = minx;
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
720 vertices[5] = maxy;
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
721 vertices[6] = maxx;
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
722 vertices[7] = maxy;
2964
Sam Lantinga <slouken@libsdl.org>
parents: 2949
diff changeset
723
3536
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
724 data->glVertexPointer(2, GL_SHORT, 0, vertices);
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
725 data->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 3520
diff changeset
726 }
2949
4eabc35fbb4a Modified OpenGL ES render driver to support new SDL_RenderFill, SDL_RenderLine, and SDL_RenderPoint.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents: 2937
diff changeset
727
2753
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
728 return 0;
2739
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
729 }
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
730
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
731 static int
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
732 GLES_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
2753
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
733 const SDL_Rect * srcrect, const SDL_Rect * dstrect)
2739
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
734 {
2753
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
735
2739
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
736 GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
737 GLES_TextureData *texturedata = (GLES_TextureData *) texture->driverdata;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
738 int minx, miny, maxx, maxy;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
739 GLfloat minu, maxu, minv, maxv;
2753
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
740 int i;
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
741 void *temp_buffer; /* used for reformatting dirty rect pixels */
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
742 void *temp_ptr;
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
743
3122
6c98826d88b0 OpenGL ES renderer state fixes. Now GL_TEXTURE_2D is not enabled by default.
Mike Gorchak <lestat@i.com.ua>
parents: 3099
diff changeset
744 data->glEnable(GL_TEXTURE_2D);
6c98826d88b0 OpenGL ES renderer state fixes. Now GL_TEXTURE_2D is not enabled by default.
Mike Gorchak <lestat@i.com.ua>
parents: 3099
diff changeset
745
2739
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
746 if (texturedata->dirty.list) {
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
747 SDL_DirtyRect *dirty;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
748 void *pixels;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
749 int bpp = SDL_BYTESPERPIXEL(texture->format);
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
750 int pitch = texturedata->pitch;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
751
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
752 SetupTextureUpdate(data, texture, pitch);
2753
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
753
2739
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
754 data->glBindTexture(texturedata->type, texturedata->texture);
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
755 for (dirty = texturedata->dirty.list; dirty; dirty = dirty->next) {
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
756 SDL_Rect *rect = &dirty->rect;
2753
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
757 pixels =
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
758 (void *) ((Uint8 *) texturedata->pixels + rect->y * pitch +
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
759 rect->x * bpp);
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
760 /* There is no GL_UNPACK_ROW_LENGTH in OpenGLES
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
761 we must do this reformatting ourselves(!)
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
762
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
763 maybe it'd be a good idea to keep a temp buffer around
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
764 for this purpose rather than allocating it each time
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
765 */
4525
3abf0b9cafad pelya 2010-07-12 03:53:48 PDT
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
766 if( rect->x == 0 && rect->w * bpp == pitch ) {
3abf0b9cafad pelya 2010-07-12 03:53:48 PDT
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
767 temp_buffer = pixels; /* Updating whole texture, no need to reformat */
3abf0b9cafad pelya 2010-07-12 03:53:48 PDT
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
768 } else {
3abf0b9cafad pelya 2010-07-12 03:53:48 PDT
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
769 temp_buffer = SDL_malloc(rect->w * rect->h * bpp);
3abf0b9cafad pelya 2010-07-12 03:53:48 PDT
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
770 temp_ptr = temp_buffer;
3abf0b9cafad pelya 2010-07-12 03:53:48 PDT
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
771 for (i = 0; i < rect->h; i++) {
3abf0b9cafad pelya 2010-07-12 03:53:48 PDT
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
772 SDL_memcpy(temp_ptr, pixels, rect->w * bpp);
3abf0b9cafad pelya 2010-07-12 03:53:48 PDT
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
773 temp_ptr += rect->w * bpp;
3abf0b9cafad pelya 2010-07-12 03:53:48 PDT
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
774 pixels += pitch;
3abf0b9cafad pelya 2010-07-12 03:53:48 PDT
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
775 }
2753
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
776 }
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
777
2739
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
778 data->glTexSubImage2D(texturedata->type, 0, rect->x, rect->y,
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
779 rect->w, rect->h, texturedata->format,
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
780 texturedata->formattype, temp_buffer);
2753
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
781
4525
3abf0b9cafad pelya 2010-07-12 03:53:48 PDT
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
782 if( temp_buffer != pixels ) {
3abf0b9cafad pelya 2010-07-12 03:53:48 PDT
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
783 SDL_free(temp_buffer);
3abf0b9cafad pelya 2010-07-12 03:53:48 PDT
Sam Lantinga <slouken@libsdl.org>
parents: 3697
diff changeset
784 }
2739
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
785 }
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
786 SDL_ClearDirtyRects(&texturedata->dirty);
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
787 }
2753
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
788
2739
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
789 data->glBindTexture(texturedata->type, texturedata->texture);
2753
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
790
2739
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
791 if (texture->modMode) {
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
792 data->glColor4f((GLfloat) texture->r * inv255f,
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
793 (GLfloat) texture->g * inv255f,
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
794 (GLfloat) texture->b * inv255f,
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
795 (GLfloat) texture->a * inv255f);
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
796 } else {
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
797 data->glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
798 }
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
799
5143
e743b9c3f6d6 Making the API simpler, the blend modes are "none, blend, add" and are supported by all renderers.
Sam Lantinga <slouken@libsdl.org>
parents: 5141
diff changeset
800 GLES_SetBlendMode(data, texture->blendMode);
2739
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
801
2753
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
802 if (data->GL_OES_draw_texture_supported && data->useDrawTexture) {
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
803 /* this code is a little funny because the viewport is upside down vs SDL's coordinate system */
3685
64ce267332c6 Switched from SDL_WindowID and SDL_TextureID to SDL_Window* and SDL_Texture* for code simplicity and improved performance.
Sam Lantinga <slouken@libsdl.org>
parents: 3641
diff changeset
804 SDL_Window *window = renderer->window;
2753
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
805 GLint cropRect[4];
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
806 cropRect[0] = srcrect->x;
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
807 cropRect[1] = srcrect->y + srcrect->h;
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
808 cropRect[2] = srcrect->w;
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
809 cropRect[3] = -srcrect->h;
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
810 data->glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES,
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
811 cropRect);
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
812 data->glDrawTexiOES(dstrect->x, window->h - dstrect->y - dstrect->h,
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
813 0, dstrect->w, dstrect->h);
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
814 } else {
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
815
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
816 minx = dstrect->x;
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
817 miny = dstrect->y;
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
818 maxx = dstrect->x + dstrect->w;
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
819 maxy = dstrect->y + dstrect->h;
2739
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
820
2753
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
821 minu = (GLfloat) srcrect->x / texture->w;
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
822 minu *= texturedata->texw;
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
823 maxu = (GLfloat) (srcrect->x + srcrect->w) / texture->w;
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
824 maxu *= texturedata->texw;
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
825 minv = (GLfloat) srcrect->y / texture->h;
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
826 minv *= texturedata->texh;
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
827 maxv = (GLfloat) (srcrect->y + srcrect->h) / texture->h;
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
828 maxv *= texturedata->texh;
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
829
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
830 GLshort vertices[8];
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
831 GLfloat texCoords[8];
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
832
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
833 vertices[0] = minx;
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
834 vertices[1] = miny;
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
835 vertices[2] = maxx;
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
836 vertices[3] = miny;
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
837 vertices[4] = minx;
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
838 vertices[5] = maxy;
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
839 vertices[6] = maxx;
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
840 vertices[7] = maxy;
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
841
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
842 texCoords[0] = minu;
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
843 texCoords[1] = minv;
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
844 texCoords[2] = maxu;
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
845 texCoords[3] = minv;
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
846 texCoords[4] = minu;
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
847 texCoords[5] = maxv;
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
848 texCoords[6] = maxu;
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
849 texCoords[7] = maxv;
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
850
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
851 data->glVertexPointer(2, GL_SHORT, 0, vertices);
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
852 data->glTexCoordPointer(2, GL_FLOAT, 0, texCoords);
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
853 data->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
3122
6c98826d88b0 OpenGL ES renderer state fixes. Now GL_TEXTURE_2D is not enabled by default.
Mike Gorchak <lestat@i.com.ua>
parents: 3099
diff changeset
854 }
2753
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
855
3122
6c98826d88b0 OpenGL ES renderer state fixes. Now GL_TEXTURE_2D is not enabled by default.
Mike Gorchak <lestat@i.com.ua>
parents: 3099
diff changeset
856 data->glDisable(GL_TEXTURE_2D);
2753
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
857
2739
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
858 return 0;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
859 }
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
860
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
861 static void
3139
Sam Lantinga <slouken@libsdl.org>
parents: 3122
diff changeset
862 GLES_RenderPresent(SDL_Renderer * renderer)
2739
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
863 {
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
864 SDL_GL_SwapWindow(renderer->window);
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
865 }
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
866
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
867 static void
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
868 GLES_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
869 {
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
870 GLES_TextureData *data = (GLES_TextureData *) texture->driverdata;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
871
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
872 if (!data) {
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
873 return;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
874 }
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
875 if (data->texture) {
2753
Sam Lantinga <slouken@libsdl.org>
parents: 2739
diff changeset
876 glDeleteTextures(1, &data->texture);
2739
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
877 }
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
878 if (data->pixels) {
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
879 SDL_free(data->pixels);
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
880 }
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
881 SDL_FreeDirtyRects(&data->dirty);
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
882 SDL_free(data);
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
883 texture->driverdata = NULL;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
884 }
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
885
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
886 static void
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
887 GLES_DestroyRenderer(SDL_Renderer * renderer)
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
888 {
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
889 GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
890
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
891 if (data) {
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
892 if (data->context) {
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
893 SDL_GL_DeleteContext(data->context);
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
894 }
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
895 SDL_free(data);
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
896 }
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
897 SDL_free(renderer);
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
898 }
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
899
3099
82e60908fab1 Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 2964
diff changeset
900 #endif /* SDL_VIDEO_RENDER_OGL_ES */
2739
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
901
68862734a5fd These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff changeset
902 /* vi: set ts=4 sw=4 expandtab: */