Note that there are some explanatory texts on larger screens.

plurals
  1. POPyOpenGL - A tutorial about shaders that doesn't work
    text
    copied!<p>This is an example from: <a href="http://pyopengl.sourceforge.net/context/tutorials/shader_1.xhtml" rel="nofollow noreferrer">http://pyopengl.sourceforge.net/context/tutorials/shader_1.xhtml</a></p> <p>It is creating a vbo, binging it, and running it with a shader, but somewhere along the way, it is not working properly. I searched a lot on the internet and didn't find any precise answers for my problem (the best pick I had was on this topic on StackOverflow : <a href="https://stackoverflow.com/questions/16945500/why-is-this-tutorial-example-of-a-shader-not-displaying-any-geometry-as-it-is-su">Why is this tutorial example of a shader not displaying any geometry as it is supposed to?</a> but even if the author was working on the same tutorial, he didn't have the same problem and solved it by himself...)</p> <pre><code>from OpenGLContext import testingcontext BaseContext = testingcontext.getInteractive() from OpenGL.GL import * from OpenGL.arrays import vbo from OpenGLContext.arrays import * from OpenGL.GL import shaders class TestContext( BaseContext ): def OnInit( self ): VERTEX_SHADER = shaders.compileShader("""#version 330 void main() { gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; }""", GL_VERTEX_SHADER) FRAGMENT_SHADER = shaders.compileShader("""#version 330 void main() { gl_FragColor = vec4( 0, 3, 6, 1 ); }""", GL_FRAGMENT_SHADER) self.shader = shaders.compileProgram(VERTEX_SHADER,FRAGMENT_SHADER) self.vbo = vbo.VBO( array( [ [ 0, 1, 0 ], [ -1,-1, 0 ], [ 1,-1, 0 ], [ 2,-1, 0 ], [ 4,-1, 0 ], [ 4, 1, 0 ], [ 2,-1, 0 ], [ 4, 1, 0 ], [ 2, 1, 0 ], ],'f') ) def Render( self, mode): shaders.glUseProgram(self.shader) try: self.vbo.bind() try: glEnableClientState(GL_VERTEX_ARRAY); glVertexPointerf(self.vbo) glDrawArrays(GL_TRIANGLES, 0, 9) finally: self.vbo.unbind() glDisableClientState(GL_VERTEX_ARRAY); finally: shaders.glUseProgram(0) if __name__ == "__main__": TestContext.ContextMainLoop() </code></pre> <p>Running this program from the windows command-line give me that error:</p> <pre><code>Traceback(most recent call last): File "openGL-test.py', line 70, in &lt;module&gt; TestContext.ContextMainLoop() File "C:\Python27\lib\site-package\openglcontext-2.2.0a2-py2.7.egg\OpenGLContext\glutcontext.py", line 159, in ContextMainLoop render = cls( *args, **named) File "C:\Python27\lib\site-package\openglcontext-2.2.0a2-py2.7.egg\OpenGLContext\glutcontext.py", line 35, in __init__ glutInitDisplayMode( self.DISPLAYMODE ) File "C:\Python27\lib\site-package\OpenGL\platform\baseplatform.py", line 384, in __call__ self.__name__, self.__name__, OpenGL.error.NullFunctionError: Attempt to call an undefined function glutInitDisplayMode, check for bool(glutInitDisplayMode) before calling </code></pre> <p>Any idea of what that means ? I have to precise, I began to learn Python two months ago, so I'm pretty newbie, even if I had to work it a lot for my internship period. (ho, and that's my first question on StackOverflow :)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload