Re: ShaderState with GLArrayDataClient and GLArrayDataServer explaining
Posted by jedwards1211 on Apr 25, 2017; 3:29am
URL: https://forum.jogamp.org/ShaderState-with-GLArrayDataClient-and-GLArrayDataServer-explaining-tp4034042p4037893.html
Sven,
I read through RedSquareES2.
The main thing that's not clear to me about the design is that you can associate buffers, uniforms, etc. with ShaderState, yet you still have to call st.uniform() in your draw code, as well as enableBuffer() on each buffer. ShaderState already contains all the bindings, so couldn't it perform all of those things in one fell swoop?
Also, those demos don't really demonstrate data sharing as far as I can tell. To share a vertex array with a different ShaderState and different variable name, I assume I do something like this?
GLArrayDataServer data = ...
GLArrayDataServer dataCopy = new GLArrayDataServer(data);
dataCopy.setName("otherName");
ShaderState otherState = new ShaderState();
otherState.ownAttribute(dataCopy, true);
Also, this brings up a seeming problem -- if `otherState` destroys `dataCopy`, won't that break `data`, since it has the same `vboName` as `dataCopy`?
Storing the shader variable name with GLArrayData, GLUniformData, etc. is what I'm most skeptical of about the design...
Another thing that's not obvious from the examples is why I would use attachShaderProgram() to switch programs on the fly instead of just creating another ShaderState for the other program.