Mercurial > sdl-ios-xcode
annotate src/video/SDL_renderer_gles.c @ 5152:be02be2ea897
Making the API simpler, removed support for palettized video modes and textures.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Tue, 01 Feb 2011 21:23:43 -0800 |
parents | 5429daf5e3f9 |
children | 1435f8a6425c |
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 | 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 | 44 GL_API void GL_APIENTRY |
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 | 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); |
5150
ad50b3db78bd
The rendering functions take a context so it's clear what window they're drawing to. This also potentially opens to the door to multi-threaded rendering in the future.
Sam Lantinga <slouken@libsdl.org>
parents:
5145
diff
changeset
|
57 static void GLES_WindowEvent(SDL_Renderer * renderer, |
ad50b3db78bd
The rendering functions take a context so it's clear what window they're drawing to. This also potentially opens to the door to multi-threaded rendering in the future.
Sam Lantinga <slouken@libsdl.org>
parents:
5145
diff
changeset
|
58 const SDL_WindowEvent *event); |
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
|
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 | 61 SDL_Texture * texture, void **pixels, |
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_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, |
2753 | 64 const SDL_Rect * rect, const void *pixels, |
65 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
|
66 static int GLES_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, |
2753 | 67 const SDL_Rect * rect, int markDirty, |
68 void **pixels, int *pitch); | |
69 static void GLES_UnlockTexture(SDL_Renderer * renderer, | |
70 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
|
71 static void GLES_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture, |
2753 | 72 int numrects, const SDL_Rect * rects); |
3641 | 73 static int GLES_RenderDrawPoints(SDL_Renderer * renderer, |
74 const SDL_Point * points, int count); | |
75 static int GLES_RenderDrawLines(SDL_Renderer * renderer, | |
76 const SDL_Point * points, int count); | |
77 static int GLES_RenderFillRects(SDL_Renderer * renderer, | |
78 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
|
79 static int GLES_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, |
2753 | 80 const SDL_Rect * srcrect, |
81 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
|
82 static void GLES_RenderPresent(SDL_Renderer * renderer); |
2753 | 83 static void GLES_DestroyTexture(SDL_Renderer * renderer, |
84 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
|
85 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
|
86 |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
87 |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.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 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
|
89 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
|
90 { |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.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 "opengl_es", |
5145
c8e049de174c
Making the API simpler, the renderer present semantics are always having a backbuffer and then discarding it. This is best for hardware accelerated rendering.
Sam Lantinga <slouken@libsdl.org>
parents:
5144
diff
changeset
|
92 (SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED), |
2753 | 93 { |
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
|
94 /* 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
|
95 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
|
96 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
|
97 SDL_PIXELFORMAT_RGB565, |
4963
604077962776
Fixed screen texture format on Android
Sam Lantinga <slouken@libsdl.org>
parents:
4929
diff
changeset
|
98 SDL_PIXELFORMAT_RGB24, |
604077962776
Fixed screen texture format on Android
Sam Lantinga <slouken@libsdl.org>
parents:
4929
diff
changeset
|
99 SDL_PIXELFORMAT_BGR888, |
3139 | 100 SDL_PIXELFORMAT_ABGR8888}, |
2753 | 101 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
|
102 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
|
103 }; |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
104 |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
105 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
|
106 { |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
107 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
|
108 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
|
109 int blendMode; |
2753 | 110 |
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
|
111 #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
|
112 #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
|
113 #endif |
2753 | 114 |
115 SDL_bool useDrawTexture; | |
116 SDL_bool GL_OES_draw_texture_supported; | |
117 | |
118 /* OpenGL ES functions */ | |
119 #define SDL_PROC(ret,func,params) ret (APIENTRY *func) params; | |
120 #include "SDL_glesfuncs.h" | |
121 #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
|
122 |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.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 } 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
|
124 |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
125 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
|
126 { |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
127 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
|
128 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
|
129 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
|
130 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
|
131 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
|
132 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
|
133 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
|
134 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
|
135 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
|
136 } 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
|
137 |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.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 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
|
139 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
|
140 { |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.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 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
|
142 |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.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 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
|
144 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
|
145 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
|
146 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
|
147 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
|
148 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
|
149 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
|
150 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
|
151 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
|
152 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
|
153 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
|
154 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
|
155 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
|
156 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
|
157 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
|
158 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
|
159 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
|
160 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
|
161 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
|
162 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
|
163 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
|
164 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
|
165 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
|
166 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
|
167 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
|
168 } |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.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 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
|
170 } |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.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 |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.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 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
|
173 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
|
174 { |
2753 | 175 |
176 #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
|
177 data->func = func; |
2753 | 178 #include "SDL_glesfuncs.h" |
179 #undef SDL_PROC | |
180 | |
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
|
181 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
|
182 } |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.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 |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.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 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
|
185 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
|
186 { |
2753 | 187 |
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
|
188 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
|
189 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
|
190 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
|
191 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
|
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 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
|
194 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
|
195 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
|
196 } |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
197 } |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.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 |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.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 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
|
200 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
|
201 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
|
202 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
|
203 } |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.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 |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.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 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
|
206 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
|
207 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
|
208 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
|
209 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
|
210 } |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.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 |
5150
ad50b3db78bd
The rendering functions take a context so it's clear what window they're drawing to. This also potentially opens to the door to multi-threaded rendering in the future.
Sam Lantinga <slouken@libsdl.org>
parents:
5145
diff
changeset
|
212 renderer->WindowEvent = GLES_WindowEvent; |
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
|
213 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
|
214 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
|
215 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
|
216 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
|
217 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
|
218 renderer->DirtyTexture = GLES_DirtyTexture; |
3641 | 219 renderer->RenderDrawPoints = GLES_RenderDrawPoints; |
220 renderer->RenderDrawLines = GLES_RenderDrawLines; | |
221 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
|
222 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
|
223 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
|
224 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
|
225 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
|
226 renderer->info = GL_ES_RenderDriver.info; |
3688
6512cba48440
Fixed Cocoa and OpenGL builds
Sam Lantinga <slouken@libsdl.org>
parents:
3685
diff
changeset
|
227 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
|
228 renderer->driverdata = data; |
2753 | 229 |
5145
c8e049de174c
Making the API simpler, the renderer present semantics are always having a backbuffer and then discarding it. This is best for hardware accelerated rendering.
Sam Lantinga <slouken@libsdl.org>
parents:
5144
diff
changeset
|
230 renderer->info.flags = 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
|
231 |
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
|
232 #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
|
233 #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
|
234 /* 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
|
235 /* packed textures support, affected versions 6.3.2, 6.4.0, 6.4.1 */ |
3169 | 236 renderer->info.num_texture_formats = 2; |
237 renderer->info.texture_formats[0] = SDL_PIXELFORMAT_ABGR8888; | |
238 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
|
239 #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
|
240 #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
|
241 |
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 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
|
243 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
|
244 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
|
245 } |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.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 |
3688
6512cba48440
Fixed Cocoa and OpenGL builds
Sam Lantinga <slouken@libsdl.org>
parents:
3685
diff
changeset
|
247 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
|
248 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
|
249 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
|
250 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
|
251 } |
3688
6512cba48440
Fixed Cocoa and OpenGL builds
Sam Lantinga <slouken@libsdl.org>
parents:
3685
diff
changeset
|
252 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
|
253 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
|
254 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
|
255 } |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
256 |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.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 (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
|
258 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
|
259 } 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
|
260 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
|
261 } |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
262 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
|
263 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
|
264 } |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.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 |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.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 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
|
267 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
|
268 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
|
269 } |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.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 } |
3161
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3139
diff
changeset
|
271 #if SDL_VIDEO_DRIVER_PANDORA |
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3139
diff
changeset
|
272 data->GL_OES_draw_texture_supported = SDL_FALSE; |
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3139
diff
changeset
|
273 data->useDrawTexture = SDL_FALSE; |
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3139
diff
changeset
|
274 #else |
2753 | 275 if (SDL_GL_ExtensionSupported("GL_OES_draw_texture")) { |
276 data->GL_OES_draw_texture_supported = SDL_TRUE; | |
277 data->useDrawTexture = SDL_TRUE; | |
278 } else { | |
279 data->GL_OES_draw_texture_supported = SDL_FALSE; | |
280 data->useDrawTexture = SDL_FALSE; | |
281 } | |
3161
494559cc723b
OpenPandora support added by David Carré
Sam Lantinga <slouken@libsdl.org>
parents:
3139
diff
changeset
|
282 #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
|
283 |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.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 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
|
285 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
|
286 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
|
287 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
|
288 |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
289 /* 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
|
290 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
|
291 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
|
292 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
|
293 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
|
294 |
5053 | 295 data->glEnableClientState(GL_VERTEX_ARRAY); |
296 data->glEnableClientState(GL_TEXTURE_COORD_ARRAY); | |
297 | |
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 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
|
299 } |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.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 |
5150
ad50b3db78bd
The rendering functions take a context so it's clear what window they're drawing to. This also potentially opens to the door to multi-threaded rendering in the future.
Sam Lantinga <slouken@libsdl.org>
parents:
5145
diff
changeset
|
301 static SDL_GLContext SDL_CurrentContext = NULL; |
ad50b3db78bd
The rendering functions take a context so it's clear what window they're drawing to. This also potentially opens to the door to multi-threaded rendering in the future.
Sam Lantinga <slouken@libsdl.org>
parents:
5145
diff
changeset
|
302 |
2753 | 303 static int |
304 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
|
305 { |
2753 | 306 |
307 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
|
308 SDL_Window *window = renderer->window; |
2753 | 309 |
5150
ad50b3db78bd
The rendering functions take a context so it's clear what window they're drawing to. This also potentially opens to the door to multi-threaded rendering in the future.
Sam Lantinga <slouken@libsdl.org>
parents:
5145
diff
changeset
|
310 if (SDL_CurrentContext != data->context) { |
ad50b3db78bd
The rendering functions take a context so it's clear what window they're drawing to. This also potentially opens to the door to multi-threaded rendering in the future.
Sam Lantinga <slouken@libsdl.org>
parents:
5145
diff
changeset
|
311 if (SDL_GL_MakeCurrent(window, data->context) < 0) { |
ad50b3db78bd
The rendering functions take a context so it's clear what window they're drawing to. This also potentially opens to the door to multi-threaded rendering in the future.
Sam Lantinga <slouken@libsdl.org>
parents:
5145
diff
changeset
|
312 return -1; |
ad50b3db78bd
The rendering functions take a context so it's clear what window they're drawing to. This also potentially opens to the door to multi-threaded rendering in the future.
Sam Lantinga <slouken@libsdl.org>
parents:
5145
diff
changeset
|
313 } |
ad50b3db78bd
The rendering functions take a context so it's clear what window they're drawing to. This also potentially opens to the door to multi-threaded rendering in the future.
Sam Lantinga <slouken@libsdl.org>
parents:
5145
diff
changeset
|
314 SDL_CurrentContext = data->context; |
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
|
315 } |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
316 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
|
317 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
|
318 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
|
319 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
|
320 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
|
321 data->glViewport(0, 0, window->w, window->h); |
2753 | 322 data->glOrthof(0.0, (GLfloat) window->w, (GLfloat) window->h, 0.0, |
323 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
|
324 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
|
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 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
|
327 } |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.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 |
5150
ad50b3db78bd
The rendering functions take a context so it's clear what window they're drawing to. This also potentially opens to the door to multi-threaded rendering in the future.
Sam Lantinga <slouken@libsdl.org>
parents:
5145
diff
changeset
|
329 static void |
ad50b3db78bd
The rendering functions take a context so it's clear what window they're drawing to. This also potentially opens to the door to multi-threaded rendering in the future.
Sam Lantinga <slouken@libsdl.org>
parents:
5145
diff
changeset
|
330 GLES_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event) |
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
|
331 { |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
332 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
|
333 |
5150
ad50b3db78bd
The rendering functions take a context so it's clear what window they're drawing to. This also potentially opens to the door to multi-threaded rendering in the future.
Sam Lantinga <slouken@libsdl.org>
parents:
5145
diff
changeset
|
334 if (event->event == SDL_WINDOWEVENT_RESIZED) { |
ad50b3db78bd
The rendering functions take a context so it's clear what window they're drawing to. This also potentially opens to the door to multi-threaded rendering in the future.
Sam Lantinga <slouken@libsdl.org>
parents:
5145
diff
changeset
|
335 /* Rebind the context to the window area and update matrices */ |
ad50b3db78bd
The rendering functions take a context so it's clear what window they're drawing to. This also potentially opens to the door to multi-threaded rendering in the future.
Sam Lantinga <slouken@libsdl.org>
parents:
5145
diff
changeset
|
336 SDL_CurrentContext = NULL; |
ad50b3db78bd
The rendering functions take a context so it's clear what window they're drawing to. This also potentially opens to the door to multi-threaded rendering in the future.
Sam Lantinga <slouken@libsdl.org>
parents:
5145
diff
changeset
|
337 data->updateSize = SDL_TRUE; |
ad50b3db78bd
The rendering functions take a context so it's clear what window they're drawing to. This also potentially opens to the door to multi-threaded rendering in the future.
Sam Lantinga <slouken@libsdl.org>
parents:
5145
diff
changeset
|
338 } |
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
|
339 } |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.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 |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.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 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
|
342 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
|
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 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
|
345 |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.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 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
|
347 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
|
348 } |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.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 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
|
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 |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.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 static int |
3139 | 353 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
|
354 { |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.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 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
|
356 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
|
357 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
|
358 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
|
359 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
|
360 GLenum result; |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2964
diff
changeset
|
361 |
5150
ad50b3db78bd
The rendering functions take a context so it's clear what window they're drawing to. This also potentially opens to the door to multi-threaded rendering in the future.
Sam Lantinga <slouken@libsdl.org>
parents:
5145
diff
changeset
|
362 GLES_ActivateRenderer(renderer); |
ad50b3db78bd
The rendering functions take a context so it's clear what window they're drawing to. This also potentially opens to the door to multi-threaded rendering in the future.
Sam Lantinga <slouken@libsdl.org>
parents:
5145
diff
changeset
|
363 |
2753 | 364 switch (texture->format) { |
4963
604077962776
Fixed screen texture format on Android
Sam Lantinga <slouken@libsdl.org>
parents:
4929
diff
changeset
|
365 case SDL_PIXELFORMAT_RGB24: |
3139 | 366 internalFormat = GL_RGB; |
367 format = GL_RGB; | |
368 type = GL_UNSIGNED_BYTE; | |
369 break; | |
4963
604077962776
Fixed screen texture format on Android
Sam Lantinga <slouken@libsdl.org>
parents:
4929
diff
changeset
|
370 case SDL_PIXELFORMAT_BGR888: |
2753 | 371 case SDL_PIXELFORMAT_ABGR8888: |
3139 | 372 internalFormat = GL_RGBA; |
373 format = GL_RGBA; | |
374 type = GL_UNSIGNED_BYTE; | |
375 break; | |
4985
047a580d30f3
Fixed blue-red channel swap in OpenGL ES 16-bit texture formats
Sam Lantinga <slouken@libsdl.org>
parents:
4963
diff
changeset
|
376 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
|
377 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
|
378 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
|
379 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
|
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_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
|
382 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
|
383 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
|
384 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
|
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_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
|
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_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
|
390 break; |
2753 | 391 default: |
4990
397e748d901a
Improved error message for unsupported texture format
Sam Lantinga <slouken@libsdl.org>
parents:
4986
diff
changeset
|
392 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
|
393 SDL_GetPixelFormatName(texture->format)); |
2753 | 394 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
|
395 } |
2753 | 396 |
397 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
|
398 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
|
399 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
|
400 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
|
401 } |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
402 |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.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 (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
|
404 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
|
405 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
|
406 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
|
407 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
|
408 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
|
409 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
|
410 } |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.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 } |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.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 |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.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 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
|
414 |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.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 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
|
416 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
|
417 renderdata->glGenTextures(1, &data->texture); |
2753 | 418 |
419 data->type = GL_TEXTURE_2D; | |
420 /* no NPOV textures allowed in OpenGL ES (yet) */ | |
421 texture_w = power_of_2(texture->w); | |
422 texture_h = power_of_2(texture->h); | |
423 data->texw = (GLfloat) texture->w / texture_w; | |
424 data->texh = (GLfloat) texture->h / texture_h; | |
425 | |
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
|
426 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
|
427 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
|
428 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
|
429 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
|
430 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
|
431 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
|
432 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
|
433 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
|
434 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
|
435 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
|
436 GL_CLAMP_TO_EDGE); |
2753 | 437 |
438 renderdata->glTexImage2D(data->type, 0, internalFormat, texture_w, | |
439 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
|
440 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
|
441 |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
442 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
|
443 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
|
444 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
|
445 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
|
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 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
|
448 } |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.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 |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.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 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
|
451 GLES_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture, |
2753 | 452 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
|
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 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
|
455 |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.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 *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
|
457 *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
|
458 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
|
459 } |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.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 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
|
462 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
|
463 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
|
464 { |
2753 | 465 GLES_TextureData *data = (GLES_TextureData *) texture->driverdata; |
466 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
|
467 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
|
468 } |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.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 |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
470 static int |
3139 | 471 GLES_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, |
472 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
|
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 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
|
475 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
|
476 GLenum result; |
5052 | 477 int bpp = SDL_BYTESPERPIXEL(texture->format); |
478 void * temp_buffer; | |
479 void * temp_ptr; | |
480 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
|
481 |
5150
ad50b3db78bd
The rendering functions take a context so it's clear what window they're drawing to. This also potentially opens to the door to multi-threaded rendering in the future.
Sam Lantinga <slouken@libsdl.org>
parents:
5145
diff
changeset
|
482 GLES_ActivateRenderer(renderer); |
ad50b3db78bd
The rendering functions take a context so it's clear what window they're drawing to. This also potentially opens to the door to multi-threaded rendering in the future.
Sam Lantinga <slouken@libsdl.org>
parents:
5145
diff
changeset
|
483 |
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
|
484 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
|
485 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
|
486 SetupTextureUpdate(renderdata, texture, pitch); |
5052 | 487 |
488 if( rect->w * bpp == pitch ) { | |
489 temp_buffer = (void *)pixels; /* No need to reformat */ | |
490 } else { | |
491 /* Reformatting of mem area required */ | |
492 temp_buffer = SDL_malloc(rect->w * rect->h * bpp); | |
493 temp_ptr = temp_buffer; | |
494 for (i = 0; i < rect->h; i++) { | |
495 SDL_memcpy(temp_ptr, pixels, rect->w * bpp); | |
496 temp_ptr += rect->w * bpp; | |
497 pixels += pitch; | |
498 } | |
499 } | |
500 | |
2753 | 501 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
|
502 rect->h, data->format, data->formattype, |
5052 | 503 temp_buffer); |
504 | |
505 if( temp_buffer != pixels ) { | |
506 SDL_free(temp_buffer); | |
507 } | |
508 | |
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
|
509 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
|
510 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
|
511 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
|
512 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
|
513 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
|
514 } |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
515 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
|
516 } |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
517 |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
518 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
|
519 GLES_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, |
2753 | 520 const SDL_Rect * rect, int markDirty, void **pixels, |
521 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
|
522 { |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
523 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
|
524 |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
525 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
|
526 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
|
527 } |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
528 |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.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 *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
|
530 (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
|
531 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
|
532 *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
|
533 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
|
534 } |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.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 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
|
537 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
|
538 { |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
539 } |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
540 |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.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 static void |
2753 | 542 GLES_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture, |
543 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
|
544 { |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.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 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
|
546 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
|
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 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
|
549 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
|
550 } |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.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 } |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.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 |
2936
066384910f50
iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents:
2884
diff
changeset
|
553 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
|
554 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
|
555 { |
066384910f50
iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents:
2884
diff
changeset
|
556 if (blendMode != data->blendMode) { |
066384910f50
iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents:
2884
diff
changeset
|
557 switch (blendMode) { |
066384910f50
iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents:
2884
diff
changeset
|
558 case SDL_BLENDMODE_NONE: |
066384910f50
iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents:
2884
diff
changeset
|
559 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
|
560 data->glDisable(GL_BLEND); |
066384910f50
iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents:
2884
diff
changeset
|
561 break; |
066384910f50
iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents:
2884
diff
changeset
|
562 case SDL_BLENDMODE_BLEND: |
066384910f50
iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents:
2884
diff
changeset
|
563 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
|
564 data->glEnable(GL_BLEND); |
066384910f50
iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents:
2884
diff
changeset
|
565 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
|
566 break; |
066384910f50
iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents:
2884
diff
changeset
|
567 case SDL_BLENDMODE_ADD: |
066384910f50
iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents:
2884
diff
changeset
|
568 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
|
569 data->glEnable(GL_BLEND); |
066384910f50
iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents:
2884
diff
changeset
|
570 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
|
571 break; |
066384910f50
iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents:
2884
diff
changeset
|
572 } |
066384910f50
iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents:
2884
diff
changeset
|
573 data->blendMode = blendMode; |
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 } |
066384910f50
iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents:
2884
diff
changeset
|
576 |
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
|
577 static int |
3641 | 578 GLES_RenderDrawPoints(SDL_Renderer * renderer, const SDL_Point * points, |
579 int count) | |
2936
066384910f50
iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents:
2884
diff
changeset
|
580 { |
066384910f50
iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents:
2884
diff
changeset
|
581 GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; |
3547
8b18669c2663
Fixed building on iPhone
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
582 int i; |
8b18669c2663
Fixed building on iPhone
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
583 GLshort *vertices; |
2936
066384910f50
iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents:
2884
diff
changeset
|
584 |
5150
ad50b3db78bd
The rendering functions take a context so it's clear what window they're drawing to. This also potentially opens to the door to multi-threaded rendering in the future.
Sam Lantinga <slouken@libsdl.org>
parents:
5145
diff
changeset
|
585 GLES_ActivateRenderer(renderer); |
ad50b3db78bd
The rendering functions take a context so it's clear what window they're drawing to. This also potentially opens to the door to multi-threaded rendering in the future.
Sam Lantinga <slouken@libsdl.org>
parents:
5145
diff
changeset
|
586 |
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
|
587 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
|
588 |
066384910f50
iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents:
2884
diff
changeset
|
589 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
|
590 (GLfloat) renderer->g * inv255f, |
066384910f50
iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents:
2884
diff
changeset
|
591 (GLfloat) renderer->b * inv255f, |
066384910f50
iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents:
2884
diff
changeset
|
592 (GLfloat) renderer->a * inv255f); |
066384910f50
iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents:
2884
diff
changeset
|
593 |
3547
8b18669c2663
Fixed building on iPhone
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
594 vertices = SDL_stack_alloc(GLshort, count*2); |
8b18669c2663
Fixed building on iPhone
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
595 for (i = 0; i < count; ++i) { |
8b18669c2663
Fixed building on iPhone
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
596 vertices[2*i+0] = (GLshort)points[i].x; |
8b18669c2663
Fixed building on iPhone
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
597 vertices[2*i+1] = (GLshort)points[i].y; |
8b18669c2663
Fixed building on iPhone
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
598 } |
8b18669c2663
Fixed building on iPhone
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
599 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
|
600 data->glDrawArrays(GL_POINTS, 0, count); |
3547
8b18669c2663
Fixed building on iPhone
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
601 SDL_stack_free(vertices); |
2964 | 602 |
2936
066384910f50
iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents:
2884
diff
changeset
|
603 return 0; |
066384910f50
iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents:
2884
diff
changeset
|
604 } |
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 static int |
3641 | 607 GLES_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points, |
608 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
|
609 { |
2936
066384910f50
iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents:
2884
diff
changeset
|
610 GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; |
3547
8b18669c2663
Fixed building on iPhone
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
611 int i; |
8b18669c2663
Fixed building on iPhone
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
612 GLshort *vertices; |
2753 | 613 |
5150
ad50b3db78bd
The rendering functions take a context so it's clear what window they're drawing to. This also potentially opens to the door to multi-threaded rendering in the future.
Sam Lantinga <slouken@libsdl.org>
parents:
5145
diff
changeset
|
614 GLES_ActivateRenderer(renderer); |
ad50b3db78bd
The rendering functions take a context so it's clear what window they're drawing to. This also potentially opens to the door to multi-threaded rendering in the future.
Sam Lantinga <slouken@libsdl.org>
parents:
5145
diff
changeset
|
615 |
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
|
616 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
|
617 |
066384910f50
iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents:
2884
diff
changeset
|
618 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
|
619 (GLfloat) renderer->g * inv255f, |
066384910f50
iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents:
2884
diff
changeset
|
620 (GLfloat) renderer->b * inv255f, |
066384910f50
iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents:
2884
diff
changeset
|
621 (GLfloat) renderer->a * inv255f); |
066384910f50
iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents:
2884
diff
changeset
|
622 |
3547
8b18669c2663
Fixed building on iPhone
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
623 vertices = SDL_stack_alloc(GLshort, count*2); |
8b18669c2663
Fixed building on iPhone
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
624 for (i = 0; i < count; ++i) { |
8b18669c2663
Fixed building on iPhone
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
625 vertices[2*i+0] = (GLshort)points[i].x; |
8b18669c2663
Fixed building on iPhone
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
626 vertices[2*i+1] = (GLshort)points[i].y; |
8b18669c2663
Fixed building on iPhone
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
627 } |
8b18669c2663
Fixed building on iPhone
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
628 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
|
629 if (count > 2 && |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
630 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
|
631 /* 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
|
632 --count; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
633 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
|
634 } else { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
635 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
|
636 } |
3547
8b18669c2663
Fixed building on iPhone
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
637 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
|
638 |
2936
066384910f50
iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents:
2884
diff
changeset
|
639 return 0; |
066384910f50
iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents:
2884
diff
changeset
|
640 } |
066384910f50
iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents:
2884
diff
changeset
|
641 |
066384910f50
iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents:
2884
diff
changeset
|
642 static int |
3641 | 643 GLES_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects, |
644 int count) | |
2936
066384910f50
iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents:
2884
diff
changeset
|
645 { |
2753 | 646 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
|
647 int i; |
2753 | 648 |
5150
ad50b3db78bd
The rendering functions take a context so it's clear what window they're drawing to. This also potentially opens to the door to multi-threaded rendering in the future.
Sam Lantinga <slouken@libsdl.org>
parents:
5145
diff
changeset
|
649 GLES_ActivateRenderer(renderer); |
ad50b3db78bd
The rendering functions take a context so it's clear what window they're drawing to. This also potentially opens to the door to multi-threaded rendering in the future.
Sam Lantinga <slouken@libsdl.org>
parents:
5145
diff
changeset
|
650 |
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
|
651 GLES_SetBlendMode(data, renderer->blendMode); |
2753 | 652 |
2936
066384910f50
iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents:
2884
diff
changeset
|
653 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
|
654 (GLfloat) renderer->g * inv255f, |
066384910f50
iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents:
2884
diff
changeset
|
655 (GLfloat) renderer->b * inv255f, |
066384910f50
iPhone build compiles again (drawing routines need to be implemented)
Sam Lantinga <slouken@libsdl.org>
parents:
2884
diff
changeset
|
656 (GLfloat) renderer->a * inv255f); |
2753 | 657 |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
658 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
|
659 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
|
660 GLshort minx = rect->x; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
661 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
|
662 GLshort miny = rect->y; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
663 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
|
664 GLshort vertices[8]; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
665 vertices[0] = minx; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
666 vertices[1] = miny; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
667 vertices[2] = maxx; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
668 vertices[3] = miny; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
669 vertices[4] = minx; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
670 vertices[5] = maxy; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
671 vertices[6] = maxx; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
672 vertices[7] = maxy; |
2964 | 673 |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
3520
diff
changeset
|
674 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
|
675 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
|
676 } |
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
|
677 |
2753 | 678 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
|
679 } |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
680 |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
681 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
|
682 GLES_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, |
2753 | 683 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
|
684 { |
2753 | 685 |
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
|
686 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
|
687 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
|
688 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
|
689 GLfloat minu, maxu, minv, maxv; |
2753 | 690 int i; |
691 void *temp_buffer; /* used for reformatting dirty rect pixels */ | |
692 void *temp_ptr; | |
693 | |
5150
ad50b3db78bd
The rendering functions take a context so it's clear what window they're drawing to. This also potentially opens to the door to multi-threaded rendering in the future.
Sam Lantinga <slouken@libsdl.org>
parents:
5145
diff
changeset
|
694 GLES_ActivateRenderer(renderer); |
ad50b3db78bd
The rendering functions take a context so it's clear what window they're drawing to. This also potentially opens to the door to multi-threaded rendering in the future.
Sam Lantinga <slouken@libsdl.org>
parents:
5145
diff
changeset
|
695 |
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
|
696 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
|
697 |
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
|
698 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
|
699 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
|
700 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
|
701 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
|
702 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
|
703 |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
704 SetupTextureUpdate(data, texture, pitch); |
2753 | 705 |
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
|
706 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
|
707 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
|
708 SDL_Rect *rect = &dirty->rect; |
2753 | 709 pixels = |
710 (void *) ((Uint8 *) texturedata->pixels + rect->y * pitch + | |
711 rect->x * bpp); | |
712 /* There is no GL_UNPACK_ROW_LENGTH in OpenGLES | |
713 we must do this reformatting ourselves(!) | |
714 | |
715 maybe it'd be a good idea to keep a temp buffer around | |
716 for this purpose rather than allocating it each time | |
717 */ | |
4525
3abf0b9cafad
pelya 2010-07-12 03:53:48 PDT
Sam Lantinga <slouken@libsdl.org>
parents:
3697
diff
changeset
|
718 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
|
719 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
|
720 } else { |
3abf0b9cafad
pelya 2010-07-12 03:53:48 PDT
Sam Lantinga <slouken@libsdl.org>
parents:
3697
diff
changeset
|
721 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
|
722 temp_ptr = temp_buffer; |
3abf0b9cafad
pelya 2010-07-12 03:53:48 PDT
Sam Lantinga <slouken@libsdl.org>
parents:
3697
diff
changeset
|
723 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
|
724 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
|
725 temp_ptr += rect->w * bpp; |
3abf0b9cafad
pelya 2010-07-12 03:53:48 PDT
Sam Lantinga <slouken@libsdl.org>
parents:
3697
diff
changeset
|
726 pixels += pitch; |
3abf0b9cafad
pelya 2010-07-12 03:53:48 PDT
Sam Lantinga <slouken@libsdl.org>
parents:
3697
diff
changeset
|
727 } |
2753 | 728 } |
729 | |
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
|
730 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
|
731 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
|
732 texturedata->formattype, temp_buffer); |
2753 | 733 |
4525
3abf0b9cafad
pelya 2010-07-12 03:53:48 PDT
Sam Lantinga <slouken@libsdl.org>
parents:
3697
diff
changeset
|
734 if( temp_buffer != pixels ) { |
3abf0b9cafad
pelya 2010-07-12 03:53:48 PDT
Sam Lantinga <slouken@libsdl.org>
parents:
3697
diff
changeset
|
735 SDL_free(temp_buffer); |
3abf0b9cafad
pelya 2010-07-12 03:53:48 PDT
Sam Lantinga <slouken@libsdl.org>
parents:
3697
diff
changeset
|
736 } |
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
|
737 } |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.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 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
|
739 } |
2753 | 740 |
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
|
741 data->glBindTexture(texturedata->type, texturedata->texture); |
2753 | 742 |
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
|
743 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
|
744 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
|
745 (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
|
746 (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
|
747 (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
|
748 } 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
|
749 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
|
750 } |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.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 |
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
|
752 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
|
753 |
2753 | 754 if (data->GL_OES_draw_texture_supported && data->useDrawTexture) { |
755 /* 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
|
756 SDL_Window *window = renderer->window; |
2753 | 757 GLint cropRect[4]; |
758 cropRect[0] = srcrect->x; | |
759 cropRect[1] = srcrect->y + srcrect->h; | |
760 cropRect[2] = srcrect->w; | |
761 cropRect[3] = -srcrect->h; | |
762 data->glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, | |
763 cropRect); | |
764 data->glDrawTexiOES(dstrect->x, window->h - dstrect->y - dstrect->h, | |
765 0, dstrect->w, dstrect->h); | |
766 } else { | |
767 | |
768 minx = dstrect->x; | |
769 miny = dstrect->y; | |
770 maxx = dstrect->x + dstrect->w; | |
771 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
|
772 |
2753 | 773 minu = (GLfloat) srcrect->x / texture->w; |
774 minu *= texturedata->texw; | |
775 maxu = (GLfloat) (srcrect->x + srcrect->w) / texture->w; | |
776 maxu *= texturedata->texw; | |
777 minv = (GLfloat) srcrect->y / texture->h; | |
778 minv *= texturedata->texh; | |
779 maxv = (GLfloat) (srcrect->y + srcrect->h) / texture->h; | |
780 maxv *= texturedata->texh; | |
781 | |
782 GLshort vertices[8]; | |
783 GLfloat texCoords[8]; | |
784 | |
785 vertices[0] = minx; | |
786 vertices[1] = miny; | |
787 vertices[2] = maxx; | |
788 vertices[3] = miny; | |
789 vertices[4] = minx; | |
790 vertices[5] = maxy; | |
791 vertices[6] = maxx; | |
792 vertices[7] = maxy; | |
793 | |
794 texCoords[0] = minu; | |
795 texCoords[1] = minv; | |
796 texCoords[2] = maxu; | |
797 texCoords[3] = minv; | |
798 texCoords[4] = minu; | |
799 texCoords[5] = maxv; | |
800 texCoords[6] = maxu; | |
801 texCoords[7] = maxv; | |
802 | |
803 data->glVertexPointer(2, GL_SHORT, 0, vertices); | |
804 data->glTexCoordPointer(2, GL_FLOAT, 0, texCoords); | |
805 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
|
806 } |
2753 | 807 |
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
|
808 data->glDisable(GL_TEXTURE_2D); |
2753 | 809 |
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
|
810 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
|
811 } |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
812 |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
813 static void |
3139 | 814 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
|
815 { |
5150
ad50b3db78bd
The rendering functions take a context so it's clear what window they're drawing to. This also potentially opens to the door to multi-threaded rendering in the future.
Sam Lantinga <slouken@libsdl.org>
parents:
5145
diff
changeset
|
816 GLES_ActivateRenderer(renderer); |
ad50b3db78bd
The rendering functions take a context so it's clear what window they're drawing to. This also potentially opens to the door to multi-threaded rendering in the future.
Sam Lantinga <slouken@libsdl.org>
parents:
5145
diff
changeset
|
817 |
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
|
818 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
|
819 } |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.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 |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
821 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
|
822 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
|
823 { |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
824 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
|
825 |
5150
ad50b3db78bd
The rendering functions take a context so it's clear what window they're drawing to. This also potentially opens to the door to multi-threaded rendering in the future.
Sam Lantinga <slouken@libsdl.org>
parents:
5145
diff
changeset
|
826 GLES_ActivateRenderer(renderer); |
ad50b3db78bd
The rendering functions take a context so it's clear what window they're drawing to. This also potentially opens to the door to multi-threaded rendering in the future.
Sam Lantinga <slouken@libsdl.org>
parents:
5145
diff
changeset
|
827 |
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
|
828 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
|
829 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
|
830 } |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
831 if (data->texture) { |
2753 | 832 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
|
833 } |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
834 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
|
835 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
|
836 } |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
837 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
|
838 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
|
839 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
|
840 } |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
841 |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
842 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
|
843 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
|
844 { |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
845 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
|
846 |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
847 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
|
848 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
|
849 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
|
850 } |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
851 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
|
852 } |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
853 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
|
854 } |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.c and SDL_renderer_gl.h, except they use OpenGL ES 1.1 for rendering.
Holmes Futrell <hfutrell@umail.ucsb.edu>
parents:
diff
changeset
|
855 |
3099
82e60908fab1
Date: Mon, 23 Mar 2009 09:17:24 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
2964
diff
changeset
|
856 #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
|
857 |
68862734a5fd
These files are similar in purpose and structure as SDL_renderer_gl.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 /* vi: set ts=4 sw=4 expandtab: */ |