-
Notifications
You must be signed in to change notification settings - Fork 853
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
RenderVboIbo: fix number of vertex indices for glDrawElements #152
base: master
Are you sure you want to change the base?
RenderVboIbo: fix number of vertex indices for glDrawElements #152
Conversation
2b55ce0
to
c235583
Compare
c235583
to
e74acdc
Compare
I am using this fix for quite some time to correctly render meshes. |
Sorry, I haven't had a chance to look properly at it. The GL_TRIANGLE_STRIP parameter should probably be an option, not hard-coded. GL_TRIANGLE_STRIP is more efficient generally than GL_TRIANGLES if you have managed to set up your indices in a way to use them. Regarding the element count, it seems like a usage issue - I need to take a look at it carefully because your change would appear to break the semantics for existing code. |
If you look at the documentation for glDrawElements (https://www.opengl.org/sdk/docs/man4/html/glDrawElements.xhtml), the second parameter is the "number of elements to be rendered". If you take MakeTriangleStripIboForVbo as an example, you would typically have only 1 'count per element' for an IBO. What would multiple counts mean, in an index buffer? |
The problem is probably my mesh, it has holes. E.g. Here is example code (with corrupted mesh): triangle_strip_example.tar.gz that compares both approaches (with and without Running:
There should be an optional flag to render meshes that have not been converted to a triangle strip. Alternative this could be determined by the |
e74acdc
to
a561efc
Compare
The amount of indices to use from the element buffer is number-of-elements times the number-of-indices.
By using GL_TRIANGLES, the index order does not need to be pre-processed.
a561efc
to
654cf84
Compare
28a1208
to
5f06939
Compare
4169749
to
1579041
Compare
This commit fixes an issue in
RenderVboIbo
where the incorrect number of indices (ibo.num_elements
) is used forglDrawElements
. The correct number of indices to use isibo.num_elements*ibo.count_per_element
.