Vertex Functions


Jump to: navigation, search
Vertex ordering for various primitive types with clockwise orientation.

This article is an overview of vertex buffers and their related functions. The vertex functions are lower level than the model functions and allow you more control over how the vertex attributes, such as color, texture coordinates, and normals, are specified. This means they can be used to achieve proper 3D multitexturing too.

In modern graphics programming, graphics primitives are rendered from vertex buffers in OpenGL and Direct3D where the data for vertices and texture coordinates are packed together inside a buffer and sent to your graphics card before being rendered by the GPU. This works best when data is static, and is rarely updated, because synchronizing the data between CPU and GPU can create a bottleneck.

The following functions can be used to create, declare primitives for, render, and delete a vertex buffer.

These functions add vertex position, diffuse, UV, and normal data.

These functions let you add the vertex data in a custom way yourself.

The vertex format functions let you specify exactly what format your vertices are in, and for instance how many texture coordinates each vertex in the primitive contains, effectively allowing you to multitexture. The vertex formats were mainly inspired by Direct3D usage declarations, but are necessary to let the native backends (e.g. OpenGL or Direct3D) know how the vertex data is laid out. They are also important for functions like vertex_data to correctly pack the data together for the GPU with the correct data types. As long as you specify the data in the same order as the vertex format, you will have no problems using the default shader or your own custom shaders, the vertex data will be correctly mapped to shader inputs.

See Also

Personal tools