Import .obj model from Blender
Add third-party hashmap library to help when importing
This commit is contained in:
12
src/render.c
12
src/render.c
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user