vertex_update_buffer_from_vertex

This function updates the contents of a vertex buffer using (part of) the contents of another vertex buffer.

IMPORTANT You cannot pass frozen vertex buffers into this function.

Usage Notes

 

Syntax:

vertex_update_buffer_from_vertex(dest_vbuff, dest_vert, src_vbuff[, src_vert, src_vert_num]);

ArgumentTypeDescription
dest_vbuffVertex BufferThe destination vertex buffer to copy vertices to
dest_vertRealThe index of the first vertex in the destination vertex buffer to copy to
src_vbuffVertex BufferThe source vertex buffer to copy vertices from
src_vertRealOPTIONAL The index of the first vertex in the source vertex buffer to copy
src_vert_numRealOPTIONAL The number of vertices to copy

 

Returns:

N/A

 

Example:

Create Event

vertex_format_begin();
vertex_format_add_position_3d();     // Three buffer_f32 values
vertex_format_add_color();           // Four buffer_u8 values
vertex_format_add_texcoord();        // Two buffer_f32 values
vertex_format = vertex_format_end();

vb = vertex_create_buffer();
vertex_begin(vb, vertex_format);
vertex_position_3d(vb, 100, 100, 0);
vertex_color(vb, c_lime, 1);
vertex_texcoord(vb, 0, 0);
vertex_position_3d(vb, 200, 100, 0);
vertex_color(vb, c_lime, 1);
vertex_texcoord(vb, 1, 0);
vertex_position_3d(vb, 200, 200, 0);
vertex_color(vb, c_lime, 1);
vertex_texcoord(vb, 1, 1);
vertex_end(vb);

vb2 = vertex_create_buffer();

vertex_update_buffer_from_vertex(vb2, 0, vb);

Draw Event

vertex_submit(vb2, pr_trianglelist, -1);

The above code shows how to duplicate a vertex buffer's contents to another, newly created vertex buffer.

First, in the Create event, a vertex format identical to the Passthrough Vertex Format is created and stored in a variable vertex_format. Then, a new vertex buffer is created and filled with three vertices, according to the vertex format. After that, a second vertex buffer vb2 is created and updated with the vertex data in vb using vertex_update_buffer_from_vertex. After the function call, the vertex data in vb2 will be identical to that in vb.

Finally, in the Draw event, vb2 is drawn using vertex_submit.