MODERN OPENGL cannot change uniform value between glDrawArrays calls

EDIT: I just managed to fix the problem by reinstalling PyOpenGL with pip. The same program now works as expected. Thanks for your efforts.

The whole question has been rewritten and clarified.

The problem is not in the (albeit strange) approach to texture and text binding, as explained in the comments.

My actual problem is that homogeneous variables in shaders do not change their values ​​when changing (yes, changed outside the shader) between calls to glDrawArrays (). I checked that using different types of uniforms, different values ​​and checking their values ​​by rendering to a texture.

It seems that uniform values ​​are blocked as soon as glDrawArrays () is called. After that, I can only change them when I clear the color buffer.

I am ready to give generosity for any working solution. Posting any source code is not useful in my opinion, as the problem does not seem to lie in the code.

Any suggestions are complemented.

+4
source share
1 answer

You can update uniforms between drawing calls so that they are used.

Having looked at the inserted code and, as indicated in the comments, lines 167..169 should work randomly for small texIds, but you really have to 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)

, , , GL_TEXTURE0, glBindTexture() . , id .

, OpenGL, . ? .

, - OpenGL , , , .

+3

Source: https://habr.com/ru/post/1626771/


All Articles