|
|
|
@ -8,27 +8,6 @@ |
|
|
|
#include "types.h" |
|
|
|
#include "types.h" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct gl_buffer |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
GLuint id; |
|
|
|
|
|
|
|
GLenum target; |
|
|
|
|
|
|
|
GLenum data_type; |
|
|
|
|
|
|
|
GLuint location; // NOTE: if used as backing for vertex attribute
|
|
|
|
|
|
|
|
GLuint binding_idx; // NOTE: if used as backing from unifor buffer object
|
|
|
|
|
|
|
|
char* name; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// NOTE: we need another struct for vertex attributes that mirrors gl_buffer
|
|
|
|
|
|
|
|
// because an attribute is associated with a shader_programe while a buffer is
|
|
|
|
|
|
|
|
// associated with the vertex data passed to glBufferData()
|
|
|
|
|
|
|
|
struct GLVertexAttrib |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
GLenum data_type; |
|
|
|
|
|
|
|
u32 num_components; |
|
|
|
|
|
|
|
GLuint location; |
|
|
|
|
|
|
|
char* name; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct gl_uniform |
|
|
|
struct gl_uniform |
|
|
|
{ |
|
|
|
{ |
|
|
|
// NOTE: would be nice to use idx as the location parameter because it seems
|
|
|
|
// NOTE: would be nice to use idx as the location parameter because it seems
|
|
|
|
@ -52,6 +31,17 @@ struct GLUniformBlock |
|
|
|
char* name; |
|
|
|
char* name; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// NOTE: we need another struct for vertex attributes that mirrors gl_buffer
|
|
|
|
|
|
|
|
// because an attribute is associated with a shader_program while a buffer is
|
|
|
|
|
|
|
|
// associated with the vertex data passed to glBufferData()
|
|
|
|
|
|
|
|
struct GLVertexAttrib |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
GLenum data_type; |
|
|
|
|
|
|
|
u32 num_components; |
|
|
|
|
|
|
|
GLuint location; |
|
|
|
|
|
|
|
char* name; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
struct shader_program |
|
|
|
struct shader_program |
|
|
|
{ |
|
|
|
{ |
|
|
|
GLuint prog_id; |
|
|
|
GLuint prog_id; |
|
|
|
@ -71,6 +61,15 @@ struct shader_program |
|
|
|
u64 hash; // NOTE: hash of vs filpath + fs filepath concat
|
|
|
|
u64 hash; // NOTE: hash of vs filpath + fs filepath concat
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct gl_buffer |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
GLuint id; |
|
|
|
|
|
|
|
GLenum target; |
|
|
|
|
|
|
|
GLenum data_type; |
|
|
|
|
|
|
|
GLuint binding_idx; // NOTE: if used as backing from uniform buffer object
|
|
|
|
|
|
|
|
char* name; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
struct GLContext |
|
|
|
struct GLContext |
|
|
|
{ |
|
|
|
{ |
|
|
|
GLuint binding_count; |
|
|
|
GLuint binding_count; |
|
|
|
@ -88,6 +87,13 @@ struct GLContext |
|
|
|
shader_program* shaders; |
|
|
|
shader_program* shaders; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct GLBufferToAttribMapping |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
const char* buf_name; |
|
|
|
|
|
|
|
gl_buffer* buf; |
|
|
|
|
|
|
|
GLVertexAttrib* attrib; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
struct GLmesh |
|
|
|
struct GLmesh |
|
|
|
{ |
|
|
|
{ |
|
|
|
u32 num_indices; |
|
|
|
u32 num_indices; |
|
|
|
@ -103,6 +109,13 @@ struct GLmesh |
|
|
|
shader_program* shader; |
|
|
|
shader_program* shader; |
|
|
|
glm::mat4* model_xform; |
|
|
|
glm::mat4* model_xform; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// FIXME: WIP
|
|
|
|
|
|
|
|
u32 max_vertex_buffers; |
|
|
|
|
|
|
|
u32 num_vertex_buffers; |
|
|
|
|
|
|
|
gl_buffer* vertex_buffers; |
|
|
|
|
|
|
|
// WIP
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// FIXME: replace IDs here with gl_buffer struct array?
|
|
|
|
GLuint vert_buf_id; |
|
|
|
GLuint vert_buf_id; |
|
|
|
GLuint norm_buf_id; |
|
|
|
GLuint norm_buf_id; |
|
|
|
GLuint uv_buf_id; |
|
|
|
GLuint uv_buf_id; |
|
|
|
@ -110,12 +123,38 @@ struct GLmesh |
|
|
|
GLuint idx_buf_id; |
|
|
|
GLuint idx_buf_id; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: node/tree structure for entities
|
|
|
|
|
|
|
|
struct Node; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct Entity |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
u32 num_meshes; |
|
|
|
|
|
|
|
GLmesh* meshes; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct RenderGroup |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
u32 num_entites; |
|
|
|
|
|
|
|
u32 max_entities; |
|
|
|
|
|
|
|
Entity* entities; |
|
|
|
|
|
|
|
char* name; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct ShaderToRenderGroupMapping |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
shader_program* shader; |
|
|
|
|
|
|
|
RenderGroup* render_group; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct Animation; |
|
|
|
|
|
|
|
#if 0 |
|
|
|
// NOTE: attempt to resolve GLmesh to shader_program mapping issue
|
|
|
|
// NOTE: attempt to resolve GLmesh to shader_program mapping issue
|
|
|
|
struct GLmeshMapping |
|
|
|
struct GLmeshMapping |
|
|
|
{ |
|
|
|
{ |
|
|
|
u32 mesh_idx; |
|
|
|
u32 entity_idx; |
|
|
|
u32 shader_idx; |
|
|
|
u32 shader_idx; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
struct PointLight |
|
|
|
struct PointLight |
|
|
|
{ |
|
|
|
{ |
|
|
|
@ -124,10 +163,6 @@ struct PointLight |
|
|
|
u32 intensity; |
|
|
|
u32 intensity; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
struct node; |
|
|
|
|
|
|
|
struct entity; |
|
|
|
|
|
|
|
struct animation; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct transforms |
|
|
|
struct transforms |
|
|
|
{ |
|
|
|
{ |
|
|
|
glm::mat4 view_xform; |
|
|
|
glm::mat4 view_xform; |
|
|
|
|