#pragma once #include #include "usage.h" #include "vertexstructure.h" #include #include /*! \file vertexbuffer.h \brief Provides functions for setting up and using vertex-buffers. */ #ifdef __cplusplus extern "C" { #endif typedef struct kinc_g4_vertex_buffer { kinc_g4_vertex_buffer_impl_t impl; } kinc_g4_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 /// A hint for how the buffer will be used /// The step-rate for instanced-rendering - use 0 if instanced-rendering will not be used with this buffer KINC_FUNC void kinc_g4_vertex_buffer_init(kinc_g4_vertex_buffer_t *buffer, int count, kinc_g4_vertex_structure_t *structure, kinc_g4_usage_t usage, int instance_data_step_rate); /// /// Destroys a vertex-buffer. /// /// The buffer to destroy KINC_FUNC void kinc_g4_vertex_buffer_destroy(kinc_g4_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_g4_vertex_buffer_lock_all(kinc_g4_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_g4_vertex_buffer_lock(kinc_g4_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_g4_vertex_buffer_unlock_all(kinc_g4_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_g4_vertex_buffer_unlock(kinc_g4_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_g4_vertex_buffer_count(kinc_g4_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_g4_vertex_buffer_stride(kinc_g4_vertex_buffer_t *buffer); int kinc_internal_g4_vertex_buffer_set(kinc_g4_vertex_buffer_t *buffer, int offset); /// /// Sets vertex-buffers for the next draw-call. /// /// The buffers to set /// The number of buffers to set KINC_FUNC void kinc_g4_set_vertex_buffers(kinc_g4_vertex_buffer_t **buffers, int count); /// /// Sets a vertex-buffer for the next draw-call. /// /// The buffer to set KINC_FUNC void kinc_g4_set_vertex_buffer(kinc_g4_vertex_buffer_t *buffer); #ifdef __cplusplus } #endif