• Advertisement
Sign in to follow this  

PyOpenGl Uniform (GLSL) problem

This topic is 3476 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, i'm trying to set a uniform for a GLSL program. The offending code is below:
print "Program: "+str(self.program)
loc = glGetUniformLocation(self.program,'sing')
print "sing: "+str(glGetUniformLocation(self.program,'sing'))

glUniform1f(loc,1.0)
This gives the following output: Program: 1 sing: 0 (would be -1 if not a valid uniform?) Traceback (most recent call last): line 145, in present glUniform1f(loc,1.0) File "c:\python25\lib\site-packages\PyOpenGL-3.0.0b3-py2.5.egg\OpenGL\platform\baseplatform.py", line 261, in __call__ return self( *args, **named ) File "c:\python25\lib\site-packages\PyOpenGL-3.0.0b3-py2.5.egg\OpenGL\error.py", line 194, in glCheckError baseOperation = baseOperation, GLError: GLError( err = 1282, description = 'invalid operation', baseOperation = glUniform1f, cArguments = (0, 1.0) ) Surely these are valid arguments? I feel I must be missing something more fundamental here. The vertex shader:
varying vec3 lightDir;
uniform float sing;
	
varying float intensity;
	
void main()
{
       lightDir = vec3(0.0, sing, 0.0);
       intensity = dot(lightDir,gl_Normal);
		
       gl_Position = ftransform();
} 

Share this post


Link to post
Share on other sites
Advertisement
Ok, a more general question:

In what situations is it possible for glUniform1f to casue an error/exception?
(All other unifrom setting eg. 3f, 3vf, 2i also fails)

Share this post


Link to post
Share on other sites
http://www.opengl.org/sdk/docs/man/xhtml/glUniform.xml

There's the errors generated by glUniform*

Share this post


Link to post
Share on other sites
Quote:
Original post by HuntsMan
http://www.opengl.org/sdk/docs/man/xhtml/glUniform.xml

There's the errors generated by glUniform*


Thank you. The problem turned out to be that I needed to call glUseProgram before glUniform. I had assumed that since glGetUniformLocation takes a program ID as an argument, it would return a "global" location that could be used without changing the active program,

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement