Closed ghost closed 9 years ago
More information in my case. It seems like I get to if (!_glfwIsValidContext(&ctxconfig))
in GLFW and whatever checks are done inside _glfwIsValidContext(&ctxconfig)
are failing so I get NULL
instead of a context.
For the tutorial itself, maybe some wording about debugging and seeing where the context is failing is appropriate? In my case I've just been single stepping the code in Visual Studio.
Found it. In glfwIsValidContext
, two OpenGL contexts are checked against each other and if the version doesn't match, we get NULL.
I'm on Windows 10 on a Lenovo X1 Carbon (3443CTO)
ctxconfig = 0x003ef8a8 {api=196609 major=4 minor=1 ...} //the context we're checking window->context = {api=196609 major=4 minor=0 ...} //result of _glfwPlatformGetCurrentContext
Further than that, I don't really understand - maybe someone else can provide more insight.
FWIW, making _glfwIsValidContext
return GL_TRUE
gets me a grey window, but I have no idea if it's usable / working.
Can you try generating an OpenGL 3.3 context instead?
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
I don't have an HD 4000 anymore, but I can ask around and try to have someone else reproduce this.
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
works, and so does
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
Maybe something in the README about dropping the OpenGL version down if you have trouble? Or is there a way to make the "Failed" message spit out the system's supported OpenGL version?
@voltagex according to Wikipedia, the Intel HD 4000 only supports OpenGL 4.0
under Windows. Looks like that's what your error messages were saying as well. You'll want:
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
I tested this on an HD 4000 in OSX, where 4.1 is available. Should have caught this, sorry about that!
Edit: Similar problems under Linux.
This chart says it only runs 3.3 under Linux.
Looks like it's time to roll back to an older GL version or maybe insert more error messages ...
Depends what you expect from your target audience. If this is intended for classrooms where all the machines would have the same version supported, maybe hardcoding 4.0 is OK.
Should I open another issue for something like "Minimum OpenGL requirements"?
Fundamentally, GL 3 and GL 4 are pretty similar. They're both within the scope of "Modern OpenGL" though there are a few nice things about 4 that aren't available in 3. 4.0 and 4.1 is miniscule differences, so it's probably safe to drop to 4.0. It'll still create a forward compatible context when possible.
I'm more concerned about users who are on older graphics cards that aren't GL 4 compatible. They are out there, but evidently a lot more are still floating around than I realized, considering this is the second issue raised about this so far.
Setting an error callback could be helpful: http://www.glfw.org/docs/latest/quick.html#quick_capture_error - but in this case, the error message produced is useless. I wonder if that's worth a bug report to GLFW...
I want to avoid callbacks as much as possible. This project is used by a significant number of "non-programmers" (art majors, etc. who just want OpenGL to "work"). Ideally the main code should be as short and simple as possible, and should be easy to read without having to go "oh, this is called when an error happens? But why?!"
Fair enough. Thanks for helping me get started.
@voltagex sure thing!
I set it to OpenGL 4.0, so you should be able to pull latest and pick up that change.
This may be out of scope for this project, but would it be possible to include some troubleshooting steps for those of us who get
Failed to Create OpenGL Context
instead of a GL window? I'm on an Intel HD4000 chipset right now but I should be able to get some kind of window.