Fix OpenGL initialization when OpenGL and OpenGLES are both available.
Both options default to "yes" via configure, and having libs/headers for both installed is not unusual. We default to OpenGL on this compile time combination, but can enforce OpenGLES via setting the envvar SDL_VIDEO_X11_GLES. This will be further refined based on community feedback. Contributed by Andre Heider
This commit is contained in:
parent
b29ba3d6cf
commit
cb83481887
3 changed files with 53 additions and 39 deletions
|
@ -144,7 +144,19 @@ X11_CreateDevice(int devindex)
|
||||||
}
|
}
|
||||||
device->driverdata = data;
|
device->driverdata = data;
|
||||||
|
|
||||||
|
/* In case GL and GLES/GLES2 is compiled in, we default to GL, but use
|
||||||
|
* GLES if SDL_VIDEO_X11_GLES is set.
|
||||||
|
*/
|
||||||
#if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
|
#if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
|
||||||
|
#if SDL_VIDEO_OPENGL_GLX
|
||||||
|
data->gles = SDL_getenv("SDL_VIDEO_X11_GLES") != NULL;
|
||||||
|
#else
|
||||||
|
data->gles = SDL_TRUE;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
|
||||||
|
if (data->gles) {
|
||||||
device->gles_data = (struct SDL_PrivateGLESData *) SDL_calloc(1, sizeof(SDL_PrivateGLESData));
|
device->gles_data = (struct SDL_PrivateGLESData *) SDL_calloc(1, sizeof(SDL_PrivateGLESData));
|
||||||
if (!device->gles_data) {
|
if (!device->gles_data) {
|
||||||
SDL_OutOfMemory();
|
SDL_OutOfMemory();
|
||||||
|
@ -152,6 +164,7 @@ X11_CreateDevice(int devindex)
|
||||||
SDL_free(device);
|
SDL_free(device);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* FIXME: Do we need this?
|
/* FIXME: Do we need this?
|
||||||
|
@ -224,6 +237,7 @@ X11_CreateDevice(int devindex)
|
||||||
device->shape_driver.ResizeWindowShape = X11_ResizeWindowShape;
|
device->shape_driver.ResizeWindowShape = X11_ResizeWindowShape;
|
||||||
|
|
||||||
#if SDL_VIDEO_OPENGL_GLX
|
#if SDL_VIDEO_OPENGL_GLX
|
||||||
|
if (!data->gles) {
|
||||||
device->GL_LoadLibrary = X11_GL_LoadLibrary;
|
device->GL_LoadLibrary = X11_GL_LoadLibrary;
|
||||||
device->GL_GetProcAddress = X11_GL_GetProcAddress;
|
device->GL_GetProcAddress = X11_GL_GetProcAddress;
|
||||||
device->GL_UnloadLibrary = X11_GL_UnloadLibrary;
|
device->GL_UnloadLibrary = X11_GL_UnloadLibrary;
|
||||||
|
@ -233,8 +247,10 @@ X11_CreateDevice(int devindex)
|
||||||
device->GL_GetSwapInterval = X11_GL_GetSwapInterval;
|
device->GL_GetSwapInterval = X11_GL_GetSwapInterval;
|
||||||
device->GL_SwapWindow = X11_GL_SwapWindow;
|
device->GL_SwapWindow = X11_GL_SwapWindow;
|
||||||
device->GL_DeleteContext = X11_GL_DeleteContext;
|
device->GL_DeleteContext = X11_GL_DeleteContext;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
|
#if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
|
||||||
|
if (data->gles) {
|
||||||
device->GL_LoadLibrary = X11_GLES_LoadLibrary;
|
device->GL_LoadLibrary = X11_GLES_LoadLibrary;
|
||||||
device->GL_GetProcAddress = X11_GLES_GetProcAddress;
|
device->GL_GetProcAddress = X11_GLES_GetProcAddress;
|
||||||
device->GL_UnloadLibrary = X11_GLES_UnloadLibrary;
|
device->GL_UnloadLibrary = X11_GLES_UnloadLibrary;
|
||||||
|
@ -244,6 +260,7 @@ X11_CreateDevice(int devindex)
|
||||||
device->GL_GetSwapInterval = X11_GLES_GetSwapInterval;
|
device->GL_GetSwapInterval = X11_GLES_GetSwapInterval;
|
||||||
device->GL_SwapWindow = X11_GLES_SwapWindow;
|
device->GL_SwapWindow = X11_GLES_SwapWindow;
|
||||||
device->GL_DeleteContext = X11_GLES_DeleteContext;
|
device->GL_DeleteContext = X11_GLES_DeleteContext;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
device->SetClipboardText = X11_SetClipboardText;
|
device->SetClipboardText = X11_SetClipboardText;
|
||||||
|
|
|
@ -93,6 +93,8 @@ typedef struct SDL_VideoData
|
||||||
|
|
||||||
SDL_Scancode key_layout[256];
|
SDL_Scancode key_layout[256];
|
||||||
SDL_bool selection_waiting;
|
SDL_bool selection_waiting;
|
||||||
|
|
||||||
|
SDL_bool gles;
|
||||||
} SDL_VideoData;
|
} SDL_VideoData;
|
||||||
|
|
||||||
extern SDL_bool X11_UseDirectColorVisuals(void);
|
extern SDL_bool X11_UseDirectColorVisuals(void);
|
||||||
|
|
|
@ -269,24 +269,19 @@ X11_CreateWindow(_THIS, SDL_Window * window)
|
||||||
Atom wmstate_atoms[3];
|
Atom wmstate_atoms[3];
|
||||||
Uint32 fevent = 0;
|
Uint32 fevent = 0;
|
||||||
|
|
||||||
#if SDL_VIDEO_OPENGL_GLX
|
#if SDL_VIDEO_OPENGL_GLX || SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
|
||||||
if (window->flags & SDL_WINDOW_OPENGL) {
|
if (window->flags & SDL_WINDOW_OPENGL) {
|
||||||
XVisualInfo *vinfo;
|
XVisualInfo *vinfo;
|
||||||
|
|
||||||
vinfo = X11_GL_GetVisual(_this, display, screen);
|
#if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
|
||||||
if (!vinfo) {
|
if (data->gles) {
|
||||||
return -1;
|
vinfo = X11_GLES_GetVisual(_this, display, screen);
|
||||||
}
|
|
||||||
visual = vinfo->visual;
|
|
||||||
depth = vinfo->depth;
|
|
||||||
XFree(vinfo);
|
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
#if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
|
{
|
||||||
if (window->flags & SDL_WINDOW_OPENGL) {
|
vinfo = X11_GL_GetVisual(_this, display, screen);
|
||||||
XVisualInfo *vinfo;
|
}
|
||||||
|
|
||||||
vinfo = X11_GLES_GetVisual(_this, display, screen);
|
|
||||||
if (!vinfo) {
|
if (!vinfo) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -395,7 +390,7 @@ X11_CreateWindow(_THIS, SDL_Window * window)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
|
#if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
|
||||||
if (window->flags & SDL_WINDOW_OPENGL) {
|
if (data->gles && window->flags & SDL_WINDOW_OPENGL) {
|
||||||
/* Create the GLES window surface */
|
/* Create the GLES window surface */
|
||||||
_this->gles_data->egl_surface =
|
_this->gles_data->egl_surface =
|
||||||
_this->gles_data->eglCreateWindowSurface(_this->gles_data->
|
_this->gles_data->eglCreateWindowSurface(_this->gles_data->
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue