elm-community / elm-webgl

Moved to elm-explorations/webgl
http://package.elm-lang.org/packages/elm-explorations/webgl/latest
BSD 3-Clause "New" or "Revised" License
95 stars 22 forks source link

Ability to use IndexTriangles #40

Closed nacmartin closed 7 years ago

nacmartin commented 7 years ago

This provides the ability to specify indices. There is a nice explanation of this technique here http://www.opengl-tutorial.org/intermediate-tutorials/tutorial-9-vbo-indexing/

Here is a gist that uses this feature: https://gist.github.com/nacmartin/fb79c2a0a0b26d9bd2c233f8f2da7564

Note that this is a change in the API. It doesn't break compatibility, as it only provides a new type for a union type, but I will understand if it is not merged.

This PR addresses #37

nacmartin commented 7 years ago

I just noticed rendering more complex meshes that the vertexes (not the indices) need to be reversed. Fixed in next commit.

w0rm commented 7 years ago

@nacmartin it also looks that doBindSetup and doBindSetupIndexed are almost identical, maybe we can have one function that takes indices.

w0rm commented 7 years ago

Another idea would be to add an Either of each case, indexed and non-indexed. This will probably change the way of creating drawables, but this change is major anyway.

w0rm commented 7 years ago

I've rebased this pull request, so we can continue discussing it here: https://github.com/elm-community/webgl/pull/8