-
Notifications
You must be signed in to change notification settings - Fork 58
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
Buffer legacy implementation default target #340
Comments
I think you may refer to our guideline, that with globjects you won't need any If there is an additional issue, can you extend your example or provide some source code that is currently not working? For the meantime, I'll provide a short introduction on how we would use PBOs in a program. /* */ auto pbo = new Buffer();
/* */ auto vbo = new Buffer();
/* */ auto vao = new VertexArray();
/* */ auto fbo = new Framebuffer();
/* */ auto colorTex = Texture::createDefault();
/* */ auto depthTex = Texture::createDefault();
/* */ fbo->attachTexture(GL_COLOR_ATTACHMENT0, colorTex);
/* */ fbo->attachTexture(GL_DEPTH_ATTACHMENT, depthTex);
/* */ //configure rendering
/* 1 */ vao->binding(0)->setBuffer(vbo, 0, sizeof(float)*3);
/* */ //render
/* */ fbo->bind(GL_FRAMEBUFFER);
/* */ //vao->draw(...);
/* 2 */ fbo->readPixelsToBuffer(std::array<GLint, 4>{{ 0, 0, 1920, 1080 }}, GL_RGBA, GL_UNSIGNED_BYTE, pbo); The crucial lines are numbered (1 and 2). In 1, we use a globjects buffer as VBO and configure a vertex array with geometry data. In 2, the framebuffer should read pixels to a buffer used as PBO. The corresponding OpenGL calls actually bind the buffer as |
Typically, I'm trying to do this:
I can't do that with a Buffer because IMHO, the example you've given works for one case, because Check this gist for a concrete example: https://gist.github.com/roxlu/59a13936f1244de32140 |
BTW, to stay within the projects guideline, either a PBOBuffer class could be provided, either changing the target as a non-static member would work. This will not break the assumption that you don't need to bind before use, does not break the existing code either, yet allow using the other types of buffers. |
I had a look at your example. The only functions where you specify the All four accept From the current OpenGL API design I learned that a buffer is just a storage area without any usage semantics attached. Within an application, you typically have one usage scenario and thus can choose a constant per-member target. We sometimes use buffers for multiple scenarios (one time array buffer, next time transform feedback buffer, then shader storage buffer) and just choose a binding point suitable for the current use case. It may be that OpenGL drivers make assumptions on how to handle buffers for possible improvements but I don't see any problem switching the |
You probably missed the most important one, In all case, the issue is |
Yes, a |
The current code for legacy buffer implementation use a static target by default and all calls bind this static target before calling the GL function.
So, it's not possible to have both a PBO and a VBO in a program with the current buffer class.
The solution would be to set the target as a non-static member and a setTarget would change it.
Another solution would be to remove all glBindBuffer calls from the legacy implementation but that could break other people's code.
The text was updated successfully, but these errors were encountered: