Improved simultaneous support for OpenGL and OpenGL ES
From Scott Percival Okay, I think I have something for this. Tested it on GL and GLES machines, it seems to work okay. - Add a new SDL GL attribute SDL_GL_CONTEXT_EGL: - Only useful for the X11 video driver at the moment - Set to 1 for an EGL context, 0 to use the default for the video driver - Default is 0, unless library is built for EGL only - Should be set after SDL init, but before window/context creation (i.e. same place you'd specify attributes for major/minor GL version) - After a lot of agony pondering the least-terrible way to go about it, made it so that X11_GL_LoadLibrary and X11_GLES_LoadLibrary check SDL_GL_CONTEXT_EGL. If no GL context exists yet, and the attribute choice doesn't match with the checking function, then it changes all the function pointers in the video driver and passes control on to the new LoadLibrary method. - Likewise, make X11_CreateWindow check this attribute before firing off a call to X11_GL_GetVisual/X11_GLES_GetVisual - Added a sanity check to the start of X11_GL_LoadLibrary - Tidied up SDL_x11opengles.h - Moved ownership of the gles_data structure over to X11_GLES_LoadLibrary/UnloadLibrary - Should incorporate the 3 fixes posted by Andre Heider This is obviously quite a bit to take in, but is (at least) a proof of concept for the approach I think EGL/GLX mingling should take. Any comments/criticism is much appreciated.
This commit is contained in:
parent
cb83481887
commit
b3219a6db1
9 changed files with 127 additions and 103 deletions
|
@ -29,6 +29,7 @@
|
|||
|
||||
#if SDL_VIDEO_OPENGL_GLX
|
||||
#include "SDL_loadso.h"
|
||||
#include "SDL_x11opengles.h"
|
||||
|
||||
#if defined(__IRIX__)
|
||||
/* IRIX doesn't have a GL library versioning system */
|
||||
|
@ -122,6 +123,28 @@ X11_GL_LoadLibrary(_THIS, const char *path)
|
|||
{
|
||||
void *handle;
|
||||
|
||||
if (_this->gl_data) {
|
||||
SDL_SetError("OpenGL context already created");
|
||||
return -1;
|
||||
}
|
||||
|
||||
#if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2
|
||||
/* If SDL_GL_CONTEXT_EGL has been changed to 1, switch over to X11_GLES functions */
|
||||
if (_this->gl_config.use_egl == 1) {
|
||||
_this->GL_LoadLibrary = X11_GLES_LoadLibrary;
|
||||
_this->GL_GetProcAddress = X11_GLES_GetProcAddress;
|
||||
_this->GL_UnloadLibrary = X11_GLES_UnloadLibrary;
|
||||
_this->GL_CreateContext = X11_GLES_CreateContext;
|
||||
_this->GL_MakeCurrent = X11_GLES_MakeCurrent;
|
||||
_this->GL_SetSwapInterval = X11_GLES_SetSwapInterval;
|
||||
_this->GL_GetSwapInterval = X11_GLES_GetSwapInterval;
|
||||
_this->GL_SwapWindow = X11_GLES_SwapWindow;
|
||||
_this->GL_DeleteContext = X11_GLES_DeleteContext;
|
||||
return X11_GLES_LoadLibrary(_this, path);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* Load the OpenGL library */
|
||||
if (path == NULL) {
|
||||
path = SDL_getenv("SDL_OPENGL_LIBRARY");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue