Re: No valid context
Ian Mallett <[email protected]> Wed, 22 Apr 2020 01:28:04 -0600
| Newsgroups | gmane.comp.python.opengl.user |
|---|---|
| Message-ID | <CAG4NV=sU+paP8-4xG9xJ9LkSmaQBDE+MGzP_8F+ov3e2eRJLtg@mail.gmail.com> |
--===============7169775225189561335== Content-Type: multipart/alternative; boundary="0000000000003ff2ca05a3dc1351" --0000000000003ff2ca05a3dc1351 Content-Type: text/plain; charset="UTF-8" On Tue, Apr 21, 2020 at 11:26 PM physkets <[email protected]> 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 --0000000000003ff2ca05a3dc1351 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr"><div dir=3D"ltr">On Tue, Apr 21, 2020 at 11:26 PM physkets= <<a href=3D"mailto:[email protected]">[email protected]</a>>= wrote:<br></div><div class=3D"gmail_quote"><blockquote class=3D"gmail_quot= e" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204)= ;padding-left:1ex"><blockquote class=3D"gmail_quote" style=3D"margin:0px 0p= x 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> Offhand, I am surprised that `glVertexAttribPointer(...)` would be the call= to fail; there are plenty of other GL calls that should have failed before= hand, 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 sug= gest to try validating the context, perhaps creating a debug context.<br></= blockquote> Can you point me to some resources that explain how I can do that?<br></blo= ckquote><div>In general, Google is your friend on this, but I'll give a= shoutout to the OpenGL Wiki.</div><div><br></div><div>PyOpenGL convenientl= y 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.</div><div><b= r></div><div>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&#= 39;s as easy as:</div><div> <p class=3D"MsoNormal" style=3D"margin:0cm 0cm 0.0001pt 40px;line-height:no= rmal;background:rgb(30,30,30) none repeat scroll 0% 0%"><font size=3D"2"><s= pan style=3D"font-family:monospace"><span style=3D"color:rgb(86,156,214)">v= oid</span><span style=3D"color:gainsboro">=C2=A0</span><span style=3D"color= :rgb(86,156,214)">__stdcall</span><span style=3D"color:gainsboro">=C2=A0cal= lback_err_gl</span><span style=3D"color:rgb(180,180,180)">(</span><span sty= le=3D"color:gainsboro">GLenum=C2=A0source</span><span style=3D"color:rgb(18= 0,180,180)">,</span><span style=3D"color:gainsboro">GLenum=C2=A0type</span>= <span style=3D"color:rgb(180,180,180)">,</span><span style=3D"color:gainsbo= ro">GLuint=C2=A0id</span><span style=3D"color:rgb(180,180,180)">,</span><sp= an style=3D"color:gainsboro">GLenum=C2=A0severity</span><span style=3D"colo= r:rgb(180,180,180)">,</span><span style=3D"color:gainsboro">GLsizei=C2=A0le= ngth</span><span style=3D"color:rgb(180,180,180)">,</span><span style=3D"co= lor:gainsboro">GLchar=C2=A0</span><span style=3D"color:rgb(86,156,214)">con= st</span><span style=3D"color:rgb(180,180,180)">*</span><span style=3D"colo= r:gainsboro">=C2=A0message</span><span style=3D"color:rgb(180,180,180)">,</= span><span style=3D"color:rgb(86,156,214)">void</span><span style=3D"color:= gainsboro">=C2=A0</span><span style=3D"color:rgb(86,156,214)">const</span><= span style=3D"color:rgb(180,180,180)">*</span><span style=3D"color:gainsbor= o">=C2=A0user_param</span><span style=3D"color:rgb(180,180,180)">)</span><s= pan style=3D"color:gainsboro">=C2=A0</span><span style=3D"color:rgb(180,180= ,180)">{</span><span style=3D"color:gainsboro"><span></span></span></span><= /font></p><div style=3D"margin-left:40px"> </div><p class=3D"MsoNormal" style=3D"margin:0cm 0cm 0.0001pt 40px;line-hei= ght:normal;background:rgb(30,30,30) none repeat scroll 0% 0%"><font size=3D= "2"><span style=3D"font-family:monospace"><span style=3D"color:gainsboro"><= span>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 </span></span><span s= tyle=3D"color:rgb(87,166,74)">//[Notice=C2=A0errors=C2=A0here=C2=A0.=C2=A0.= =C2=A0.]</span><span style=3D"color:gainsboro"><span></span></span></span><= /font></p><div style=3D"margin-left:40px"> </div><p class=3D"MsoNormal" style=3D"margin:0cm 0cm 0.0001pt 40px;line-hei= ght:normal;background:rgb(30,30,30) none repeat scroll 0% 0%"><font size=3D= "2"><span style=3D"font-family:monospace"><span style=3D"color:rgb(180,180,= 180)">}</span><span style=3D"color:gainsboro"><span></span></span></span></= font></p><div style=3D"margin-left:40px"> </div><p class=3D"MsoNormal" style=3D"margin:0cm 0cm 0.0001pt 40px;line-hei= ght:normal;background:rgb(30,30,30) none repeat scroll 0% 0%"><font size=3D= "2"><span style=3D"font-family:monospace"><span style=3D"color:rgb(86,156,2= 14)">int</span><span style=3D"color:gainsboro">=C2=A0main</span><span style= =3D"color:rgb(180,180,180)">(</span><span style=3D"color:rgb(86,156,214)">i= nt</span><span style=3D"color:gainsboro">=C2=A0argc</span><span style=3D"co= lor:rgb(180,180,180)">,</span><span style=3D"color:gainsboro">=C2=A0</span>= <span style=3D"color:rgb(86,156,214)">char</span><span style=3D"color:rgb(1= 80,180,180)">*</span><span style=3D"color:gainsboro">=C2=A0argv</span><span= style=3D"color:rgb(180,180,180)">[])</span><span style=3D"color:gainsboro"= >=C2=A0</span><span style=3D"color:rgb(180,180,180)">{</span><span style=3D= "color:gainsboro"><span></span></span></span></font></p><div style=3D"margi= n-left:40px"> </div><p class=3D"MsoNormal" style=3D"margin:0cm 0cm 0.0001pt 40px;line-hei= ght:normal;background:rgb(30,30,30) none repeat scroll 0% 0%"><font size=3D= "2"><span style=3D"font-family:monospace"><span style=3D"color:gainsboro"><= span>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 </span></span><span s= tyle=3D"color:rgb(87,166,74)">//[...]</span><span style=3D"color:gainsboro"= ><span></span></span></span></font></p><div style=3D"margin-left:40px"> </div><p class=3D"MsoNormal" style=3D"margin:0cm 0cm 0.0001pt 40px;line-hei= ght:normal;background:rgb(30,30,30) none repeat scroll 0% 0%"><font size=3D= "2"><span style=3D"font-family:monospace"><span style=3D"color:gainsboro"><= span>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 </span>glfwWindowHint= </span><span style=3D"color:rgb(180,180,180)">(</span><span style=3D"color:= gainsboro">GLFW_OPENGL_DEBUG_CONTEXT</span><span style=3D"color:rgb(180,180= ,180)">,</span><span style=3D"color:gainsboro">=C2=A0GLFW_TRUE</span><span = style=3D"color:rgb(180,180,180)">);</span><span style=3D"color:gainsboro"><= span></span></span></span></font></p><div style=3D"margin-left:40px"> </div><p class=3D"MsoNormal" style=3D"margin:0cm 0cm 0.0001pt 40px;line-hei= ght:normal;background:rgb(30,30,30) none repeat scroll 0% 0%"><font size=3D= "2"><span style=3D"font-family:monospace"><span style=3D"color:gainsboro"><= span>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 </span>glDebugMessage= Callback</span><span style=3D"color:rgb(180,180,180)">(</span><span style= =3D"color:gainsboro">callback_err_gl</span><span style=3D"color:rgb(180,180= ,180)">,</span><span style=3D"color:rgb(86,156,214)">nullptr</span><span st= yle=3D"color:rgb(180,180,180)">);</span><span style=3D"color:gainsboro"><sp= an></span></span></span></font></p><div style=3D"margin-left:40px"> </div><p class=3D"MsoNormal" style=3D"margin:0cm 0cm 0.0001pt 40px;line-hei= ght:normal;background:rgb(30,30,30) none repeat scroll 0% 0%"><font size=3D= "2"><span style=3D"font-family:monospace"><span style=3D"color:gainsboro"><= span>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 </span></span><span s= tyle=3D"color:rgb(87,166,74)">//[...]</span><span style=3D"color:gainsboro"= ><span></span></span></span></font></p><div style=3D"margin-left:40px"> </div><p class=3D"MsoNormal" style=3D"margin:0cm 0cm 0.0001pt 40px;line-hei= ght:normal;background:rgb(30,30,30) none repeat scroll 0% 0%"><font size=3D= "2"><span style=3D"font-family:monospace"><span style=3D"color:gainsboro"><= span>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 </span></span><span s= tyle=3D"color:rgb(216,160,223)">return</span><span style=3D"color:gainsboro= ">=C2=A0</span><span style=3D"color:rgb(181,206,168)">0</span><span style= =3D"color:rgb(180,180,180)">;</span><span style=3D"color:gainsboro"><span><= /span></span></span></font></p><div style=3D"margin-left:40px"> </div><p class=3D"MsoNormal" style=3D"margin:0cm 0cm 0.0001pt 40px;line-hei= ght:normal;background:rgb(30,30,30) none repeat scroll 0% 0%;font-size:11pt= ;font-family:"Calibri",sans-serif"><font size=3D"2"><span style= =3D"font-family:monospace"><span style=3D"color:rgb(180,180,180)">}</span><= /span></font><span style=3D"font-size:8.5pt;font-family:"DejaVu Sans M= ono";color:gainsboro"><span></span></span></p> <p class=3D"MsoNormal" style=3D"margin:0cm 0cm 8pt;line-height:107%;font-si= ze:11pt;font-family:"Calibri",sans-serif"><span>=C2=A0</span></p>= <p class=3D"MsoNormal" style=3D"margin:0cm 0cm 8pt;line-height:107%;font-si= ze:11pt;font-family:"Calibri",sans-serif"><span></span></p></div>= <div>This should be a reasonable guide as you search for the Python binding= 's equivalent.<br></div><div>=C2=A0 <br></div><blockquote class=3D"gmai= l_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,20= 4,204);padding-left:1ex"><blockquote class=3D"gmail_quote" style=3D"margin:= 0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> What happens if you just try drawing an empty window without the problemati= c setup code?<br></blockquote> It works if I simply set a single colour using `glClearColor()`. There is n= o crash, and it displays a window with the right color.<br></blockquote><di= v>This suggests to me that the OpenGL context is working, and that there= 9;s some peculiarity with the <span class=3D"gmail-im">`glVertexAttribPointer(...)` function itself. I ha= ve no idea what that might be, though. It working for me on a different pla= tform, and other GL calls succeeding </span>suggests a possible bug.<br></d= iv><div><br></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px= 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><blockq= uote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1p= x solid rgb(204,204,204);padding-left:1ex"> Also, why did you comment the context creation hints?<br></blockquote> 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?<br></blockquote><div>I do= n'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= 9;ll get back whatever the driver wants to give you. This is often the high= est OpenGL version your hardware supports (which is not necessarily a good = thing, mind), but it's sometimes not. The point is, you want to <i>know= </i> what you're getting. Specifying the parameters is a good way to do= that.</div><div><br></div><div>You might also try seeing if you can reprod= uce the problem in <a href=3D"https://renderdoc.org/">RenderDoc</a>? (Altho= ugh IDK how well it plays with Python . . .)<br></div><div><br></div><div>I= an<br></div></div></div> --0000000000003ff2ca05a3dc1351-- --===============7169775225189561335== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline --===============7169775225189561335== 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 --===============7169775225189561335==--