A small OpenGL 3+ renderer and game engine
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

63 lines
1.3 KiB

#pragma once
#include <GL/glew.h>
#include <glm/glm.hpp>
#include "animation.h"
#include "util.h"
#include "util_image.h"
// NOTE: wrapper for tinygltf https://github.com/syoyo/tinygltf
// https://github.com/KhronosGroup/glTF
struct mesh
{
GLenum draw_mode; // NOTE: GL_LINES, GL_TRIANGLES
GLenum usage; // NOTE: GL_STATIC_DRAW, GL_DYNAMIC_DRAW
uint num_vertices;
uint num_indices;
glm::vec3* vertices;
glm::vec3* normals;
glm::vec2* texture_coords;
uint* indices;
glm::mat4* xform;
};
// TODO: will eventually need a tree structure with child nodes and transforms
// at each branch. Can then combine each transform down from the root node to
// the mesh, and send the final combination down to the shader
#define MAX_PATH_SIZE 256
struct model
{
uint num_meshes;
char* filepath;
uint64_t filepath_hash;
mesh* meshes; // NOTE: fixed sized array
// NOTE: pointer to a texture in render_state->textures
util_image* diffuse_texture;
// FIXME: node_animation has a pointer to a render_object. need to decouple
// that somehow
//node_animation* node_anim;
};
struct model_assets
{
model* models;
uint count;
uint max;
};
model_assets*
assetInitBlock(memory_arena* arena, uint asset_count);
model*
assetLoadFromFile(model_assets* assets,
memory_arena* arena,
const char* filename);
model*
assetGetCached(model_assets* assets, uint64_t path_hash);