1

This is an example from: http://pyopengl.sourceforge.net/context/tutorials/shader_1.xhtml

It is creating a vbo, binging it, and running it with a shader, but somewhere along the way, something is not working properly. :\

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()

Running this sample in the normal py 2.7 interactive terminal produces the following:

OpenGLContext.scenegraph.basenodes:Unable to load node implementation for 
MMImageTexture: 'module' object has no attribute 'MMImageTexture'

In both cases, a window is produced, but there is no geometry displayed.

Is the basenodes issue indicating that MMImageTexture was a custom basenode and hasn't been created properly? I followed everything in the tut to the letter as far as I can tell. :\ So annoying...so annoying. Prease Helps Me's! :P

My system specs are win7, 4gb ram, corei5, 630m GeForce GT, using python 2.7 and python portable.

JoryRFerrell
  • 33
  • 2
  • 16
  • Ok...I looked at the module and MMImageTexture IS contained in the module. I re-ran the example, and noticed that there was another error: The interpreter can't find a valid PIL module (I installed a deprecated vers, or I installed a 32bit instead of 64...so, that should fix the error by the normal (non-portable version of python) but the portable python is making no such complaints. So apparently this is not the issue blocking the geometry from being shown. Any ideas...pls?! Take a shot in the dark. I'll try anything as long as it doesn't involve consuming battery acid, or Russian Roulette. – JoryRFerrell Jun 08 '13 at 00:27
  • Well...I checked and ran PIL. It works on it's own. I haven't figured out why python can't import it for the shader code. :\ – JoryRFerrell Jun 09 '13 at 21:45
  • glContext is apparently relying on a deprecated lib version of VRML... – JoryRFerrell Sep 19 '13 at 18:25

0 Answers0