What state is lost / reset after glUseProgram?

This is due to the program for switching shaders in WebGL , but I wanted to ask a question again, now I have a clearer idea of ​​the problem, and what I want to ask.

I try to switch between different shader programs, but I can’t get things to display correctly when switching a shader program in the same render. I think the state is lost or reset after the call glUseProgram().

What state is lost or reset after this call? In other words, what do I need to bind again after glUseProgram()?

+5
source share
1 answer

It is possible that your vertex arrays and vertex attribute arrays have different locations in other programs (for example this.locATex), the same problems can occur when linking textures and sampler uniforms, for example. You need to request these attributes and the “texture unit uniform”, which you need to initialize yourself, for each program individually and bind your arrays and textures, respectively, before drawing. Further “at the other end” bindings can also break, for example, locations of fragment data. But I suggest, you provided some more codes before new problems were invented :-).

0
source

All Articles