|
|
|
@ -17,7 +17,7 @@ doFrameCallback(render_state* rs) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void |
|
|
|
void |
|
|
|
doRenderLoop(render_state* rs, frame_callback_fn callback_fn, entity* entities, uint entity_count) |
|
|
|
doRenderLoop(render_state* rs, frame_callback_fn callback_fn) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// TODO: move frame delay to renderFrame()
|
|
|
|
// TODO: move frame delay to renderFrame()
|
|
|
|
const uint TARGET_FPS = 60; |
|
|
|
const uint TARGET_FPS = 60; |
|
|
|
@ -29,7 +29,8 @@ doRenderLoop(render_state* rs, frame_callback_fn callback_fn, entity* entities, |
|
|
|
while (running) { |
|
|
|
while (running) { |
|
|
|
frameStart = SDL_GetTicks(); |
|
|
|
frameStart = SDL_GetTicks(); |
|
|
|
|
|
|
|
|
|
|
|
// TODO: add a better structure for input, and provide a callback to use here
|
|
|
|
// TODO: add a better structure for input, and provide a callback to use
|
|
|
|
|
|
|
|
// here
|
|
|
|
while (SDL_PollEvent(&e)) { |
|
|
|
while (SDL_PollEvent(&e)) { |
|
|
|
if ((e.type == SDL_KEYDOWN && e.key.keysym.sym == SDLK_ESCAPE) |
|
|
|
if ((e.type == SDL_KEYDOWN && e.key.keysym.sym == SDLK_ESCAPE) |
|
|
|
|| e.type == SDL_QUIT) { |
|
|
|
|| e.type == SDL_QUIT) { |
|
|
|
@ -39,13 +40,6 @@ doRenderLoop(render_state* rs, frame_callback_fn callback_fn, entity* entities, |
|
|
|
|
|
|
|
|
|
|
|
callback_fn(rs); |
|
|
|
callback_fn(rs); |
|
|
|
|
|
|
|
|
|
|
|
// TODO: entity pointer and entity count should be stored somewhere on the render_state object
|
|
|
|
|
|
|
|
// TODO: render_group should track a group of entity objects. the entity objects
|
|
|
|
|
|
|
|
// should keep track of their own render_objects?
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
* render_group -> entities -> render_object(s) |
|
|
|
|
|
|
|
* -> mesh_info ? |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
renRenderFrame(rs); |
|
|
|
renRenderFrame(rs); |
|
|
|
SDL_GL_SwapWindow(rs->handles.window); |
|
|
|
SDL_GL_SwapWindow(rs->handles.window); |
|
|
|
frameTime = SDL_GetTicks() - frameStart; |
|
|
|
frameTime = SDL_GetTicks() - frameStart; |
|
|
|
@ -61,13 +55,15 @@ doRenderLoop(render_state* rs, frame_callback_fn callback_fn, entity* entities, |
|
|
|
int |
|
|
|
int |
|
|
|
main() |
|
|
|
main() |
|
|
|
{ |
|
|
|
{ |
|
|
|
// TODO: would be nice to be able to pass in viewport_dims, window title here
|
|
|
|
// TODO: would be nice to be able to pass in viewport_dims, window title
|
|
|
|
|
|
|
|
// here
|
|
|
|
render_state* rs = renInit(); |
|
|
|
render_state* rs = renInit(); |
|
|
|
meInitAssimp(); |
|
|
|
meInitAssimp(); |
|
|
|
|
|
|
|
|
|
|
|
// TODO: entInit() doesn't allocate memory because we want to do the allocation in
|
|
|
|
// TODO: entInit() doesn't allocate memory because we want to do the
|
|
|
|
// one big block, but this is really clunky to use
|
|
|
|
// allocation in one big block, but this is really clunky to use
|
|
|
|
entity spaceship; |
|
|
|
render_group* group_1 = renAllocateGroup(1, *rs->default_shader); |
|
|
|
|
|
|
|
entity spaceship = group_1->entities[0]; |
|
|
|
|
|
|
|
|
|
|
|
// TODO: this should be handled in entInit
|
|
|
|
// TODO: this should be handled in entInit
|
|
|
|
entSetWorldPosition(spaceship, 0, 0, 0); |
|
|
|
entSetWorldPosition(spaceship, 0, 0, 0); |
|
|
|
@ -83,14 +79,14 @@ main() |
|
|
|
glm::vec3(0,0,1) |
|
|
|
glm::vec3(0,0,1) |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
// TODO: renderer::setDefaults() allocates 10 lights based on a MACRO in renderer.cpp
|
|
|
|
// TODO: renderer::setDefaults() allocates 10 lights based on a MACRO in
|
|
|
|
// probably need an interface to add more than that
|
|
|
|
// renderer.cpp probably need an interface to add more than that add a
|
|
|
|
// add a light
|
|
|
|
// light
|
|
|
|
rs->num_lights = 1; |
|
|
|
rs->num_lights = 1; |
|
|
|
rs->lights[0].position = glm::vec3(200, -150, 150); |
|
|
|
rs->lights[0].position = glm::vec3(200, -150, 150); |
|
|
|
|
|
|
|
|
|
|
|
// TODO: look into setting up git-annex for large files. git-lfs works fine for gitlab,
|
|
|
|
// TODO: look into setting up git-annex for large files. git-lfs works fine
|
|
|
|
// but has no real implementation for self-hosting:
|
|
|
|
// for gitlab, but has no real implementation for self-hosting:
|
|
|
|
// https://github.com/git-lfs/git-lfs/issues/1044
|
|
|
|
// https://github.com/git-lfs/git-lfs/issues/1044
|
|
|
|
// https://git-annex.branchable.com/
|
|
|
|
// https://git-annex.branchable.com/
|
|
|
|
//
|
|
|
|
//
|
|
|
|
@ -98,7 +94,7 @@ main() |
|
|
|
logDebugAnimationInfo("../data/spaceship.glb"); |
|
|
|
logDebugAnimationInfo("../data/spaceship.glb"); |
|
|
|
|
|
|
|
|
|
|
|
if (entInit(spaceship, "../data/spaceship.glb")) |
|
|
|
if (entInit(spaceship, "../data/spaceship.glb")) |
|
|
|
doRenderLoop(rs, doFrameCallback, &spaceship, 1); |
|
|
|
doRenderLoop(rs, doFrameCallback); |
|
|
|
else |
|
|
|
else |
|
|
|
LOG(Error) << "Error initializing entity, exiting\n"; |
|
|
|
LOG(Error) << "Error initializing entity, exiting\n"; |
|
|
|
|
|
|
|
|
|
|
|
|