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.
 
 
 

54 lines
1.3 KiB

#include <glm/glm.hpp>
#include "dumbLog.h"
#include "mesh.h"
#include "renderer.h"
int
main()
{
render_state* rs = renInit("simple mesh");
if (rs == nullptr) {
LOG(Error) << "Error Initialzing renderer\n";
return 1;
}
// TODO: this needs to be more convenient
shader_wrapper sw = { SIMPLE_SHADER, nullptr, rs->simple_shader };
rs->render_groups = renAllocateGroup(1, sw);
rs->render_group_count = 1;
entity& e = rs->render_groups->entities[0];
// manually construct a simple mesh
simple_mesh mesh = {0};
mesh.num_vertices = 4;
mesh.vertices = UTIL_ALLOC(mesh.num_vertices, glm::vec3);
mesh.vertices[0] = glm::vec3(-200, 0, 200);
mesh.vertices[1] = glm::vec3(-200, 0, -200);
mesh.vertices[2] = glm::vec3(200, 0, -200);
mesh.vertices[3] = glm::vec3(200, 0, 200);
mesh.vert_colors = UTIL_ALLOC(mesh.num_vertices, glm::vec3);
mesh.vert_colors[0] = glm::vec3(255, 0, 0);
mesh.vert_colors[1] = glm::vec3(255, 0, 0);
mesh.vert_colors[2] = glm::vec3(255, 0, 0);
mesh.vert_colors[3] = glm::vec3(255, 0, 0);
//initialize entity with new mesh
entInitSimpleMesh(e, mesh, GL_LINE_LOOP);
utilSafeFree(mesh.vertices);
utilSafeFree(mesh.vert_colors);
cameraInitPerspective(
rs->cam,
glm::vec3(0, -500, 0),
glm::vec3(0, 0, 0),
glm::vec3(0,0,1)
);
renDoRenderLoop(rs);
renShutdown(rs);
return 0;
}