-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uniform Buffer Objects in oglplus? #112
Comments
You don't specify the but try the following:
|
Adding the usage didn't work. Also, sorry if that's not the right place to ask this, but I couldn't find anything in the documentation. Of course I can do program.use() and then retrieve the id with a regular opengl call like above glGetIntegerv(GL_CURRENT_PROGRAM, &programID); It looks like this issue is related to binding operations so if there was a way to retrieve programID from oglplus::Program and bufferID from oglplus::Buffer than I could resolve this issue by using the Program and Buffer classes like normal, then getting IDs from them and passing them to raw binding instructions (glBindBufferBase and glUniformBlockBinding). |
Hmm, OK I'll try to create a working code using UBOs and have a look at this. In order to get the GL name of a wrapped object (program, shader, texture,...) You can use the |
I have a question: do you issue the GL draw calls in the same function where the code above is executed or somewhere else? |
I was issuing the draw calls in separate function, of course after binding all the buffers first.
and in my program class:
Drawing with:
This way it works fine. Sorry, but I couldn't spend more time experimenting with binding in oglplus itself and ended up using raw opengl calls. I am also really sorry for replying so late. |
Hi, sorry for the late response, I've been rather busy lately. The problem was probably caused by the fact that You created a buffer object in one function, set it up and uploaded the data,
but when the process went out of scope of that function, the UBO buffer got destroyed and the underlying GL object deleted. There are some examples using UBOs and I've tested them on several machines and everywhere they work fine. |
Are there more examples of UniformBuffers except for examples/standalone/025_bitmap_font_text.cpp ? I'm doing exactly the same but trying to update a more complex uniform block with a array of Light structs. struct Attenuation
{
float constant;
float linear;
float quadratic;
};
struct Light {
float angleInnerCone;
float angleOuterCone;
vec3 ambient;
vec3 diffuse;
vec3 specular;
vec3 position;
vec3 direction;
Attenuation attenuation;
uint lightType;
};
...
layout (std140) uniform AvailableLights {
Light light[N_LIGHTS];
}; I have in the C++ side a identical class to that struct, and a vector of that class. The rest is exactly the same, I bind the uniform buffer to the program, and use a uniform buffer object to pass the vector of Light using the same binding point but it is not working. I may end up using raw C OpenGL to do this or just standard uniforms. |
Hi, there are several other examples using UBOs: oglplus/021_overdraw.cpp HTH |
Hi again,
I have a valid, minimal OpenGL code that produces desired results:
In the vertex shader code I simply translate the vertex position by that test vector that I've got in "MatrixBlock" uniform block.
The problems start when I try to express the same thing using oglplus:
When I switch to this oglplus-based code my geometry simply doesn't get translated at all in vertex shader (as if there are only zeroes in the test vector).
The text was updated successfully, but these errors were encountered: