author | Sam Lantinga <slouken@libsdl.org> |
Mon, 31 Dec 2012 14:14:01 -0800 | |
changeset 6791 | c19c5232439d |
parent 6522 | edacce9402fb |
child 6817 | 93103b719488 |
permissions | -rw-r--r-- |
3190
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 |
/* |
5535
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
2 |
Simple DirectMedia Layer |
6138 | 3 |
Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org> |
3190
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4 |
|
5535
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
5 |
This software is provided 'as-is', without any express or implied |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
6 |
warranty. In no event will the authors be held liable for any damages |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
7 |
arising from the use of this software. |
3190
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
8 |
|
5535
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
9 |
Permission is granted to anyone to use this software for any purpose, |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
10 |
including commercial applications, and to alter it and redistribute it |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
11 |
freely, subject to the following restrictions: |
3190
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 |
|
5535
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
13 |
1. The origin of this software must not be misrepresented; you must not |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
14 |
claim that you wrote the original software. If you use this software |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
15 |
in a product, an acknowledgment in the product documentation would be |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
16 |
appreciated but is not required. |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
17 |
2. Altered source versions must be plainly marked as such, and must not be |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
18 |
misrepresented as being the original software. |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
19 |
3. This notice may not be removed or altered from any source distribution. |
3190
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
20 |
*/ |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
21 |
#include "SDL_config.h" |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
22 |
|
6044
35448a5ea044
Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents:
5535
diff
changeset
|
23 |
#if SDL_VIDEO_DRIVER_X11 && SDL_VIDEO_OPENGL_ES |
3190
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
24 |
|
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
25 |
#include "SDL_x11video.h" |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
26 |
#include "SDL_x11opengles.h" |
6370
93187f7f7d5d
Improved simultaneous support for OpenGL and OpenGL ES
Sam Lantinga <slouken@libsdl.org>
parents:
6368
diff
changeset
|
27 |
#include "SDL_x11opengl.h" |
3190
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
28 |
|
6190
519380462400
X11 OpenGL ES minor corrections
Sam Lantinga <slouken@libsdl.org>
parents:
6188
diff
changeset
|
29 |
#define DEFAULT_EGL "libEGL.so" |
519380462400
X11 OpenGL ES minor corrections
Sam Lantinga <slouken@libsdl.org>
parents:
6188
diff
changeset
|
30 |
#define DEFAULT_OGL_ES2 "libGLESv2.so" |
519380462400
X11 OpenGL ES minor corrections
Sam Lantinga <slouken@libsdl.org>
parents:
6188
diff
changeset
|
31 |
#define DEFAULT_OGL_ES_PVR "libGLES_CM.so" |
519380462400
X11 OpenGL ES minor corrections
Sam Lantinga <slouken@libsdl.org>
parents:
6188
diff
changeset
|
32 |
#define DEFAULT_OGL_ES "libGLESv1_CM.so" |
3190
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
33 |
|
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
34 |
#define LOAD_FUNC(NAME) \ |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
35 |
*((void**)&_this->gles_data->NAME) = dlsym(handle, #NAME); \ |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
36 |
if (!_this->gles_data->NAME) \ |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
37 |
{ \ |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
38 |
SDL_SetError("Could not retrieve EGL function " #NAME); \ |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
39 |
return -1; \ |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
40 |
} |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
41 |
|
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
42 |
/* GLES implementation of SDL OpenGL support */ |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
43 |
|
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
44 |
void * |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
45 |
X11_GLES_GetProcAddress(_THIS, const char *proc) |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
46 |
{ |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
47 |
static char procname[1024]; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
48 |
void *handle; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
49 |
void *retval; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
50 |
|
6188
e82023802002
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Sam Lantinga <slouken@libsdl.org>
parents:
6138
diff
changeset
|
51 |
handle = _this->gles_data->egl_dll_handle; |
3190
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
52 |
if (_this->gles_data->eglGetProcAddress) { |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
53 |
retval = _this->gles_data->eglGetProcAddress(proc); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
54 |
if (retval) { |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
55 |
return retval; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
56 |
} |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
57 |
} |
6188
e82023802002
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Sam Lantinga <slouken@libsdl.org>
parents:
6138
diff
changeset
|
58 |
|
e82023802002
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Sam Lantinga <slouken@libsdl.org>
parents:
6138
diff
changeset
|
59 |
handle = _this->gl_config.dll_handle; |
3190
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
60 |
#if defined(__OpenBSD__) && !defined(__ELF__) |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
61 |
#undef dlsym(x,y); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
62 |
#endif |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
63 |
retval = dlsym(handle, proc); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
64 |
if (!retval && strlen(proc) <= 1022) { |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
65 |
procname[0] = '_'; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
66 |
strcpy(procname + 1, proc); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
67 |
retval = dlsym(handle, procname); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
68 |
} |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
69 |
return retval; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
70 |
} |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
71 |
|
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
72 |
void |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
73 |
X11_GLES_UnloadLibrary(_THIS) |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
74 |
{ |
6370
93187f7f7d5d
Improved simultaneous support for OpenGL and OpenGL ES
Sam Lantinga <slouken@libsdl.org>
parents:
6368
diff
changeset
|
75 |
if ((_this->gles_data) && (_this->gl_config.driver_loaded)) { |
3190
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
76 |
_this->gles_data->eglTerminate(_this->gles_data->egl_display); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
77 |
|
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
78 |
dlclose(_this->gl_config.dll_handle); |
6188
e82023802002
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Sam Lantinga <slouken@libsdl.org>
parents:
6138
diff
changeset
|
79 |
dlclose(_this->gles_data->egl_dll_handle); |
3190
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
80 |
|
6370
93187f7f7d5d
Improved simultaneous support for OpenGL and OpenGL ES
Sam Lantinga <slouken@libsdl.org>
parents:
6368
diff
changeset
|
81 |
SDL_free(_this->gles_data); |
93187f7f7d5d
Improved simultaneous support for OpenGL and OpenGL ES
Sam Lantinga <slouken@libsdl.org>
parents:
6368
diff
changeset
|
82 |
_this->gles_data = NULL; |
3190
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
83 |
|
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
84 |
_this->gl_config.dll_handle = NULL; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
85 |
_this->gl_config.driver_loaded = 0; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
86 |
} |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
87 |
} |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
88 |
|
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
89 |
int |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
90 |
X11_GLES_LoadLibrary(_THIS, const char *path) |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
91 |
{ |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
92 |
void *handle; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
93 |
int dlopen_flags; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
94 |
|
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
95 |
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
96 |
|
6370
93187f7f7d5d
Improved simultaneous support for OpenGL and OpenGL ES
Sam Lantinga <slouken@libsdl.org>
parents:
6368
diff
changeset
|
97 |
if (_this->gles_data) { |
3190
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
98 |
SDL_SetError("OpenGL ES context already created"); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
99 |
return -1; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
100 |
} |
6370
93187f7f7d5d
Improved simultaneous support for OpenGL and OpenGL ES
Sam Lantinga <slouken@libsdl.org>
parents:
6368
diff
changeset
|
101 |
|
93187f7f7d5d
Improved simultaneous support for OpenGL and OpenGL ES
Sam Lantinga <slouken@libsdl.org>
parents:
6368
diff
changeset
|
102 |
/* If SDL_GL_CONTEXT_EGL has been changed to 0, switch over to X11_GL functions */ |
93187f7f7d5d
Improved simultaneous support for OpenGL and OpenGL ES
Sam Lantinga <slouken@libsdl.org>
parents:
6368
diff
changeset
|
103 |
if (_this->gl_config.use_egl == 0) { |
6373
494e0436525f
More OpenGL ES fixes from Scott Percival
Sam Lantinga <slouken@libsdl.org>
parents:
6370
diff
changeset
|
104 |
#if SDL_VIDEO_OPENGL_GLX |
6370
93187f7f7d5d
Improved simultaneous support for OpenGL and OpenGL ES
Sam Lantinga <slouken@libsdl.org>
parents:
6368
diff
changeset
|
105 |
_this->GL_LoadLibrary = X11_GL_LoadLibrary; |
93187f7f7d5d
Improved simultaneous support for OpenGL and OpenGL ES
Sam Lantinga <slouken@libsdl.org>
parents:
6368
diff
changeset
|
106 |
_this->GL_GetProcAddress = X11_GL_GetProcAddress; |
93187f7f7d5d
Improved simultaneous support for OpenGL and OpenGL ES
Sam Lantinga <slouken@libsdl.org>
parents:
6368
diff
changeset
|
107 |
_this->GL_UnloadLibrary = X11_GL_UnloadLibrary; |
93187f7f7d5d
Improved simultaneous support for OpenGL and OpenGL ES
Sam Lantinga <slouken@libsdl.org>
parents:
6368
diff
changeset
|
108 |
_this->GL_CreateContext = X11_GL_CreateContext; |
93187f7f7d5d
Improved simultaneous support for OpenGL and OpenGL ES
Sam Lantinga <slouken@libsdl.org>
parents:
6368
diff
changeset
|
109 |
_this->GL_MakeCurrent = X11_GL_MakeCurrent; |
93187f7f7d5d
Improved simultaneous support for OpenGL and OpenGL ES
Sam Lantinga <slouken@libsdl.org>
parents:
6368
diff
changeset
|
110 |
_this->GL_SetSwapInterval = X11_GL_SetSwapInterval; |
93187f7f7d5d
Improved simultaneous support for OpenGL and OpenGL ES
Sam Lantinga <slouken@libsdl.org>
parents:
6368
diff
changeset
|
111 |
_this->GL_GetSwapInterval = X11_GL_GetSwapInterval; |
93187f7f7d5d
Improved simultaneous support for OpenGL and OpenGL ES
Sam Lantinga <slouken@libsdl.org>
parents:
6368
diff
changeset
|
112 |
_this->GL_SwapWindow = X11_GL_SwapWindow; |
93187f7f7d5d
Improved simultaneous support for OpenGL and OpenGL ES
Sam Lantinga <slouken@libsdl.org>
parents:
6368
diff
changeset
|
113 |
_this->GL_DeleteContext = X11_GL_DeleteContext; |
93187f7f7d5d
Improved simultaneous support for OpenGL and OpenGL ES
Sam Lantinga <slouken@libsdl.org>
parents:
6368
diff
changeset
|
114 |
return X11_GL_LoadLibrary(_this, path); |
6373
494e0436525f
More OpenGL ES fixes from Scott Percival
Sam Lantinga <slouken@libsdl.org>
parents:
6370
diff
changeset
|
115 |
#else |
494e0436525f
More OpenGL ES fixes from Scott Percival
Sam Lantinga <slouken@libsdl.org>
parents:
6370
diff
changeset
|
116 |
SDL_SetError("SDL not configured with OpenGL/GLX support"); |
494e0436525f
More OpenGL ES fixes from Scott Percival
Sam Lantinga <slouken@libsdl.org>
parents:
6370
diff
changeset
|
117 |
return -1; |
494e0436525f
More OpenGL ES fixes from Scott Percival
Sam Lantinga <slouken@libsdl.org>
parents:
6370
diff
changeset
|
118 |
#endif |
6370
93187f7f7d5d
Improved simultaneous support for OpenGL and OpenGL ES
Sam Lantinga <slouken@libsdl.org>
parents:
6368
diff
changeset
|
119 |
} |
93187f7f7d5d
Improved simultaneous support for OpenGL and OpenGL ES
Sam Lantinga <slouken@libsdl.org>
parents:
6368
diff
changeset
|
120 |
|
3190
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
121 |
#ifdef RTLD_GLOBAL |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
122 |
dlopen_flags = RTLD_LAZY | RTLD_GLOBAL; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
123 |
#else |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
124 |
dlopen_flags = RTLD_LAZY; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
125 |
#endif |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
126 |
handle = dlopen(path, dlopen_flags); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
127 |
/* Catch the case where the application isn't linked with EGL */ |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
128 |
if ((dlsym(handle, "eglChooseConfig") == NULL) && (path == NULL)) { |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
129 |
|
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
130 |
dlclose(handle); |
6368
fcbbd0e2da5e
Rename envvar to overwrite X11 EGL library name.
Sam Lantinga <slouken@libsdl.org>
parents:
6190
diff
changeset
|
131 |
path = getenv("SDL_VIDEO_EGL_DRIVER"); |
3190
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
132 |
if (path == NULL) { |
6188
e82023802002
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Sam Lantinga <slouken@libsdl.org>
parents:
6138
diff
changeset
|
133 |
path = DEFAULT_EGL; |
3190
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
134 |
} |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
135 |
handle = dlopen(path, dlopen_flags); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
136 |
} |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
137 |
|
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
138 |
if (handle == NULL) { |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
139 |
SDL_SetError("Could not load OpenGL ES/EGL library"); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
140 |
return -1; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
141 |
} |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
142 |
|
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
143 |
/* Unload the old driver and reset the pointers */ |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
144 |
X11_GLES_UnloadLibrary(_this); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
145 |
|
6370
93187f7f7d5d
Improved simultaneous support for OpenGL and OpenGL ES
Sam Lantinga <slouken@libsdl.org>
parents:
6368
diff
changeset
|
146 |
_this->gles_data = (struct SDL_PrivateGLESData *) SDL_calloc(1, sizeof(SDL_PrivateGLESData)); |
93187f7f7d5d
Improved simultaneous support for OpenGL and OpenGL ES
Sam Lantinga <slouken@libsdl.org>
parents:
6368
diff
changeset
|
147 |
if (!_this->gles_data) { |
93187f7f7d5d
Improved simultaneous support for OpenGL and OpenGL ES
Sam Lantinga <slouken@libsdl.org>
parents:
6368
diff
changeset
|
148 |
SDL_OutOfMemory(); |
93187f7f7d5d
Improved simultaneous support for OpenGL and OpenGL ES
Sam Lantinga <slouken@libsdl.org>
parents:
6368
diff
changeset
|
149 |
return -1; |
93187f7f7d5d
Improved simultaneous support for OpenGL and OpenGL ES
Sam Lantinga <slouken@libsdl.org>
parents:
6368
diff
changeset
|
150 |
} |
93187f7f7d5d
Improved simultaneous support for OpenGL and OpenGL ES
Sam Lantinga <slouken@libsdl.org>
parents:
6368
diff
changeset
|
151 |
|
3190
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
152 |
/* Load new function pointers */ |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
153 |
LOAD_FUNC(eglGetDisplay); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
154 |
LOAD_FUNC(eglInitialize); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
155 |
LOAD_FUNC(eglTerminate); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
156 |
LOAD_FUNC(eglGetProcAddress); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
157 |
LOAD_FUNC(eglChooseConfig); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
158 |
LOAD_FUNC(eglGetConfigAttrib); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
159 |
LOAD_FUNC(eglCreateContext); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
160 |
LOAD_FUNC(eglDestroyContext); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
161 |
LOAD_FUNC(eglCreateWindowSurface); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
162 |
LOAD_FUNC(eglDestroySurface); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
163 |
LOAD_FUNC(eglMakeCurrent); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
164 |
LOAD_FUNC(eglSwapBuffers); |
6190
519380462400
X11 OpenGL ES minor corrections
Sam Lantinga <slouken@libsdl.org>
parents:
6188
diff
changeset
|
165 |
LOAD_FUNC(eglSwapInterval); |
3190
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
166 |
|
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
167 |
_this->gles_data->egl_display = |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
168 |
_this->gles_data->eglGetDisplay((NativeDisplayType) data->display); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
169 |
|
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
170 |
if (!_this->gles_data->egl_display) { |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
171 |
SDL_SetError("Could not get EGL display"); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
172 |
return -1; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
173 |
} |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
174 |
|
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
175 |
if (_this->gles_data-> |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
176 |
eglInitialize(_this->gles_data->egl_display, NULL, |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
177 |
NULL) != EGL_TRUE) { |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
178 |
SDL_SetError("Could not initialize EGL"); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
179 |
return -1; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
180 |
} |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
181 |
|
6188
e82023802002
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Sam Lantinga <slouken@libsdl.org>
parents:
6138
diff
changeset
|
182 |
_this->gles_data->egl_dll_handle = handle; |
e82023802002
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Sam Lantinga <slouken@libsdl.org>
parents:
6138
diff
changeset
|
183 |
|
e82023802002
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Sam Lantinga <slouken@libsdl.org>
parents:
6138
diff
changeset
|
184 |
path = getenv("SDL_VIDEO_GL_DRIVER"); |
e82023802002
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Sam Lantinga <slouken@libsdl.org>
parents:
6138
diff
changeset
|
185 |
handle = dlopen(path, dlopen_flags); |
e82023802002
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Sam Lantinga <slouken@libsdl.org>
parents:
6138
diff
changeset
|
186 |
if ((path == NULL) | (handle == NULL)) { |
e82023802002
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Sam Lantinga <slouken@libsdl.org>
parents:
6138
diff
changeset
|
187 |
if (_this->gl_config.major_version > 1) { |
e82023802002
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Sam Lantinga <slouken@libsdl.org>
parents:
6138
diff
changeset
|
188 |
path = DEFAULT_OGL_ES2; |
e82023802002
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Sam Lantinga <slouken@libsdl.org>
parents:
6138
diff
changeset
|
189 |
handle = dlopen(path, dlopen_flags); |
e82023802002
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Sam Lantinga <slouken@libsdl.org>
parents:
6138
diff
changeset
|
190 |
} else { |
e82023802002
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Sam Lantinga <slouken@libsdl.org>
parents:
6138
diff
changeset
|
191 |
path = DEFAULT_OGL_ES; |
e82023802002
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Sam Lantinga <slouken@libsdl.org>
parents:
6138
diff
changeset
|
192 |
handle = dlopen(path, dlopen_flags); |
e82023802002
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Sam Lantinga <slouken@libsdl.org>
parents:
6138
diff
changeset
|
193 |
if (handle == NULL) { |
e82023802002
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Sam Lantinga <slouken@libsdl.org>
parents:
6138
diff
changeset
|
194 |
path = DEFAULT_OGL_ES_PVR; |
e82023802002
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Sam Lantinga <slouken@libsdl.org>
parents:
6138
diff
changeset
|
195 |
handle = dlopen(path, dlopen_flags); |
e82023802002
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Sam Lantinga <slouken@libsdl.org>
parents:
6138
diff
changeset
|
196 |
} |
e82023802002
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Sam Lantinga <slouken@libsdl.org>
parents:
6138
diff
changeset
|
197 |
} |
e82023802002
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Sam Lantinga <slouken@libsdl.org>
parents:
6138
diff
changeset
|
198 |
} |
e82023802002
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Sam Lantinga <slouken@libsdl.org>
parents:
6138
diff
changeset
|
199 |
|
e82023802002
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Sam Lantinga <slouken@libsdl.org>
parents:
6138
diff
changeset
|
200 |
if (handle == NULL) { |
e82023802002
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Sam Lantinga <slouken@libsdl.org>
parents:
6138
diff
changeset
|
201 |
SDL_SetError("Could not initialize OpenGL ES library"); |
e82023802002
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Sam Lantinga <slouken@libsdl.org>
parents:
6138
diff
changeset
|
202 |
return -1; |
e82023802002
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Sam Lantinga <slouken@libsdl.org>
parents:
6138
diff
changeset
|
203 |
} |
e82023802002
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Sam Lantinga <slouken@libsdl.org>
parents:
6138
diff
changeset
|
204 |
|
3190
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
205 |
_this->gl_config.dll_handle = handle; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
206 |
_this->gl_config.driver_loaded = 1; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
207 |
|
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
208 |
if (path) { |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
209 |
strncpy(_this->gl_config.driver_path, path, |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
210 |
sizeof(_this->gl_config.driver_path) - 1); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
211 |
} else { |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
212 |
strcpy(_this->gl_config.driver_path, ""); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
213 |
} |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
214 |
return 0; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
215 |
} |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
216 |
|
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
217 |
XVisualInfo * |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
218 |
X11_GLES_GetVisual(_THIS, Display * display, int screen) |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
219 |
{ |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
220 |
/* 64 seems nice. */ |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
221 |
EGLint attribs[64]; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
222 |
EGLint found_configs = 0; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
223 |
VisualID visual_id; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
224 |
int i; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
225 |
|
6370
93187f7f7d5d
Improved simultaneous support for OpenGL and OpenGL ES
Sam Lantinga <slouken@libsdl.org>
parents:
6368
diff
changeset
|
226 |
if (!_this->gles_data) { |
93187f7f7d5d
Improved simultaneous support for OpenGL and OpenGL ES
Sam Lantinga <slouken@libsdl.org>
parents:
6368
diff
changeset
|
227 |
/* The EGL library wasn't loaded, SDL_GetError() should have info */ |
93187f7f7d5d
Improved simultaneous support for OpenGL and OpenGL ES
Sam Lantinga <slouken@libsdl.org>
parents:
6368
diff
changeset
|
228 |
return NULL; |
3190
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
229 |
} |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
230 |
|
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
231 |
i = 0; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
232 |
attribs[i++] = EGL_RED_SIZE; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
233 |
attribs[i++] = _this->gl_config.red_size; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
234 |
attribs[i++] = EGL_GREEN_SIZE; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
235 |
attribs[i++] = _this->gl_config.green_size; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
236 |
attribs[i++] = EGL_BLUE_SIZE; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
237 |
attribs[i++] = _this->gl_config.blue_size; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
238 |
|
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
239 |
if (_this->gl_config.alpha_size) { |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
240 |
attribs[i++] = EGL_ALPHA_SIZE; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
241 |
attribs[i++] = _this->gl_config.alpha_size; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
242 |
} |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
243 |
|
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
244 |
if (_this->gl_config.buffer_size) { |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
245 |
attribs[i++] = EGL_BUFFER_SIZE; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
246 |
attribs[i++] = _this->gl_config.buffer_size; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
247 |
} |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
248 |
|
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
249 |
attribs[i++] = EGL_DEPTH_SIZE; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
250 |
attribs[i++] = _this->gl_config.depth_size; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
251 |
|
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
252 |
if (_this->gl_config.stencil_size) { |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
253 |
attribs[i++] = EGL_STENCIL_SIZE; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
254 |
attribs[i++] = _this->gl_config.stencil_size; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
255 |
} |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
256 |
|
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
257 |
if (_this->gl_config.multisamplebuffers) { |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
258 |
attribs[i++] = EGL_SAMPLE_BUFFERS; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
259 |
attribs[i++] = _this->gl_config.multisamplebuffers; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
260 |
} |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
261 |
|
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
262 |
if (_this->gl_config.multisamplesamples) { |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
263 |
attribs[i++] = EGL_SAMPLES; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
264 |
attribs[i++] = _this->gl_config.multisamplesamples; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
265 |
} |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
266 |
|
6188
e82023802002
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Sam Lantinga <slouken@libsdl.org>
parents:
6138
diff
changeset
|
267 |
attribs[i++] = EGL_RENDERABLE_TYPE; |
e82023802002
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Sam Lantinga <slouken@libsdl.org>
parents:
6138
diff
changeset
|
268 |
if (_this->gl_config.major_version == 2) { |
e82023802002
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Sam Lantinga <slouken@libsdl.org>
parents:
6138
diff
changeset
|
269 |
attribs[i++] = EGL_OPENGL_ES2_BIT; |
e82023802002
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Sam Lantinga <slouken@libsdl.org>
parents:
6138
diff
changeset
|
270 |
} else { |
e82023802002
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Sam Lantinga <slouken@libsdl.org>
parents:
6138
diff
changeset
|
271 |
attribs[i++] = EGL_OPENGL_ES_BIT; |
e82023802002
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Sam Lantinga <slouken@libsdl.org>
parents:
6138
diff
changeset
|
272 |
} |
e82023802002
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Sam Lantinga <slouken@libsdl.org>
parents:
6138
diff
changeset
|
273 |
|
3190
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
274 |
attribs[i++] = EGL_NONE; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
275 |
|
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
276 |
if (_this->gles_data->eglChooseConfig(_this->gles_data->egl_display, |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
277 |
attribs, |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
278 |
&_this->gles_data->egl_config, 1, |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
279 |
&found_configs) == EGL_FALSE || |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
280 |
found_configs == 0) { |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
281 |
SDL_SetError("Couldn't find matching EGL config"); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
282 |
return NULL; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
283 |
} |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
284 |
|
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
285 |
if (_this->gles_data->eglGetConfigAttrib(_this->gles_data->egl_display, |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
286 |
_this->gles_data->egl_config, |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
287 |
EGL_NATIVE_VISUAL_ID, |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
288 |
(EGLint *) & visual_id) == |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
289 |
EGL_FALSE || !visual_id) { |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
290 |
/* Use the default visual when all else fails */ |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
291 |
XVisualInfo vi_in; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
292 |
int out_count; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
293 |
vi_in.screen = screen; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
294 |
|
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
295 |
_this->gles_data->egl_visualinfo = XGetVisualInfo(display, |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
296 |
VisualScreenMask, |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
297 |
&vi_in, &out_count); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
298 |
} else { |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
299 |
XVisualInfo vi_in; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
300 |
int out_count; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
301 |
|
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
302 |
vi_in.screen = screen; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
303 |
vi_in.visualid = visual_id; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
304 |
_this->gles_data->egl_visualinfo = XGetVisualInfo(display, |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
305 |
VisualScreenMask | |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
306 |
VisualIDMask, |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
307 |
&vi_in, &out_count); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
308 |
} |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
309 |
|
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
310 |
return _this->gles_data->egl_visualinfo; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
311 |
} |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
312 |
|
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
313 |
SDL_GLContext |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
314 |
X11_GLES_CreateContext(_THIS, SDL_Window * window) |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
315 |
{ |
6188
e82023802002
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Sam Lantinga <slouken@libsdl.org>
parents:
6138
diff
changeset
|
316 |
EGLint context_attrib_list[] = { |
e82023802002
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Sam Lantinga <slouken@libsdl.org>
parents:
6138
diff
changeset
|
317 |
EGL_CONTEXT_CLIENT_VERSION, |
e82023802002
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Sam Lantinga <slouken@libsdl.org>
parents:
6138
diff
changeset
|
318 |
1, |
e82023802002
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Sam Lantinga <slouken@libsdl.org>
parents:
6138
diff
changeset
|
319 |
EGL_NONE |
e82023802002
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Sam Lantinga <slouken@libsdl.org>
parents:
6138
diff
changeset
|
320 |
}; |
e82023802002
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Sam Lantinga <slouken@libsdl.org>
parents:
6138
diff
changeset
|
321 |
|
3190
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
322 |
SDL_WindowData *data = (SDL_WindowData *) window->driverdata; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
323 |
Display *display = data->videodata->display; |
6791
c19c5232439d
Fixed bug 1671 - add cast to fix build with strict GCC settings
Sam Lantinga <slouken@libsdl.org>
parents:
6522
diff
changeset
|
324 |
SDL_GLContext context = (SDL_GLContext)1; |
3190
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
325 |
|
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
326 |
XSync(display, False); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
327 |
|
6188
e82023802002
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Sam Lantinga <slouken@libsdl.org>
parents:
6138
diff
changeset
|
328 |
if (_this->gl_config.major_version) { |
e82023802002
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Sam Lantinga <slouken@libsdl.org>
parents:
6138
diff
changeset
|
329 |
context_attrib_list[1] = _this->gl_config.major_version; |
e82023802002
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Sam Lantinga <slouken@libsdl.org>
parents:
6138
diff
changeset
|
330 |
} |
3190
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
331 |
|
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
332 |
_this->gles_data->egl_context = |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
333 |
_this->gles_data->eglCreateContext(_this->gles_data->egl_display, |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
334 |
_this->gles_data->egl_config, |
6188
e82023802002
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Sam Lantinga <slouken@libsdl.org>
parents:
6138
diff
changeset
|
335 |
EGL_NO_CONTEXT, context_attrib_list); |
3190
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
336 |
XSync(display, False); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
337 |
|
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
338 |
if (_this->gles_data->egl_context == EGL_NO_CONTEXT) { |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
339 |
SDL_SetError("Could not create EGL context"); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
340 |
return NULL; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
341 |
} |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
342 |
|
6190
519380462400
X11 OpenGL ES minor corrections
Sam Lantinga <slouken@libsdl.org>
parents:
6188
diff
changeset
|
343 |
_this->gles_data->egl_swapinterval = 0; |
3190
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
344 |
|
6188
e82023802002
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Sam Lantinga <slouken@libsdl.org>
parents:
6138
diff
changeset
|
345 |
if (X11_GLES_MakeCurrent(_this, window, context) < 0) { |
e82023802002
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Sam Lantinga <slouken@libsdl.org>
parents:
6138
diff
changeset
|
346 |
X11_GLES_DeleteContext(_this, context); |
e82023802002
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Sam Lantinga <slouken@libsdl.org>
parents:
6138
diff
changeset
|
347 |
return NULL; |
e82023802002
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11
Sam Lantinga <slouken@libsdl.org>
parents:
6138
diff
changeset
|
348 |
} |
3190
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
349 |
|
6190
519380462400
X11 OpenGL ES minor corrections
Sam Lantinga <slouken@libsdl.org>
parents:
6188
diff
changeset
|
350 |
return context; |
3190
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
351 |
} |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
352 |
|
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
353 |
int |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
354 |
X11_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
355 |
{ |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
356 |
int retval; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
357 |
|
3218 | 358 |
// SDL_WindowData *data = (SDL_WindowData *) window->driverdata; |
359 |
// Display *display = data->videodata->display; |
|
3190
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
360 |
|
6522
edacce9402fb
The gl_data is optional for the driver, so don't early out of the context delete call if it doesn't exist.
Sam Lantinga <slouken@libsdl.org>
parents:
6373
diff
changeset
|
361 |
if (!_this->gles_data) { |
edacce9402fb
The gl_data is optional for the driver, so don't early out of the context delete call if it doesn't exist.
Sam Lantinga <slouken@libsdl.org>
parents:
6373
diff
changeset
|
362 |
SDL_SetError("OpenGL not initialized"); |
edacce9402fb
The gl_data is optional for the driver, so don't early out of the context delete call if it doesn't exist.
Sam Lantinga <slouken@libsdl.org>
parents:
6373
diff
changeset
|
363 |
return -1; |
edacce9402fb
The gl_data is optional for the driver, so don't early out of the context delete call if it doesn't exist.
Sam Lantinga <slouken@libsdl.org>
parents:
6373
diff
changeset
|
364 |
} |
edacce9402fb
The gl_data is optional for the driver, so don't early out of the context delete call if it doesn't exist.
Sam Lantinga <slouken@libsdl.org>
parents:
6373
diff
changeset
|
365 |
|
3190
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
366 |
retval = 1; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
367 |
if (!_this->gles_data->eglMakeCurrent(_this->gles_data->egl_display, |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
368 |
_this->gles_data->egl_surface, |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
369 |
_this->gles_data->egl_surface, |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
370 |
_this->gles_data->egl_context)) { |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
371 |
SDL_SetError("Unable to make EGL context current"); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
372 |
retval = -1; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
373 |
} |
3218 | 374 |
// XSync(display, False); |
3190
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
375 |
|
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
376 |
return (retval); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
377 |
} |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
378 |
|
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
379 |
int |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
380 |
X11_GLES_SetSwapInterval(_THIS, int interval) |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
381 |
{ |
6370
93187f7f7d5d
Improved simultaneous support for OpenGL and OpenGL ES
Sam Lantinga <slouken@libsdl.org>
parents:
6368
diff
changeset
|
382 |
if (_this->gles_data) { |
6190
519380462400
X11 OpenGL ES minor corrections
Sam Lantinga <slouken@libsdl.org>
parents:
6188
diff
changeset
|
383 |
SDL_SetError("OpenGL ES context not active"); |
519380462400
X11 OpenGL ES minor corrections
Sam Lantinga <slouken@libsdl.org>
parents:
6188
diff
changeset
|
384 |
return -1; |
519380462400
X11 OpenGL ES minor corrections
Sam Lantinga <slouken@libsdl.org>
parents:
6188
diff
changeset
|
385 |
} |
519380462400
X11 OpenGL ES minor corrections
Sam Lantinga <slouken@libsdl.org>
parents:
6188
diff
changeset
|
386 |
|
519380462400
X11 OpenGL ES minor corrections
Sam Lantinga <slouken@libsdl.org>
parents:
6188
diff
changeset
|
387 |
EGLBoolean status; |
519380462400
X11 OpenGL ES minor corrections
Sam Lantinga <slouken@libsdl.org>
parents:
6188
diff
changeset
|
388 |
status = _this->gles_data->eglSwapInterval(_this->gles_data->egl_display, interval); |
519380462400
X11 OpenGL ES minor corrections
Sam Lantinga <slouken@libsdl.org>
parents:
6188
diff
changeset
|
389 |
if (status == EGL_TRUE) { |
519380462400
X11 OpenGL ES minor corrections
Sam Lantinga <slouken@libsdl.org>
parents:
6188
diff
changeset
|
390 |
_this->gles_data->egl_swapinterval = interval; |
519380462400
X11 OpenGL ES minor corrections
Sam Lantinga <slouken@libsdl.org>
parents:
6188
diff
changeset
|
391 |
return 0; |
519380462400
X11 OpenGL ES minor corrections
Sam Lantinga <slouken@libsdl.org>
parents:
6188
diff
changeset
|
392 |
} |
519380462400
X11 OpenGL ES minor corrections
Sam Lantinga <slouken@libsdl.org>
parents:
6188
diff
changeset
|
393 |
|
519380462400
X11 OpenGL ES minor corrections
Sam Lantinga <slouken@libsdl.org>
parents:
6188
diff
changeset
|
394 |
SDL_SetError("Unable to set the EGL swap interval"); |
519380462400
X11 OpenGL ES minor corrections
Sam Lantinga <slouken@libsdl.org>
parents:
6188
diff
changeset
|
395 |
return -1; |
3190
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
396 |
} |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
397 |
|
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
398 |
int |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
399 |
X11_GLES_GetSwapInterval(_THIS) |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
400 |
{ |
6370
93187f7f7d5d
Improved simultaneous support for OpenGL and OpenGL ES
Sam Lantinga <slouken@libsdl.org>
parents:
6368
diff
changeset
|
401 |
if (_this->gles_data) { |
6190
519380462400
X11 OpenGL ES minor corrections
Sam Lantinga <slouken@libsdl.org>
parents:
6188
diff
changeset
|
402 |
SDL_SetError("OpenGL ES context not active"); |
519380462400
X11 OpenGL ES minor corrections
Sam Lantinga <slouken@libsdl.org>
parents:
6188
diff
changeset
|
403 |
return -1; |
519380462400
X11 OpenGL ES minor corrections
Sam Lantinga <slouken@libsdl.org>
parents:
6188
diff
changeset
|
404 |
} |
519380462400
X11 OpenGL ES minor corrections
Sam Lantinga <slouken@libsdl.org>
parents:
6188
diff
changeset
|
405 |
|
519380462400
X11 OpenGL ES minor corrections
Sam Lantinga <slouken@libsdl.org>
parents:
6188
diff
changeset
|
406 |
return _this->gles_data->egl_swapinterval; |
3190
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
407 |
} |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
408 |
|
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
409 |
void |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
410 |
X11_GLES_SwapWindow(_THIS, SDL_Window * window) |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
411 |
{ |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
412 |
_this->gles_data->eglSwapBuffers(_this->gles_data->egl_display, |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
413 |
_this->gles_data->egl_surface); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
414 |
} |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
415 |
|
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
416 |
void |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
417 |
X11_GLES_DeleteContext(_THIS, SDL_GLContext context) |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
418 |
{ |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
419 |
/* Clean up GLES and EGL */ |
6522
edacce9402fb
The gl_data is optional for the driver, so don't early out of the context delete call if it doesn't exist.
Sam Lantinga <slouken@libsdl.org>
parents:
6373
diff
changeset
|
420 |
if (!_this->gles_data) { |
edacce9402fb
The gl_data is optional for the driver, so don't early out of the context delete call if it doesn't exist.
Sam Lantinga <slouken@libsdl.org>
parents:
6373
diff
changeset
|
421 |
return; |
edacce9402fb
The gl_data is optional for the driver, so don't early out of the context delete call if it doesn't exist.
Sam Lantinga <slouken@libsdl.org>
parents:
6373
diff
changeset
|
422 |
} |
3190
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
423 |
|
6522
edacce9402fb
The gl_data is optional for the driver, so don't early out of the context delete call if it doesn't exist.
Sam Lantinga <slouken@libsdl.org>
parents:
6373
diff
changeset
|
424 |
if (_this->gles_data->egl_context != EGL_NO_CONTEXT || |
edacce9402fb
The gl_data is optional for the driver, so don't early out of the context delete call if it doesn't exist.
Sam Lantinga <slouken@libsdl.org>
parents:
6373
diff
changeset
|
425 |
_this->gles_data->egl_surface != EGL_NO_SURFACE) { |
edacce9402fb
The gl_data is optional for the driver, so don't early out of the context delete call if it doesn't exist.
Sam Lantinga <slouken@libsdl.org>
parents:
6373
diff
changeset
|
426 |
_this->gles_data->eglMakeCurrent(_this->gles_data->egl_display, |
edacce9402fb
The gl_data is optional for the driver, so don't early out of the context delete call if it doesn't exist.
Sam Lantinga <slouken@libsdl.org>
parents:
6373
diff
changeset
|
427 |
EGL_NO_SURFACE, EGL_NO_SURFACE, |
edacce9402fb
The gl_data is optional for the driver, so don't early out of the context delete call if it doesn't exist.
Sam Lantinga <slouken@libsdl.org>
parents:
6373
diff
changeset
|
428 |
EGL_NO_CONTEXT); |
6370
93187f7f7d5d
Improved simultaneous support for OpenGL and OpenGL ES
Sam Lantinga <slouken@libsdl.org>
parents:
6368
diff
changeset
|
429 |
|
6522
edacce9402fb
The gl_data is optional for the driver, so don't early out of the context delete call if it doesn't exist.
Sam Lantinga <slouken@libsdl.org>
parents:
6373
diff
changeset
|
430 |
if (_this->gles_data->egl_context != EGL_NO_CONTEXT) { |
edacce9402fb
The gl_data is optional for the driver, so don't early out of the context delete call if it doesn't exist.
Sam Lantinga <slouken@libsdl.org>
parents:
6373
diff
changeset
|
431 |
_this->gles_data->eglDestroyContext(_this->gles_data->egl_display, |
edacce9402fb
The gl_data is optional for the driver, so don't early out of the context delete call if it doesn't exist.
Sam Lantinga <slouken@libsdl.org>
parents:
6373
diff
changeset
|
432 |
_this->gles_data-> |
edacce9402fb
The gl_data is optional for the driver, so don't early out of the context delete call if it doesn't exist.
Sam Lantinga <slouken@libsdl.org>
parents:
6373
diff
changeset
|
433 |
egl_context); |
edacce9402fb
The gl_data is optional for the driver, so don't early out of the context delete call if it doesn't exist.
Sam Lantinga <slouken@libsdl.org>
parents:
6373
diff
changeset
|
434 |
_this->gles_data->egl_context = EGL_NO_CONTEXT; |
3190
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
435 |
} |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
436 |
|
6522
edacce9402fb
The gl_data is optional for the driver, so don't early out of the context delete call if it doesn't exist.
Sam Lantinga <slouken@libsdl.org>
parents:
6373
diff
changeset
|
437 |
if (_this->gles_data->egl_surface != EGL_NO_SURFACE) { |
edacce9402fb
The gl_data is optional for the driver, so don't early out of the context delete call if it doesn't exist.
Sam Lantinga <slouken@libsdl.org>
parents:
6373
diff
changeset
|
438 |
_this->gles_data->eglDestroySurface(_this->gles_data->egl_display, |
edacce9402fb
The gl_data is optional for the driver, so don't early out of the context delete call if it doesn't exist.
Sam Lantinga <slouken@libsdl.org>
parents:
6373
diff
changeset
|
439 |
_this->gles_data-> |
edacce9402fb
The gl_data is optional for the driver, so don't early out of the context delete call if it doesn't exist.
Sam Lantinga <slouken@libsdl.org>
parents:
6373
diff
changeset
|
440 |
egl_surface); |
edacce9402fb
The gl_data is optional for the driver, so don't early out of the context delete call if it doesn't exist.
Sam Lantinga <slouken@libsdl.org>
parents:
6373
diff
changeset
|
441 |
_this->gles_data->egl_surface = EGL_NO_SURFACE; |
edacce9402fb
The gl_data is optional for the driver, so don't early out of the context delete call if it doesn't exist.
Sam Lantinga <slouken@libsdl.org>
parents:
6373
diff
changeset
|
442 |
} |
3190
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
443 |
} |
3218 | 444 |
|
6522
edacce9402fb
The gl_data is optional for the driver, so don't early out of the context delete call if it doesn't exist.
Sam Lantinga <slouken@libsdl.org>
parents:
6373
diff
changeset
|
445 |
/* crappy fix */ |
edacce9402fb
The gl_data is optional for the driver, so don't early out of the context delete call if it doesn't exist.
Sam Lantinga <slouken@libsdl.org>
parents:
6373
diff
changeset
|
446 |
X11_GLES_UnloadLibrary(_this); |
3190
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
447 |
} |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
448 |
|
6044
35448a5ea044
Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents:
5535
diff
changeset
|
449 |
#endif /* SDL_VIDEO_DRIVER_X11 && SDL_VIDEO_OPENGL_ES */ |
3190
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
450 |
|
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
451 |
/* vi: set ts=4 sw=4 expandtab: */ |