Re: [PyOpenGL-Users] No valid context
Brought to you by:
mcfletch
From: Ian M. <ia...@ge...> - 2020-04-22 07:28:22
|
On Tue, Apr 21, 2020 at 11:26 PM physkets <phy...@tu...> wrote: > Offhand, I am surprised that `glVertexAttribPointer(...)` would be the >> call to fail; there are plenty of other GL calls that should have failed >> beforehand, if indeed they didn't fail. GLFW creates a context, and it >> looks like you're setting it as current. If that code does what it looks >> like, correctly, then the error especially wouldn't make sense. I would >> suggest to try validating the context, perhaps creating a debug context. >> > Can you point me to some resources that explain how I can do that? > In general, Google is your friend on this, but I'll give a shoutout to the OpenGL Wiki. PyOpenGL conveniently does user-level OpenGL error checking (`glGetError()`, etc.) for you, but this is separate from a debug context per-se, which is a driver-level flag that enables additional validation within the context itself. I don't know how this works in Python, since if I need to do robust/fast/reliable graphics, I do it in C++, but in that language it's as easy as: void __stdcall callback_err_gl(GLenum source,GLenum type,GLuint id, GLenum severity,GLsizei length,GLchar const* message,void const* user_param) { //[Notice errors here . . .] } int main(int argc, char* argv[]) { //[...] glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GLFW_TRUE); glDebugMessageCallback(callback_err_gl,nullptr); //[...] return 0; } This should be a reasonable guide as you search for the Python binding's equivalent. > What happens if you just try drawing an empty window without the >> problematic setup code? >> > It works if I simply set a single colour using `glClearColor()`. There is > no crash, and it displays a window with the right color. > This suggests to me that the OpenGL context is working, and that there's some peculiarity with the `glVertexAttribPointer(...)` function itself. I have no idea what that might be, though. It working for me on a different platform, and other GL calls succeeding suggests a possible bug. Also, why did you comment the context creation hints? >> > I did not think those ones were important. I assume it will use that > latest version of opengl that I have. Is that not true? > I don't know whether it's mandated to be a particular way by the OpenGL specification (I don't think it is, and the spec. is version-specific anyway), but my experience has been that when you request a context, you'll get back whatever the driver wants to give you. This is often the highest OpenGL version your hardware supports (which is not necessarily a good thing, mind), but it's sometimes not. The point is, you want to *know* what you're getting. Specifying the parameters is a good way to do that. You might also try seeing if you can reproduce the problem in RenderDoc <https://renderdoc.org/>? (Although IDK how well it plays with Python . . .) Ian |