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.
64 lines
1.6 KiB
64 lines
1.6 KiB
|
|
#include <glm/glm.hpp> |
|
|
|
#include "dumbLog.h" |
|
#include "mesh.h" |
|
#include "renderer.h" |
|
|
|
|
|
void |
|
doFrameCallback(render_state* rs) |
|
{ |
|
// NOTE: rotate mesh on z-axis every frame |
|
entity& e = rs->render_groups[0].entities[0]; |
|
static float angle = (float) M_PI_2 / 33; |
|
static glm::vec3 axis(0, 0, 1); |
|
entRotate(e, angle, axis); |
|
} |
|
|
|
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[0].entities[0]; |
|
// manually construct a simple mesh |
|
simple_mesh mesh = { glm::mat4(1), 0, 0, 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, 60, doFrameCallback); |
|
|
|
renShutdown(rs); |
|
return 0; |
|
}
|
|
|