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.
85 lines
1.9 KiB
85 lines
1.9 KiB
|
|
#include <SDL2/SDL.h> |
|
#include <glm/glm.hpp> |
|
|
|
#include "camera.h" |
|
#include "dumbLog.h" |
|
#include "input.h" |
|
#include "entity.h" |
|
#include "renderer.h" |
|
#include "shader_program.h" |
|
|
|
|
|
void |
|
doFrameCallback(render_state* rs) |
|
{ |
|
static input_state is = {}; |
|
inputProcessEvents(&is); |
|
|
|
if (is.window_closed || is.escape) { |
|
rs->running = false; |
|
return; |
|
} |
|
|
|
int rotate_mod = 0; |
|
|
|
if (is.left) |
|
rotate_mod = -1; |
|
if (is.right) |
|
rotate_mod = 1; |
|
|
|
// 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 * rotate_mod, axis); |
|
} |
|
|
|
// TODO: remove/refactor this when we get animation working |
|
#include "animation_testing.cpp" |
|
|
|
int |
|
main() |
|
{ |
|
render_state* rs = renInit("assimp loading"); |
|
rs->render_groups = UTIL_ALLOC(256, render_group*); |
|
|
|
if (rs == nullptr) { |
|
LOG(Error) << "Error Initialzing renderer\n"; |
|
return 1; |
|
} |
|
|
|
// TODO: this needs to be more convenient |
|
shader_wrapper sw = { DEFAULT_SHADER, rs->default_shader, nullptr }; |
|
rs->render_groups[0] = renAllocateGroup(1, sw); |
|
rs->render_group_count = 1; |
|
entity& spaceship = rs->render_groups[0]->entities[0]; |
|
|
|
cameraInitPerspective( |
|
rs->cam, |
|
glm::vec3(200, -150, 150), |
|
glm::vec3(0, 0, 0), |
|
glm::vec3(0,0,1) |
|
); |
|
|
|
renAddLight(rs, glm::vec3(200, -150, 150)); |
|
|
|
// TODO: look into setting up git-annex for large files. git-lfs works fine |
|
// for gitlab, but has no real implementation for self-hosting: |
|
// https://github.com/git-lfs/git-lfs/issues/1044 |
|
// https://git-annex.branchable.com/ |
|
// |
|
// NOTE: testing assimp animation info |
|
logDebugAnimationInfo("../data/spaceship.glb"); |
|
|
|
if (entInitModel(spaceship, "../data/spaceship.glb")) { |
|
entScale(spaceship, glm::vec3(20, 20, 20)); |
|
renDoRenderLoop(rs, 60, doFrameCallback); |
|
} else { |
|
LOG(Error) << "Error initializing entity, exiting\n"; |
|
} |
|
|
|
renShutdown(rs); |
|
return 0; |
|
} |
|
|
|
|