Module OgamlGraphics.VertexArray
High-level wrapper around OpenGL vertex arraysSubmodules
VertexSource | Vertex source |
SimpleVertex | Simple pre-initialized structure |
Vertex | Creation and manipulation of vertices |
This modules provides a high-level and safe access to openGL vertex arrays. Vertex arrays are used to store vertices on the GPU and can be used to render 3D models.
The idea behind this module is to provide a safe way to create vertex arrays in 3 steps:
- First, you will need to create a vertex structure. This is done using the function Vertex.make. You can add attributes to your structure V by calling V.attribute and giving them a name and type.
The attributes will be passed to GLSL programs under the provided name. Once you have added some attributes to your structure, you need to seal it using V.seal.
Be careful as once a structure is sealed, you cannot add attributes to it anymore. You can then create vertices that will contain the attributes of your structure using V.create.
Alternatively, you can use the module SimpleVertex which is a predefined vertex structure containing a position, texture coordinates, a color, and a normal.
- Secondly, you will need to create a source which contains vertices. This is done using VertexSource.empty. The module VertexSource provides several useful functions to manipulate sources of vertices.
- Finally, you can create a vertex array using one of the two functions static
or dynamic
.
See : OgamlGraphics.VertexArray.Source
See : OgamlGraphics.VertexArray.Source
rebuild array src offset
rebuilds array
starting from the vertex at position offset
using src
.The vertex array is modified in-place and is resized as needed.
See : OgamlGraphics.VertexArray.Source
start
of length length
of a vertex array on a window using the given parameters.start
defaults to 0if
length
is not provided, then the whole vertex array (starting from start
) is drawnuniform
should provide the uniforms required by program
(defaults to empty)parameters
defaults to DrawParameter.make ()
mode
defaults to DrawMode.Triangles
See : OgamlGraphics.IndexArray
See : OgamlGraphics.Window
See : OgamlGraphics.Program
See : OgamlGraphics.Uniform
See : OgamlGraphics.DrawParameter
See : OgamlGraphics.DrawMode