Re: "Attempt to retrieve context when no valid context" when calling glVertexAttribPointer in GL ES 2

Ian Mallett <[email protected]> Tue, 2 Jan 2018 18:37:35 -0700
Newsgroups gmane.comp.python.opengl.user
Message-ID <CAG4NV=s-xmJJK45ci=0HY_0DFmP4T3FJkkdFnHZrxMCyS3-+wA@mail.gmail.com>
--===============0039018863191795878==
Content-Type: multipart/alternative; boundary="94eb2c148dd66ea6410561d5439a"

--94eb2c148dd66ea6410561d5439a
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

On Tue, Jan 2, 2018 at 12:33 AM, JP LeBreton <[email protected]> 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 straightforwar=
d,
> 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 th=
e
> full log here; my program first logs info about the hardware and the Open=
GL
> 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.
>

=E2=80=8BIt's not enough for the context to be present; it must also be "cu=
rrent"
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=E2=80=94in 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=E2=80=94and I've found it to be particularly buggy on *nix graphi=
cs
drivers, especially Debian-based Linuxes. So.

Ian

--94eb2c148dd66ea6410561d5439a
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_extra">On Tue, Jan 2, 2018 at 12:33 AM=
, JP LeBreton <span dir=3D"ltr">&lt;<a href=3D"mailto:[email protected]"=
 target=3D"_blank">[email protected]</a>&gt;</span> wrote:<br><div class=
=3D"gmail_quote"><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px =
0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir=
=3D"auto"><div dir=3D"ltr">I have a program (<a href=3D"http://vectorpoem.c=
om/playscii" target=3D"_blank">http://vectorpoem.com/playsci<wbr>i</a>) tha=
t&#39;s been running nicely with PyOpenGL on x86 Linux, macOS, and Windows =
for a few years now, and I&#39;m now attempting to get it running on a Rasp=
berry Pi 3 (using the Raspbian OpenGL driver). Until now this process was p=
retty straightforward, tweaking shaders and providing a render path for non=
-VAO hardware, but I&#39;ve now hit a crash I don&#39;t understand and can&=
#39;t figure out how to debug.<br><br>Deep into program initialization, I&#=
39;m setting up some vertex buffers, and get a crash whose final line is &q=
uot;OpenGL.error.Error: Attempt to retrieve context when no valid context&q=
uot; when calling glVertexAttribPointer. See the full log here; my program =
first logs info about the hardware and the OpenGL context it creates (via P=
ySDL2), followed by the crash:<br><br><a href=3D"https://gist.github.com/JP=
LeBreton/782b92872380ee6ab3b11b3954ca56cd" target=3D"_blank">https://gist.g=
ithub.com/JPLeBr<wbr>eton/782b92872380ee6ab3b11b395<wbr>4ca56cd</a><br><br>=
The OpenGL render context is definitely present; I tried logging stuff abou=
t it just before the glVertexAttribPointer call and as far as I can tell it=
&#39;s valid right up until that point. For what it&#39;s worth that call d=
oes appear to be the first (of many) in the program&#39;s execution.<br></d=
iv></div></blockquote><div><br></div><div><div style=3D"font-family:times n=
ew roman,serif" class=3D"gmail_default">=E2=80=8BIt&#39;s not enough for th=
e context to be present; it must also be &quot;current&quot; on the thread =
and window from which the GL command is issued. I&#39;m not especially fami=
liar 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.</div><div style=3D"font-family:times new roman,serif" class=3D"gmail=
_default"><br></div><div style=3D"font-family:times new roman,serif" class=
=3D"gmail_default">If this turns out not to be the issue, I&#39;d suggest s=
ome well-placed `glGetError(...)`s. I don&#39;t know if mixing PyOpenGL wit=
h PySDL2 is okay, either=E2=80=94in C++, at=20
least, SDL provides its own GL binding . . . but Mike would know. Also <a h=
ref=3D"https://bitbucket.org/JPLeBreton/playscii">your repo</a> doesn&#39;t=
 seem to match the error perfectly; I assume you made a few changes since.<=
br></div><div style=3D"font-family:times new roman,serif" class=3D"gmail_de=
fault"><br></div><div style=3D"font-family:times new roman,serif" class=3D"=
gmail_default">GL context creation is ludicrously fraught, even in the more=
-modern API revisions=E2=80=94and I&#39;ve found it to be particularly bugg=
y on *nix graphics drivers, especially Debian-based Linuxes. So.<br></div><=
div style=3D"font-family:times new roman,serif" class=3D"gmail_default"><br=
></div><div style=3D"font-family:times new roman,serif" class=3D"gmail_defa=
ult">Ian<br></div></div></div></div></div>

--94eb2c148dd66ea6410561d5439a--


--===============0039018863191795878==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
--===============0039018863191795878==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
PyOpenGL Homepage
http://pyopengl.sourceforge.net
_______________________________________________
PyOpenGL-Users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pyopengl-users

--===============0039018863191795878==--