[PyOpenGL-Users] using glGetUniformLocation
Brought to you by:
mcfletch
From: Ben De L. <bd...@gm...> - 2009-08-26 16:58:05
|
I have this simple test program distilled from a more complex code base, I am using glGetUniformLocation incorrectly but I am not sure what the correct syntax is. Any hits are appreciated! from OpenGL import GL from OpenGL import GLU from OpenGL import GLUT import sys simpleShader = ''' #version 140 uniform int test; void main() { ; } ''' def init(): # select clearing color GL.glClearColor (0.0, 0.0, 0.0, 0.0) # initialize viewing values GL.glMatrixMode(GL.GL_PROJECTION) GL.glLoadIdentity() GL.glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0) shader = GL.glCreateShader(GL.GL_VERTEX_SHADER) GL.glShaderSource(shader, simpleShader) GL.glCompileShader(shader) print GL.glGetShaderInfoLog(shader) program = GL.glCreateProgram() GL.glAttachShader(program, shader) GL.glLinkProgram(program) loc = GL.glGetUniformLocation(program, "test") print loc def display(): GL.glClear (GL.GL_COLOR_BUFFER_BIT) GL.glColor3f (1.0, 1.0, 1.0) GL.glBegin(GL.GL_POLYGON) GL.glVertex3f (0.25, 0.25, 0.0) GL.glVertex3f (0.75, 0.25, 0.0) GL.glVertex3f (0.75, 0.75, 0.0) GL.glVertex3f (0.25, 0.75, 0.0) GL.glEnd() GL.glFlush (); GLUT.glutInit(sys.argv) GLUT.glutInitDisplayMode(GLUT.GLUT_SINGLE | GLUT.GLUT_RGB) GLUT.glutInitWindowSize(250, 250) GLUT.glutInitWindowPosition(100, 100) GLUT.glutCreateWindow("hello") init() GLUT.glutDisplayFunc(display) GLUT.glutMainLoop() |