Re: Good news
Posted by adi on Sep 06, 2014; 1:03pm
URL: https://forum.jogamp.org/Good-news-tp4033046p4033074.html
I write only in java.
I have 3 uniform blocks:
layout (shared,binding=0) uniform GlobalDatas {
dmat4 projectionsMatrix;
};
layout (shared,binding=1) uniform GlobalDatasDynamic {
dvec3 cameraPosition;
};
layout (shared,binding=2) uniform LightDatas {
vec4 lightPosition;
vec4 specular;
vec4 lightColor;
float ambientCoefficient;
float constantAttenuation;
float linearAttenuation;
float quadraticAttenuation;
float spotCutoff;
float spotCosCutoff;
float shininess;
vec3 spotDirection;
} ;
The datas in the buffers is send with this commands:
gl.glGenBuffers( uboBuffer.length, uboBuffer, 0);
gl.glBindBufferRange(GL4.GL_UNIFORM_BUFFER, 0, uboBuffer[0], 0, 128);
gl.glBufferData(GL4.GL_UNIFORM_BUFFER, 128 , projectionsBuffer, GL4.GL_STATIC_DRAW);
( projectionsBuffer is a DoubleBuffer)
gl.glBindBufferRange(GL4.GL_UNIFORM_BUFFER, BINDING_POINT_1, uboBuffer[1], 0, 16);
gl.glBufferData(GL4.GL_UNIFORM_BUFFER, 16 , null, GL4.GL_STREAM_DRAW);
(room for dynamic vector )
gl.glBindBufferRange(GL4.GL_UNIFORM_BUFFER, BINDING_POINT_2, uboBuffer[2], 0, size);
gl.glBufferData(GL4.GL_UNIFORM_BUFFER, size, storage, GL4.GL_STATIC_DRAW);
(storage is a ByteBuffer)
Only the values from the first and second block (from the projectionsBuffer and the dynamic vector)
are correct reachable and correct in the shader.
The datas in the third buffer are not correct, all set to null,
how a fresh created buffer.