Import .obj model from Blender

Add third-party hashmap library to help when importing
This commit is contained in:
var
2026-04-04 20:19:46 -05:00
parent 06535ccf01
commit 565c4e0e6f
11 changed files with 1844 additions and 3 deletions

View File

@@ -11,6 +11,7 @@
#include "camera.h"
#include "game.h"
#include "shape.h"
#include "model.h"
static void LoadTextureArray(GLuint texture, const char* filePath, int nCols, int nRows)
{
@@ -237,7 +238,7 @@ bool Render_Init(GameState *gs)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
printf("Initialized OpenGL.\n");
gs->numShapes = 2;
gs->numShapes = 3;
Shape *shape = Shape_MakePyramid(5);
gs->shapes[0] = shape;
@@ -255,12 +256,21 @@ bool Render_Init(GameState *gs)
glGenBuffers(1, &shape->EBO);
printf("Created shape 1.\n");
shape = Model_ReadObjFile("res/model/human.obj");
gs->shapes[2] = shape;
glGenVertexArrays(1, &shape->VAO);
glGenBuffers(1, &shape->VBO);
glGenBuffers(1, &shape->IBO);
glGenBuffers(1, &shape->EBO);
printf("Created shape 2.\n");
LoadTexture(gs);
printf("Loaded textures.\n");
Camera_Init(&gs->camera);
InitShapeBuffers(gs->shapes[0]);
InitShapeBuffers(gs->shapes[1]);
InitShapeBuffers(gs->shapes[2]);
printf("Initialized buffers.\n");
return true;
}