ShaderState with GLArrayDataClient and GLArrayDataServer explaining
Please, explain next points:
1. How to use ShaderState with GLArrayDataClient ?
2. How to use ShaderState with GLArrayDataServer ?
3. When used GLArrayDataServer and when used GLArrayDataClient, differences ?
Re: ShaderState with GLArrayDataClient and GLArrayDataServer explaining
On 02/20/2015 04:17 PM, kles4enko [via jogamp] wrote:
> Please, explain next points:
> 1. How to use ShaderState with GLArrayDataClient ?
> 2. How to use ShaderState with GLArrayDataServer ?
> 3. When used GLArrayDataServer and when used GLArrayDataClient, differences ?
Please read the unit test's demo code,
e.g. RedSquareES2, GearsES2, ..
and the API documentation.
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);
ShaderState otherState = new ShaderState();
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.