vertex_submit

This function submits the contents of a vertex buffer to the graphics pipeline for use with a shader.

You supply the vertex buffer, the base primitive type (see the constants below) and the texture to be used. The base primitive type is only used for assigning the order in which the vertices that you stored in the buffer are drawn and connected, but the actual data used for each of the vertices will be that which you defined when creating the vertex buffer.

WARNING When using a surface as the texture (returned by surface_get_texture), you should make sure that the surface itself exists (surface_exists).

Usage Notes

For a visual example of the different base primitives available, see the image below: 

The different primitive types

Primitive Type Constant
ConstantDescription
pr_pointlistA point list - A point is drawn for every vertex.
pr_linelistA line list - A line is drawn between the first and the second vertex, between the third and fourth vertex, etc.
pr_linestripA line strip - A line is drawn between the first and the second vertex, between the second and the third vertex, the third and the fourth vertex, etc.
pr_trianglelistA triangle list - A triangle is drawn for the first, second and third vertex, then for the fourth, fifth and sixth vertex, etc.
pr_trianglestripA triangle strip - A triangle is drawn for the first, second and third vertex, then for the second, third and fourth vertex, etc.
pr_trianglefanA triangle fan - Every two vertices connect to the first vertex to make a triangle.

WARNING This primitive type is not natively supported on some platforms and there could be a performance hit if you use it.

 

Syntax:

vertex_submit(buffer, primitive, texture);

ArgumentTypeDescription
bufferVertex BufferThe vertex buffer to use.
primitivePrimitive Type ConstantThe primitive base type.
textureTextureThe texture to use (or -1 for no texture).

 

Returns:

N/A

 

Example:

shader_set(shader_prim);
vertex_submit(buff, pr_trianglelist, sprite_get_texture(sprite_index, 0));
shader_reset();

The above code submits the vertex buffer in the variable buff for drawing with the shader shader_prim, using a triangle list as the base primitive and the texture of the sprite for the instance running the code.