I have already added the suggested modification to my codebase, so the
following is now an academic exercise.
If you check the Khronos specification of
WGL_ARB_create_contexthttp://www.opengl.org/registry/specs/ARB/wgl_create_context.txt,
GLX_ARB_create_contexthttps://www.opengl.org/registry/specs/ARB/glx_create_context.txt,
aglChoosePixelFormathttps://developer.apple.com/library/mac/documentation/graphicsimaging/reference/agl_opengl/DeprecationAppendix/AppendixADeprecatedAPI.html#//apple_ref/c/func/aglChoosePixelFormat
/aglCreateContexthttps://developer.apple.com/library/mac/documentation/graphicsimaging/reference/agl_opengl/DeprecationAppendix/AppendixADeprecatedAPI.html#//apple_ref/c/func/aglCreateContextand
eglChooseConfighttp://www.khronos.org/registry/egl/sdk/docs/man/xhtml/eglChooseConfig.html
/eglCreateContexthttp://www.khronos.org/registry/egl/sdk/docs/man/xhtml/eglCreateContext.html,
you will see that there is no requirement that for specific attributes to
be set before a window is constructed. In other words, you can call
(pseudocode):
- win = CreateWindow()
- pf = ChoosePixelFormat(attribs)
- ctx = CreateContext(pf)
- MakeCurrent(ctx, win) (*)
in that order, and have a working OpenGL / OpenGL ES setup. This works on
native WGL, GLX, AGL and EGL. This also works on SDL2 / desktop on its
WGL, GLX, NSOpenGL and EGL/ANGLE codepaths. It fails on SDL2 / android +
EGL.
If you doubt the validity of the above, I invite you to run the
multisampling example from https://github.com/opentk/opentk on your
favorite operating system.
Do not misunderstand: I have already made the necessary modifications to
get my codebase working on SDL2 / android. The reason why I call this a
"terrible hack" is that it forces tight coupling between window and context
construction, in a way that was - so far - not required by non-android
platforms.
I don’t doubt that there are good technical reasons for this requirement on
android. If you know these reasons and care to share them, I would be
really interested in hearing the explanation. But, please, don’t handwave
this away with “every operating system requires this” - because this is
simply not true.
(*) Win32 has an additional requirement of calling SetPixelFormat before
calling MakeCurrent() for the first time. This is a one-off statement
between steps 3 and 4.
2014-03-26 1:47 GMT+01:00 Gabriel Jacobo :> Anything that uses EGL needs to follow this rule, because EGL supports 3
types of OpenGL contexts (desktop, ES1 and ES2), and each need a different
bit set in the associated EGL surface that’s created along with the window,
as well as a different API binding. If anyone has a way to get rid of this
limitation that works across all platforms, by all means let’s try it (I
did try setting the EGL_RENDERABLE_TYPE setting to an or’ed combination of
all valid bitmasks, but that didn’t fly with the Linux nVidia driver at the
time, maybe it works or doesn’t with others).
Otherwise, you’ll have to live with this 'horrible hack"
of having to
set the GL attributes before creating the window.
Non EGL based backends probably don’t require this, but you never know
what you are gonna get.
2014-03-25 21:35 GMT-03:00 Alex Szpakowski :
Forest Hale is quite correct. The only exceptions I know of are Mac OS X
and iOS, where the native backend APIs allow the OpenGL context creation to
be a little more independent from the window creation than other platforms.
You can check out the WIN_CreateWindow and WIN_GL_SetupWindow in the
Windows backend for an example.
On Mar 25, 2014, at 9:30 PM, Stefanos A. <@Stefanos_A> wrote:
My statement includes multisampling and I have working code to prove
it, both native and with SDL2. 
Feel free to contact me off-list for a link and/or explanation.
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
–
Gabriel.
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org