Skip to content Skip to sidebar Skip to footer

Modern Opengl Can't Change Uniform Value Beetween Gldrawarrays Calls

EDIT: I just managed to fix the issue by reinstalling PyOpenGL with pip. The same program now works as expected. Thanks for your efforts. The entire question was rewritten and clar

Solution 1:

You can update uniforms between draw calls, that's how they are meant to be used.

Looking at the pasted code, and as pointed out in the comments, lines 167..169 should work by chance for small texIds, but you should really change

glUniform1i(textureUnif, model.texId)
glActiveTexture(GL_TEXTURE0+model.texId)
glBindTexture(GL_TEXTURE_2D, model.texId)

to

glUniform1i(textureUnif, 0)
glActiveTexture(GL_TEXTURE0)
glBindTexture(GL_TEXTURE_2D, model.texId)

though since all you use is GL_TEXTURE0, you only really need the glBindTexture() call on each loop iteration. The texture uniform should contain the texture unit, the shader has no concept of texture id in this case.

Of course, this being OpenGL, errors are often hard to find. What are you actually trying to draw? Screenshots would be helpful.

It might well be that something else in the OpenGL state results in the uniform update not showing up on the screen, for example depth testing is one common culprit.

Post a Comment for "Modern Opengl Can't Change Uniform Value Beetween Gldrawarrays Calls"