SDL_GL_GetAttribute and 3.2+ Context |
SDL_GL_GetAttribute and 3.2+ Context |
Christopher Gautier
Guest
|
Hi,
Interestingly, I had the same problem a few days ago. SDL_GL_GetAttribute() is assuming it can always query the GL attributes, but as you said, this is no longer valid in the latest version of OpenGL. I worked around it by querying the GLX context instead (I can provide the code if you are using Linux). That's obviously not cross-platform, but I believe that it is the proper solution (so the equivalent code would be required for WGL, AGL, etc.) Cheers, Chris _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||
|
Re: SDL_GL_GetAttribute and 3.2+ Context |
errissa
|
Thanks. I am using Linux and I ended up doing the same thing. It would be nice to see if this fixed in SDL. If time permits, I'll take a stab at it... |
|||||||||||||
|
SDL_GL_GetAttribute and 3.2+ Context |
Alex Szpakowski
Guest
|
Yeah, there's been a bugzilla issue filed for it: https://bugzilla.libsdl.org/show_bug.cgi?id=2060
Basically you have to use this in core GL3.2+ contexts: glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_BACK_LEFT, GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE, &myredsize); On 2013-09-20, at 2:03 PM, errissa wrote:
|
|||||||||||||
|
trevor.shawn.williams
|
Being more specific for anyone who comes here after me looking for a workaround:
Algorithm: //Include SDL_opengl.h - This file is not included with SDL.h. //Load the OpenGL library via SDL_GL_LoadLibrary() passing NULL or nullptr as the argument if you just want to load the default. //Use SDL_GL_SetAttribute() to set whatever attributes you like including the context profile and all. //Feel free to use SDL_GL_GetAttribute to verify the values of any attributes you know aren't affected by the bug at this point. //Create the SDL_Window with the SDL_WINDOW_OPENGL flag. //Create the SDL_GLContext you want associated with the SDL_Window. //Use SDL_GL_GetProcAddress("glGetFramebufferAttachmentParameteriv") to retrieve the function named, and store it in a ptr2_function of type void (APIENTRY*)(GLenum, GLenum, GLenum, GLint*). //Make sure the function was successfully retrieved. // Verify the attribute values affected by the bug using the ptr2_function into which glGetFramebufferParameteriv() has been stored. in fake C++11 code: #include <SDL/SDL2/SDL_video.h> #include <SDL/SDL2/SDL_opengl.h> // Done implicitly after window creation, but I vaguely remember calls to set or get some opengl attributes failing if this isn't done first. SDL_GL_LoadLibrary(nullptr); SDL_GL_SetAttribute(...); SDL_GL_GetAttribute(...); SDL_Window *the_window = SDL_CreateWindow(..., SDL_WINDOW_OPENGL); SDL_GLContext the_opengl_context = SDL_GL_CreateContext(the_window); //APIENTRY, GLenum, and GLint will be unknown if you haven't included SDL_opengl.h. Again, it is not included with SDL.h //Also using APIENTRY is mandatory to avoid screwing up your stack as mentioned in the SDL src. using ptr2_opengl_function = void (APIENTRY*)(GLenum, GLenum, GLenum, GLint*); //Casting before the assignment is necessary as stated in the SDL2-2.0.3 src. Don't omit it. //See the remarks section on the SDL_GL_GetProcAddress SDL-wiki page for additional useful info. ptr2_opengl_function ptr2_glGetFramebufferAttachmentParameteriv = (ptr2_opengl_function)SDL_GL_GetProcAddress("glGetFramebufferAttachmentParameteriv"); //Be sure you've successfully retrieved the function before trying to call it or you're screwed. if(ptr2_glGetFramebufferAttachmentParameteriv) { // Check the parameters } Please excuse any typos. Just trying to give a quick overview. |
|||||||||||
|
SDL_GL_GetAttribute and 3.2+ Context |
Jonas Kulla
Guest
|
FYI: Just checking that "ptr2_glBlah != 0" is not sufficient. On GLX I can just GetProcAddress("glThisIsDog")
and get a non-null return value (I can even call into it). The only correct way to ensure that an entry point is present is to check the extension list / GL version. 2015-02-25 10:04 GMT+01:00 trevor.shawn.williams:
|
|||||||||||||
|