|
|
|
|
@ -46,7 +46,10 @@ void drawSimple(render_objects* r_objs,
|
|
|
|
|
shader_wrapper sw, |
|
|
|
|
light_group* lights); |
|
|
|
|
inline void enableGLFloatBuffer(uint buffer_id, uint location); |
|
|
|
|
bool initGLFloatBuffer(glm::vec3* buffer, uint count, GLuint& buffer_id); |
|
|
|
|
bool initGLFloatBuffer(glm::vec3* buffer, |
|
|
|
|
uint count, |
|
|
|
|
GLuint& buffer_id, |
|
|
|
|
GLenum usage = GL_STATIC_DRAW); |
|
|
|
|
bool initGLIndexBuffer(uint* buffer, uint num_indices, GLuint& buffer_id); |
|
|
|
|
bool initGLTexture(const util_image image, GLuint& tex_id); |
|
|
|
|
bool loadMeshIntoGL(default_render_object* ro_out, mesh_info* mi_in); |
|
|
|
|
@ -93,10 +96,12 @@ roInitSimpleMesh(simple_mesh& mesh_in, GLenum draw_mode)
|
|
|
|
|
|
|
|
|
|
if (initGLFloatBuffer(mesh_in.vertices, |
|
|
|
|
mesh_in.num_vertices, |
|
|
|
|
objects->vertex_buffer_id) && |
|
|
|
|
objects->vertex_buffer_id, |
|
|
|
|
GL_DYNAMIC_DRAW) && |
|
|
|
|
initGLFloatBuffer(mesh_in.vert_colors, |
|
|
|
|
mesh_in.num_vertices, |
|
|
|
|
objects->vertex_color_buffer_id)) |
|
|
|
|
objects->vertex_color_buffer_id, |
|
|
|
|
GL_DYNAMIC_DRAW)) |
|
|
|
|
{ |
|
|
|
|
objects->model_transform = mesh_in.model_transform; |
|
|
|
|
objects->vertex_count = mesh_in.num_vertices; |
|
|
|
|
@ -158,13 +163,13 @@ roUpdateSimpleMesh(render_objects* r_objs, simple_mesh* mesh, GLenum draw_mode)
|
|
|
|
|
glBufferSubData( |
|
|
|
|
GL_ARRAY_BUFFER, |
|
|
|
|
0, |
|
|
|
|
sro->vertex_count * sizeof(GLfloat), |
|
|
|
|
3 * sro->vertex_count * sizeof(GLfloat), |
|
|
|
|
mesh->vertices); |
|
|
|
|
glBindBuffer(GL_ARRAY_BUFFER, sro->vertex_color_buffer_id); |
|
|
|
|
glBufferSubData( |
|
|
|
|
GL_ARRAY_BUFFER, |
|
|
|
|
0, |
|
|
|
|
sro->vertex_count * sizeof(GLfloat), |
|
|
|
|
3 * sro->vertex_count * sizeof(GLfloat), |
|
|
|
|
mesh->vert_colors); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -238,14 +243,17 @@ enableGLFloatBuffer(uint buffer_id, uint location)
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool |
|
|
|
|
initGLFloatBuffer(glm::vec3* buffer, uint count, GLuint& buffer_id) |
|
|
|
|
initGLFloatBuffer(glm::vec3* buffer, |
|
|
|
|
uint count, |
|
|
|
|
GLuint& buffer_id, |
|
|
|
|
GLenum usage) |
|
|
|
|
{ |
|
|
|
|
glGenBuffers(1, &buffer_id); |
|
|
|
|
glBindBuffer(GL_ARRAY_BUFFER, buffer_id); |
|
|
|
|
glBufferData(GL_ARRAY_BUFFER, |
|
|
|
|
count * 3 * sizeof(GLfloat), // NOTE: 3 floats per vertex prop
|
|
|
|
|
buffer, |
|
|
|
|
GL_STATIC_DRAW); |
|
|
|
|
usage); |
|
|
|
|
|
|
|
|
|
return (glGetError() == GL_NO_ERROR); |
|
|
|
|
} |
|
|
|
|
|