Mercurial > sdl-ios-xcode
annotate src/video/x11/SDL_x11opengles.c @ 3234:f8c02d0560d5
Fixed bug #746
Fixed freeze when trying to memset with 0 length
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Fri, 07 Aug 2009 10:20:10 +0000 |
parents | 81773a1eac83 |
children | d559edc85610 |
rev | line source |
---|---|
3190
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 /* |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3 Copyright (C) 1997-2009 Sam Lantinga |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4 |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5 This library is free software; you can redistribute it and/or |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
7 License as published by the Free Software Foundation; either |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
9 |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
13 Lesser General Public License for more details. |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
14 |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
16 License along with _this library; if not, write to the Free Software |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
18 |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
19 Sam Lantinga |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
20 slouken@libsdl.org |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
21 |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
22 Open Pandora SDL driver |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
23 Copyright (C) 2009 David Carré |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
24 (cpasjuste@gmail.com) |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
25 */ |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
26 #include "SDL_config.h" |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
27 |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
28 #if SDL_VIDEO_OPENGL_ES |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
29 |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
30 #include "SDL_x11video.h" |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
31 #include "SDL_x11opengles.h" |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
32 |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
33 #define DEFAULT_OPENGL "/usr/lib/libGLES_CM.so" |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
34 |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
35 #define LOAD_FUNC(NAME) \ |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
36 *((void**)&_this->gles_data->NAME) = dlsym(handle, #NAME); \ |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
37 if (!_this->gles_data->NAME) \ |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
38 { \ |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
39 SDL_SetError("Could not retrieve EGL function " #NAME); \ |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
40 return -1; \ |
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 |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
43 /* GLES implementation of SDL OpenGL support */ |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
44 |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
45 void * |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
46 X11_GLES_GetProcAddress(_THIS, const char *proc) |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
47 { |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
48 static char procname[1024]; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
49 void *handle; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
50 void *retval; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
51 |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
52 handle = _this->gl_config.dll_handle; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
53 if (_this->gles_data->eglGetProcAddress) { |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
54 retval = _this->gles_data->eglGetProcAddress(proc); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
55 if (retval) { |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
56 return retval; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
57 } |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
58 } |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
59 #if defined(__OpenBSD__) && !defined(__ELF__) |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
60 #undef dlsym(x,y); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
61 #endif |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
62 retval = dlsym(handle, proc); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
63 if (!retval && strlen(proc) <= 1022) { |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
64 procname[0] = '_'; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
65 strcpy(procname + 1, proc); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
66 retval = dlsym(handle, procname); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
67 } |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
68 return retval; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
69 } |
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 void |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
72 X11_GLES_UnloadLibrary(_THIS) |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
73 { |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
74 if (_this->gl_config.driver_loaded) { |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
75 _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
|
76 |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
77 dlclose(_this->gl_config.dll_handle); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
78 |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
79 _this->gles_data->eglGetProcAddress = NULL; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
80 _this->gles_data->eglChooseConfig = NULL; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
81 _this->gles_data->eglCreateContext = NULL; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
82 _this->gles_data->eglCreateWindowSurface = NULL; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
83 _this->gles_data->eglDestroyContext = NULL; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
84 _this->gles_data->eglDestroySurface = NULL; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
85 _this->gles_data->eglMakeCurrent = NULL; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
86 _this->gles_data->eglSwapBuffers = NULL; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
87 _this->gles_data->eglGetDisplay = NULL; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
88 _this->gles_data->eglTerminate = NULL; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
89 |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
90 _this->gl_config.dll_handle = NULL; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
91 _this->gl_config.driver_loaded = 0; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
92 } |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
93 } |
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 int |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
96 X11_GLES_LoadLibrary(_THIS, const char *path) |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
97 { |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
98 void *handle; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
99 int dlopen_flags; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
100 |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
101 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
102 |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
103 if (_this->gles_data->egl_active) { |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
104 SDL_SetError("OpenGL ES context already created"); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
105 return -1; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
106 } |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
107 #ifdef RTLD_GLOBAL |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
108 dlopen_flags = RTLD_LAZY | RTLD_GLOBAL; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
109 #else |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
110 dlopen_flags = RTLD_LAZY; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
111 #endif |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
112 handle = dlopen(path, dlopen_flags); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
113 /* 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
|
114 if ((dlsym(handle, "eglChooseConfig") == NULL) && (path == NULL)) { |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
115 |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
116 dlclose(handle); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
117 path = getenv("SDL_VIDEO_GL_DRIVER"); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
118 if (path == NULL) { |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
119 path = DEFAULT_OPENGL; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
120 } |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
121 handle = dlopen(path, dlopen_flags); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
122 } |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
123 |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
124 if (handle == NULL) { |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
125 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
|
126 return -1; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
127 } |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
128 |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
129 /* Unload the old driver and reset the pointers */ |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
130 X11_GLES_UnloadLibrary(_this); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
131 |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
132 /* Load new function pointers */ |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
133 LOAD_FUNC(eglGetDisplay); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
134 LOAD_FUNC(eglInitialize); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
135 LOAD_FUNC(eglTerminate); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
136 LOAD_FUNC(eglGetProcAddress); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
137 LOAD_FUNC(eglChooseConfig); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
138 LOAD_FUNC(eglGetConfigAttrib); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
139 LOAD_FUNC(eglCreateContext); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
140 LOAD_FUNC(eglDestroyContext); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
141 LOAD_FUNC(eglCreateWindowSurface); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
142 LOAD_FUNC(eglDestroySurface); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
143 LOAD_FUNC(eglMakeCurrent); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
144 LOAD_FUNC(eglSwapBuffers); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
145 |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
146 _this->gles_data->egl_display = |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
147 _this->gles_data->eglGetDisplay((NativeDisplayType) data->display); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
148 |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
149 if (!_this->gles_data->egl_display) { |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
150 SDL_SetError("Could not get EGL display"); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
151 return -1; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
152 } |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
153 |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
154 if (_this->gles_data-> |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
155 eglInitialize(_this->gles_data->egl_display, NULL, |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
156 NULL) != EGL_TRUE) { |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
157 SDL_SetError("Could not initialize EGL"); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
158 return -1; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
159 } |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
160 |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
161 _this->gl_config.dll_handle = handle; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
162 _this->gl_config.driver_loaded = 1; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
163 |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
164 if (path) { |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
165 strncpy(_this->gl_config.driver_path, path, |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
166 sizeof(_this->gl_config.driver_path) - 1); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
167 } else { |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
168 strcpy(_this->gl_config.driver_path, ""); |
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 return 0; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
171 } |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
172 |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
173 XVisualInfo * |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
174 X11_GLES_GetVisual(_THIS, Display * display, int screen) |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
175 { |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
176 /* 64 seems nice. */ |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
177 EGLint attribs[64]; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
178 EGLint found_configs = 0; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
179 VisualID visual_id; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
180 int i; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
181 |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
182 /* load the gl driver from a default path */ |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
183 if (!_this->gl_config.driver_loaded) { |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
184 /* no driver has been loaded, use default (ourselves) */ |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
185 if (X11_GLES_LoadLibrary(_this, NULL) < 0) { |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
186 return NULL; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
187 } |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
188 } |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
189 |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
190 i = 0; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
191 attribs[i++] = EGL_RED_SIZE; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
192 attribs[i++] = _this->gl_config.red_size; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
193 attribs[i++] = EGL_GREEN_SIZE; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
194 attribs[i++] = _this->gl_config.green_size; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
195 attribs[i++] = EGL_BLUE_SIZE; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
196 attribs[i++] = _this->gl_config.blue_size; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
197 |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
198 if (_this->gl_config.alpha_size) { |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
199 attribs[i++] = EGL_ALPHA_SIZE; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
200 attribs[i++] = _this->gl_config.alpha_size; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
201 } |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
202 |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
203 if (_this->gl_config.buffer_size) { |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
204 attribs[i++] = EGL_BUFFER_SIZE; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
205 attribs[i++] = _this->gl_config.buffer_size; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
206 } |
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 attribs[i++] = EGL_DEPTH_SIZE; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
209 attribs[i++] = _this->gl_config.depth_size; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
210 |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
211 if (_this->gl_config.stencil_size) { |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
212 attribs[i++] = EGL_STENCIL_SIZE; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
213 attribs[i++] = _this->gl_config.stencil_size; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
214 } |
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 if (_this->gl_config.multisamplebuffers) { |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
217 attribs[i++] = EGL_SAMPLE_BUFFERS; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
218 attribs[i++] = _this->gl_config.multisamplebuffers; |
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 |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
221 if (_this->gl_config.multisamplesamples) { |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
222 attribs[i++] = EGL_SAMPLES; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
223 attribs[i++] = _this->gl_config.multisamplesamples; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
224 } |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
225 |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
226 attribs[i++] = EGL_NONE; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
227 |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
228 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
|
229 attribs, |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
230 &_this->gles_data->egl_config, 1, |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
231 &found_configs) == EGL_FALSE || |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
232 found_configs == 0) { |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
233 SDL_SetError("Couldn't find matching EGL config"); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
234 return NULL; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
235 } |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
236 |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
237 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
|
238 _this->gles_data->egl_config, |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
239 EGL_NATIVE_VISUAL_ID, |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
240 (EGLint *) & visual_id) == |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
241 EGL_FALSE || !visual_id) { |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
242 /* Use the default visual when all else fails */ |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
243 XVisualInfo vi_in; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
244 int out_count; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
245 vi_in.screen = screen; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
246 |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
247 _this->gles_data->egl_visualinfo = XGetVisualInfo(display, |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
248 VisualScreenMask, |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
249 &vi_in, &out_count); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
250 } else { |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
251 XVisualInfo vi_in; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
252 int out_count; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
253 |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
254 vi_in.screen = screen; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
255 vi_in.visualid = visual_id; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
256 _this->gles_data->egl_visualinfo = XGetVisualInfo(display, |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
257 VisualScreenMask | |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
258 VisualIDMask, |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
259 &vi_in, &out_count); |
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 return _this->gles_data->egl_visualinfo; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
263 } |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
264 |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
265 SDL_GLContext |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
266 X11_GLES_CreateContext(_THIS, SDL_Window * window) |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
267 { |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
268 int retval; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
269 SDL_WindowData *data = (SDL_WindowData *) window->driverdata; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
270 Display *display = data->videodata->display; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
271 |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
272 XSync(display, False); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
273 |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
274 |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
275 _this->gles_data->egl_context = |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
276 _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
|
277 _this->gles_data->egl_config, |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
278 EGL_NO_CONTEXT, NULL); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
279 XSync(display, False); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
280 |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
281 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
|
282 SDL_SetError("Could not create EGL context"); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
283 return NULL; |
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 |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
286 _this->gles_data->egl_active = 1; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
287 |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
288 if (_this->gles_data->egl_active) |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
289 retval = 1; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
290 else |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
291 retval = 0; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
292 |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
293 return (retval); |
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 |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
296 int |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
297 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
|
298 { |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
299 int retval; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
300 |
3218 | 301 // SDL_WindowData *data = (SDL_WindowData *) window->driverdata; |
302 // Display *display = data->videodata->display; | |
3190
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
303 |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
304 retval = 1; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
305 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
|
306 _this->gles_data->egl_surface, |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
307 _this->gles_data->egl_surface, |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
308 _this->gles_data->egl_context)) { |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
309 SDL_SetError("Unable to make EGL context current"); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
310 retval = -1; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
311 } |
3218 | 312 // XSync(display, False); |
3190
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
313 |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
314 return (retval); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
315 } |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
316 |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
317 static int swapinterval = -1; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
318 int |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
319 X11_GLES_SetSwapInterval(_THIS, int interval) |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
320 { |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
321 return 0; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
322 } |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
323 |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
324 int |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
325 X11_GLES_GetSwapInterval(_THIS) |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
326 { |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
327 return 0; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
328 } |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
329 |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
330 void |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
331 X11_GLES_SwapWindow(_THIS, SDL_Window * window) |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
332 { |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
333 _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
|
334 _this->gles_data->egl_surface); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
335 } |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
336 |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
337 void |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
338 X11_GLES_DeleteContext(_THIS, SDL_GLContext context) |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
339 { |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
340 /* Clean up GLES and EGL */ |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
341 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
|
342 _this->gles_data->egl_surface != EGL_NO_SURFACE) { |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
343 _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
|
344 EGL_NO_SURFACE, EGL_NO_SURFACE, |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
345 EGL_NO_CONTEXT); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
346 |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
347 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
|
348 _this->gles_data->eglDestroyContext(_this->gles_data->egl_display, |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
349 _this->gles_data-> |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
350 egl_context); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
351 _this->gles_data->egl_context = EGL_NO_CONTEXT; |
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 |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
354 if (_this->gles_data->egl_surface != EGL_NO_SURFACE) { |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
355 _this->gles_data->eglDestroySurface(_this->gles_data->egl_display, |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
356 _this->gles_data-> |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
357 egl_surface); |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
358 _this->gles_data->egl_surface = EGL_NO_SURFACE; |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
359 } |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
360 } |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
361 _this->gles_data->egl_active = 0; |
3218 | 362 |
363 /* crappy fix */ | |
364 X11_GLES_UnloadLibrary(_this); | |
365 | |
3190
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
366 } |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
367 |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
368 #endif /* SDL_VIDEO_OPENGL_ES */ |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
369 |
c68d2ca5970f
Added missing files for OpenGL ES support
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
370 /* vi: set ts=4 sw=4 expandtab: */ |