We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 1395 - Second call to SDL_CreateWindow causes a problem with SDL_GL_MakeCurrent
Summary: Second call to SDL_CreateWindow causes a problem with SDL_GL_MakeCurrent
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: video (show other bugs)
Version: HG 2.0
Hardware: x86_64 Windows 7
: P1 normal
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords: target-2.0.0
Depends on:
Blocks:
 
Reported: 2012-01-23 14:36 UTC by wracky
Modified: 2013-08-01 00:02 UTC (History)
3 users (show)

See Also:


Attachments
Short Context problem sample program. (1.96 KB, text/plain)
2012-01-23 14:36 UTC, wracky
Details
C version of test program without GLEW. (2.26 KB, text/plain)
2013-07-31 22:37 UTC, Ryan C. Gordon
Details

Note You need to log in before you can comment on or make changes to this bug.
Description wracky 2012-01-23 14:36:12 UTC
Created attachment 800 [details]
Short Context problem sample program.

In my project I am creating 2 OpenGL windows.

I noticed that after creating the second window, a call to "SDL_GL_MakeCurrent(window1, context)" doesn't work as expected. Seeing that after this call, functions like glCreateShader() will still fail.

If I create only 1 window, everything is fine.
If I create a second window, a glCreateShader call will fail.

Workarounds:
if I first call SDL_GL_MakeCurrent(window2, context) after creating the second window, and directly call SDL_GL_MakeCurrent(window1, context) after that, the glCreateShader call will work.

if I call context = SDL_GL_CreateContext(window1); again right after creating window2 and followed by SDL_GL_MakeCurrent(window1, context), glCreateShader will also work.

I included a sample program with just a main routine that creates 2 windows, and checks a call to glCreateShader() in between to see the effect. It uses glew for OpenGL function bindings.
Comment 1 Steven Logan 2012-10-12 12:01:08 UTC
The exception seems to be getting thrown by the call to WIN_GL_SetupPixelFormat(_this, &pfd); on line 399 of SDL_windowsopengl.c
Comment 2 Ryan C. Gordon 2013-07-12 18:52:50 UTC
(Sorry if you get a lot of copies of this email, we're touching dozens of bug reports right now.)

Tagging a bunch of bugs as target-2.0.0, Priority 1.

This means we're in the final stretch for an official SDL 2.0.0 release! These are the bugs we really want to fix before shipping if humanly possible.

That being said, we don't promise to fix them because of this tag, we just want to make sure we don't forget to deal with them before we bless a final 2.0.0 release, and generally be organized about what we're aiming to ship.

Hopefully you'll hear more about this bug soon. If you have more information (including "this got fixed at some point, nevermind"), we would love to have you come add more information to the bug report when you have a moment.

Thanks!
--ryan.
Comment 3 Ryan C. Gordon 2013-07-31 22:37:32 UTC
Created attachment 1264 [details]
C version of test program without GLEW.


Here's a C version of the program without the GLEW dependency. It was faster for me than building a new project.

--ryan.
Comment 4 Ryan C. Gordon 2013-07-31 22:40:04 UTC
There's a good chance we fixed this; I've attached a C version of your program with the GLEW dependency removed, and it does not exhibit the problem you mention, so I assume the original code won't now, either.

I can think of a few things we've improved that could have fixed this: better context management, makecurrent fixes, etc.

At any rate, this doesn't crash here and both shader objects create successfully.

If this is still a problem for you with the latest SDL snapshot, please reopen this bug and we'll research it further.

Thanks!

--ryan.
Comment 5 Ryan C. Gordon 2013-07-31 23:34:20 UTC
No, wait, I was on an old version of SDL. The second glCreateShader() call fails for me, too, in the latest version. Checking.

--ryan.
Comment 6 Ryan C. Gordon 2013-08-01 00:02:57 UTC
Okay, it _was_ an SDL bug, and it's now fixed in http://hg.libsdl.org/SDL/rev/574f465da18a

Thanks!

--ryan.