elm-community / elm-webgl

Moved to elm-explorations/webgl

Home Page:http://package.elm-lang.org/packages/elm-explorations/webgl/latest

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is is possible to add constants to the vertex array data?

7sharp9 opened this issue · comments

I can see how you create streams of information like vertex and normal position but how do you apply constant data like using a constant vertex attribute. Maybe the intension is that you would use a uniform here?

I cant see any complex examples in this API that sheds any light on this, hence this question.

Looking at the cube.elm example:

vertexShader : Shader { attr | position:Vec3, color:Vec3 } { unif | rotation:Mat4, perspective:Mat4, camera:Mat4 } { vcolor:Vec3 }

The first record specifies that "position" and "color" are your attributes. Within your GLSL code, these are defined as attributes. Within your Elm code, your "Vertex" type needs to have these defined as fields.

If you wanted to define a new attribute, you would need to change the signature for vertexShader, and add a field to the Vertex type definition.

Oh I can understand that part, its more how would you add interleaved vertex buffers, index buffers, and things like setting a subtexture.

I guess Im just missing a few more examples to grasp the mapping from js based webgl and the elm wrapper.

It sounds like you might be looking for a finer level of control than the Elm API gives you. There is no Elm counterpart to vertex or index buffers. You pass you attributes to render, and the library decides how to arrange the data in memory.

I was hoping there would be some middle ground where vertex and index buffers could be used.

What are you trying to accomplish? If you tell us more details about your use case, we may be able to help.

It doesn't sound like there is anything actionable that is related to the original topic, so I am going to close this issue.