#pragma once #include #include "vertexstructure.h" #include /*! \file vertexbuffer.h \brief Provides functions for setting up and using vertex-buffers. */ #ifdef __cplusplus extern "C" { #endif typedef struct kinc_g5_vertex_buffer { VertexBuffer5Impl impl; } kinc_g5_vertex_buffer_t; /// /// Allocate and initialize a vertex-buffer. /// /// The buffer to initialize /// The number of vertices in the buffer /// The structure of the buffer /// If true, the vertex-buffer will reside in gpu-memory which will make it slower to update but faster to use /// The step-rate for instanced-rendering - use 0 if instanced-rendering will not be used with this buffer KINC_FUNC void kinc_g5_vertex_buffer_init(kinc_g5_vertex_buffer_t *buffer, int count, kinc_g5_vertex_structure_t *structure, bool gpu_memory, int instance_data_step_rate); /// /// Destroys a vertex-buffer. /// /// The buffer to destroy KINC_FUNC void kinc_g5_vertex_buffer_destroy(kinc_g5_vertex_buffer_t *buffer); /// /// Locks all of a vertex-buffer to modify its contents. /// /// The buffer to lock /// The contents of the buffer KINC_FUNC float *kinc_g5_vertex_buffer_lock_all(kinc_g5_vertex_buffer_t *buffer); /// /// Locks part of a vertex-buffer to modify its contents. /// /// The buffer to lock /// The index of the first vertex to lock /// The number of vertices to lock /// The contents of the buffer, starting at start KINC_FUNC float *kinc_g5_vertex_buffer_lock(kinc_g5_vertex_buffer_t *buffer, int start, int count); /// /// Unlock all of a vertex-buffer so the changed contents can be used. /// /// The buffer to unlock KINC_FUNC void kinc_g5_vertex_buffer_unlock_all(kinc_g5_vertex_buffer_t *buffer); /// /// Unlocks part of a vertex-buffer so the changed contents can be used. /// /// The buffer to unlock /// The number of vertices to unlock, starting from the start-vertex from the previous lock-call KINC_FUNC void kinc_g5_vertex_buffer_unlock(kinc_g5_vertex_buffer_t *buffer, int count); /// /// Returns the number of vertices in a buffer. /// /// The buffer to figure out the number of vertices for /// The number of vertices KINC_FUNC int kinc_g5_vertex_buffer_count(kinc_g5_vertex_buffer_t *buffer); /// /// Returns the stride aka the size of one vertex of the buffer in bytes. /// /// The buffer to figure out the stride for /// The stride of the buffer in bytes KINC_FUNC int kinc_g5_vertex_buffer_stride(kinc_g5_vertex_buffer_t *buffer); int kinc_g5_internal_vertex_buffer_set(kinc_g5_vertex_buffer_t *buffer, int offset); #ifdef __cplusplus } #endif