Skip to content
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

Use DrawElement with a IntBuffer (transformed in ByteBuffer) for Indexes of element #72

Closed
Zifiv opened this issue Apr 18, 2016 · 3 comments
Assignees
Labels

Comments

@Zifiv
Copy link
Contributor

Zifiv commented Apr 18, 2016

I think we can increase the performance during the render loop.

Actually when we create a cube, for exemple, we need generate and display 36 vertices, 36 texture coordinates, 36 colors and 36 normals, but in fact for make a cube we just need to generate and display 8 of each.

VBO can display objects with a list of unique vertices, a list of unique texture coordinates, a list of unique color, a list of unique normals and a list of unique indexes.

For exemple, for a cube we have :

  • 8 vertices, 8 texture coordinates, 8 colors, and 8 normals
  • 36 indexes of render

It's better for memory, and better for the render loop.

What do you think about it ?

@Zifiv Zifiv changed the title Use DrawElement with a IntBuffer (transformed to ByteBuffer) for Indexes of element Use DrawElement with a IntBuffer (transformed in ByteBuffer) for Indexes of element Apr 18, 2016
@sriharshachilakapati sriharshachilakapati self-assigned this Apr 19, 2016
@sriharshachilakapati
Copy link
Owner

This is possible, but might be problematic. Assume the case of coloured cube, with one color per face, you can't have indices since there will not be unique colours per vertex. The same happens with textured models too.

@Zifiv
Copy link
Contributor Author

Zifiv commented Apr 19, 2016

Maybe use a state for the Batcher who will be true when the batcher is in DrawElement mode with indexes.

And add new function index(int p1Index) like the vertex(float p1X, float p2Y, float p3Z). I've tried it the last night (with fast and not really brainned code), but it was not working...

I will try with more reflexion this week.

@sriharshachilakapati
Copy link
Owner

Closing this for now, as there are more challenges than the advantages this provides.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants