Re: [PyOpenGL-Users] "Attempt to retrieve context when no valid context" when calling glVertexAttri
Brought to you by:
mcfletch
|
From: Ian M. <ia...@ge...> - 2018-01-03 01:37:58
|
On Tue, Jan 2, 2018 at 12:33 AM, JP LeBreton <jpl...@gm...> wrote: > I have a program (http://vectorpoem.com/playscii) that's been running > nicely with PyOpenGL on x86 Linux, macOS, and Windows for a few years now, > and I'm now attempting to get it running on a Raspberry Pi 3 (using the > Raspbian OpenGL driver). Until now this process was pretty straightforward, > tweaking shaders and providing a render path for non-VAO hardware, but I've > now hit a crash I don't understand and can't figure out how to debug. > > Deep into program initialization, I'm setting up some vertex buffers, and > get a crash whose final line is "OpenGL.error.Error: Attempt to retrieve > context when no valid context" when calling glVertexAttribPointer. See the > full log here; my program first logs info about the hardware and the OpenGL > context it creates (via PySDL2), followed by the crash: > > https://gist.github.com/JPLeBreton/782b92872380ee6ab3b11b3954ca56cd > > The OpenGL render context is definitely present; I tried logging stuff > about it just before the glVertexAttribPointer call and as far as I can > tell it's valid right up until that point. For what it's worth that call > does appear to be the first (of many) in the program's execution. > It's not enough for the context to be present; it must also be "current" on the thread and window from which the GL command is issued. I'm not especially familiar with SDL2 and its requirements, but I should think `SDL_GL_MakeCurrent(...)` after creating your window and before calling any GL commands would do it. If this turns out not to be the issue, I'd suggest some well-placed `glGetError(...)`s. I don't know if mixing PyOpenGL with PySDL2 is okay, either—in C++, at least, SDL provides its own GL binding . . . but Mike would know. Also your repo <https://bitbucket.org/JPLeBreton/playscii> doesn't seem to match the error perfectly; I assume you made a few changes since. GL context creation is ludicrously fraught, even in the more-modern API revisions—and I've found it to be particularly buggy on *nix graphics drivers, especially Debian-based Linuxes. So. Ian |