I'm trying to get my head around the following:
I've an object that I want to be able to render with two different sets of vertex/fragment shaders, that each have their uniforms and textures, and go back and forth between those two settings. (I know in this case I could have just one shader with a uniform dictating which logic to run, but this is part of a larger things where I can't do that)
- Should I use one or two gl programs (created by
glCreateProgram()
)? - If I use two programs, is it fine to discard the one not being used, and rebuild it if need later on? Or is it too slow?
- If I use just one program:
- can I compile shaders just once at the beginning?
- when switching should I detach old shaders, attach new ones and link the program again?
- should I recompute all uniforms locations after linking?
- should I rebind array buffers after linking?
- should I do something to remove previously attached textures?