However the API is shaped, we should keep in mind that we’ll need a way to
do a graceful fallback in some cases, and have a way to check if the app is
using GL or GLES.
So flags like
SDL_WINDOW_OPENGL (if OpenGL is unavailable, fails)
SDL_WINDOW_OPENGL_ES (if GL ES is unavailable, fails)
(SDL_WINDOW_OPENGL_ES | SDL_WINDOW_OPENGL) (allows a fallback to opengl if
GL ES fails)
With this logic, using both the the GL ES and OPENGL flags should be
cross-platform, and easy to check:
SDL_Window* your_window = SDL_CreateWindow( “OpenGL/ES
Test”, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 800, 600,
SDL_WINDOW_OPENGL| SDL_WINDOW_GLES);
if ( SDL_GetWindowFlags(your_window) & SDL_WINDOW_GLES ) {
// Hurray, we are using OpenGL/ES
} else {
// Do some sort of fallback, create context
}
I have no experience with OpenGL ES or EGL (are they the same?), so I don’t
know how well that would work, but I think it’s best not to add a bunch of
extra API, and just stick with flags. I also don’t see much point of
allowing both OpenGL and OpenGL ES function pointers to be filled (it’s my
understanding that they both do the same essential things, but I could be
wrong).
I could probably hack together some sort of patch but I did see that Andre
has already posted something to that extent. I just recommend only adding
one flag (for OpenGL ES) rather than changing one
(SDL_WINDOW_OPENGL_API_GL) and adding one for OpenGL ES.
Thoughts?
-AlexOn Wed, Jul 18, 2012 at 12:20 PM, Andre Heider <a.heider at gmail.com> wrote:
On Wed, Jul 18, 2012 at 5:29 PM, Scott Percival wrote:
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.
Hi,
I just subscribed to this list a day ago, so missed this discussion.
You’ve probably seen my patches, which take the envvar solution to fix
the initialization issue.
That’s obviously limited to one API per process runtime, which I
believe is a good first step.
But I think the proper solution needs more than your SDL_GL_CONTEXT_EGL:
If you use OpenGL calls in your application, you specifically want
that API and not OpenGLES.
How about adding 2 new flags to SDL_WindowFlags, something like:
- SDL_WINDOW_OPENGL_API_GL
- SDL_WINDOW_OPENGL_API_GLES
If none of those is set, it does what SDL currently does: Choose
whatever is available. This is backward compatible and usable for
applications that don’t use GL[ES] calls on their own. The envvar
solution is still handy for this scenario.
The other flags only accept one specific API. But instead of checking
that in the X11 driver, it should be handled in SDL_video.c globally.
That would e.g. prevent getting a GLES context on whatever platforms
if the app specifically asked for GL - and not just a single driver.
Regards,
Andre
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org