Reliable Init of SDL OpenGL Context?

Hi

For the SDL port I'm looking for help on how to reliable initialize an OpenGL Context on OS X and Linux.

According to the SDL docs the SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_MAJOR_VERSION and SDL_GL_CONTEXT_MINOR_VERSION must be set before creating the first window. Is there a way to query what is supported other than trying to create a window and context, and if that fails destroy the window and retry with a lower version?

I have the same question for SDL_GL_FRAMEBUFFER_SRGB_CAPABLE. If this attribute is set then the SDL_CreateWindow call fails on my Linux laptop. Is there a way to query if that is supported without having to assume that if creation of the window fails it is due to the framebuffer not being SRGB capable?

BTW asynchronous texture download is also super glitchy on my Linux laptop when using the nvidia driver. However it seems to work fine when using the open source driver.

/Kim
Hi,
I am definitely interested in the SDL2 port, but I am far behind. I did check out David Gow’s code on https://davidgow.net/handmadepenguin/

I think, it is your decision to pick a profile based on what you need.
Even if you picked a profile, you will still struggle.

From libsdl wiki:
...”Do not assume that all contexts you create will have the same set of extensions available, or that recreating an existing context will offer the same extensions again.”
https://wiki.libsdl.org/SDL_GL_ExtensionSupported

Which OpenGL extension-handling library did you choose?
https://wiki.libsdl.org/SDL_GL_CreateContext

Also, I would recommend that you choose a profile which is most compatible with the mobile version.
http://developer.android.com/guide/topics/graphics/opengl.html

So, we could compile on Android or via webgl in a browser as well.

I would not rely on ancient OpenGL Versions. Seriously OpenGL 2.1 was released 2006, OpenGL 3.0 in 2008 and OpenGL 4.0 in 2010. Maybe this is already a good chance for trying vulkan to sync the development heartbeat with the industry. Think Valve and Sam Lantinga might be highly amused, if you do some serious work on their API.

HmH doesn’t rely on DirectX 9, and there aren’t any fallbacks to that version planned, right?

In this context, in my mail to David Gow I already recommended a look on sdl-gpu.
https://github.com/grimfang4/sdl-gpu

David knew already about that extension, but maybe other developers are also interested.

Can’t find the link to the sdl_shader management lib yet, but I will hand it later.

Since followers here already started coding with OpenGL, here a few ressources:

Yes... the board is always complaining about too many links...
Modern OpenGL:
antongerdelan.net/opengl/
a partially port to SDL2 is here:
github.com/AidanDelaney/antons_opengl_tutorials_book/tree/sdl2-port/

SDL2/OpenGL:
www.zhieng.com/sdl2-with-opengl/
bcmpinc.wordpress.com/2015/08/18/...-4-5-context-using-sdl2-and-glad/
lazyfoo.net/tutorials/SDL/51_SDL_and_modern_opengl/
headerphile.com/sdl2/opengl-part-1-sdl-opengl-awesome/
www.opengl.org/wiki/Tutorial1:_Cr...enGL_3.2_Context_in_SDL_(C_/_SDL)
Hi Acry

Most of the OpenGL code is written by Casey and architected so that it is reusable cross platform. Shaders has not been introduced yet, so for now the platform needs to setup a context that is compatible with the old pipeline.


Acry

Which OpenGL extension-handling library did you choose?

Casey did not introduce any OpenGL extension-handling libraries and I would like to avoid that as well. But I begin to realize how nasty this is. Just the concept of having to introduce another library to make the first one usable freaks me out.


Acry

HmH doesn’t rely on DirectX 9, and there aren’t any fallbacks to that version planned, right?

Right. I think only OpenGL will be supported.

Thank you for the links. I'll check them out.

/Kim