Vertex Functions: Difference between revisions

From ENIGMA
Jump to navigation Jump to search
No edit summary
mNo edit summary
 
(13 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[Image:Primitivetypes.png|thumb|300px|Vertex ordering for various primitive types with clockwise orientation.]]
[[Image:Primitivetypes.png|thumb|300px|Vertex ordering for various primitive types with clockwise orientation.]]
This article is an overview of the vertex related functions. The vertex functions can be used to specify custom vertex formats that can allow multitexturing. In modern graphics programming, primitives and models are rendered from vertex buffers in [[OpenGL]] and [[DirectX|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, as sending data to the GPU is slow. Constantly sending data can interfere with the graphics pipeline. In addition, modern graphics cards are better optimized for drawing triangles. The OpenGL 1 graphics system does not utilize this behavior as older graphics cards may not support this, however [[OpenGL|OpenGL 3]] and [[DirectX|Direct3D 9]] and later graphics systems do utilize this for models.
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 [[DirectX|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.
* [[vertex_create_buffer]]
* [[vertex_create_buffer]]
* [[vertex_create_buffer_ext]]
* [[vertex_create_buffer_ext]]
Line 9: Line 12:
* [[vertex_end]]
* [[vertex_end]]
* [[vertex_freeze]]
* [[vertex_freeze]]
* [[vertex_clear]]
* [[vertex_get_buffer_size]]
* [[vertex_get_number]]
* [[vertex_submit]]
* [[vertex_submit]]
* [[vertex_delete]]


These functions add vertex position, diffuse, UV, and normal data.
These functions add vertex position, diffuse, UV, and normal data.
Line 16: Line 21:
* [[vertex_position_3d]]
* [[vertex_position_3d]]
* [[vertex_normal]]
* [[vertex_normal]]
* [[vertex_colour]]
* [[vertex_color]]
* [[vertex_rgba]]
* [[vertex_argb]]
* [[vertex_texcoord]]
* [[vertex_texcoord]]


These functions let you add the vertex data in a custom way yourself.
These functions let you add the vertex data in a custom way yourself.
* [[vertex_data]]
* [[vertex_float1]]
* [[vertex_float1]]
* [[vertex_float2]]
* [[vertex_float2]]
Line 27: Line 33:
* [[vertex_ubyte4]]
* [[vertex_ubyte4]]


The vertex format functions let you specify exactly what format your model is in, and for instance how many texture coordinates each vertice in the primitive contains, effectively allowing you to multitexture.
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.
* [[vertex_format_begin]]
* [[vertex_format_begin]]
* [[vertex_format_add_colour]]
* [[vertex_format_add_color]]
* [[vertex_format_add_position]]
* [[vertex_format_add_position]]
* [[vertex_format_add_position_3d]]
* [[vertex_format_add_position_3d]]
Line 36: Line 42:
* [[vertex_format_add_custom]]
* [[vertex_format_add_custom]]
* [[vertex_format_end]]
* [[vertex_format_end]]
* [[vertex_format_delete]]


== See Also ==
== See Also ==
* [[Vertex constants]]
* [[Vertex constants]]

Latest revision as of 00:20, 18 June 2018

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