Browse Source

hey, we can compile again

testing
cinnaboot 6 years ago
parent
commit
58ff019a54
  1. 15
      examples/assimp_loading/main.cpp
  2. 2
      examples/hello_world/main.cpp
  3. 2
      include/render_object.h
  4. 2
      include/renderer.h
  5. 2
      include/shader_program.h
  6. 11
      src/entity.cpp
  7. 11
      src/renderer.cpp
  8. 2
      src/shader_program.cpp

15
examples/assimp_loading/main.cpp

@ -17,7 +17,7 @@ doFrameCallback(render_state* rs)
}
void
doRenderLoop(render_state* rs, frame_callback_fn callback_fn, Entity* entities, uint entity_count)
doRenderLoop(render_state* rs, frame_callback_fn callback_fn, entity* entities, uint entity_count)
{
// TODO: move frame delay to renderFrame()
const uint TARGET_FPS = 60;
@ -46,7 +46,7 @@ doRenderLoop(render_state* rs, frame_callback_fn callback_fn, Entity* entities,
* render_group -> entities -> render_object(s)
* -> mesh_info ?
*/
renRenderFrame(rs, entities, entity_count);
renRenderFrame(rs);
SDL_GL_SwapWindow(rs->handles.window);
frameTime = SDL_GetTicks() - frameStart;
@ -67,18 +67,19 @@ main()
// TODO: entInit() doesn't allocate memory because we want to do the allocation in
// one big block, but this is really clunky to use
Entity spaceship;
entity spaceship;
// TODO: this should be handled in entInit
entSetWorldPosition(spaceship, 0, 0, 0);
spaceship.scale = glm::vec3(20, 20, 20);
spaceship.rotation = glm::vec4(0, 0, 0, 0);
entScale(spaceship, glm::vec3(20, 20, 20));
// TODO: implement setting rotation from entity
//spaceship.rotation = glm::vec4(0, 0, 0, 0);
// setup camera
cameraInitPerspective(
rs->cam,
glm::vec3(200, -150, 150),
spaceship.translation,
glm::vec3(0, 0, 0),
glm::vec3(0,0,1)
);
@ -96,7 +97,7 @@ main()
// NOTE: testing assimp animation info
logDebugAnimationInfo("../data/spaceship.glb");
if (entInit(spaceship, "../data/spaceship.glb", rs->default_shader))
if (entInit(spaceship, "../data/spaceship.glb"))
doRenderLoop(rs, doFrameCallback, &spaceship, 1);
else
LOG(Error) << "Error initializing entity, exiting\n";

2
examples/hello_world/main.cpp

@ -24,7 +24,7 @@ main()
}
}
renRenderFrame(rs, nullptr, 0);
renRenderFrame(rs);
SDL_GL_SwapWindow(rs->handles.window);
frameTime = SDL_GetTicks() - frameStart;

2
include/render_object.h

@ -18,3 +18,5 @@ struct render_object
void roFree(render_object* ro);
// TODO: implement me!
void roDraw(render_object* ro);

2
include/renderer.h

@ -61,5 +61,5 @@ render_state* renInit();
void renShutdown(render_state* rs);
void renRenderFrame(render_state* rs, Entity* entities, uint32 entity_count);
void renRenderFrame(render_state* rs);

2
include/shader_program.h

@ -18,5 +18,5 @@ struct shader_program
GLuint num_lights_id;
};
shader_program* initShaderProgram(const char* vertex_code, const char* frag_code);
shader_program* shaderInit(const char* vertex_code, const char* frag_code);

11
src/entity.cpp

@ -5,8 +5,10 @@
#include "entity.h"
#if 0
bool initEntityROs(entity& e);
bool convertMeshInfo(meMeshInfo* mesh, render_object* ro, bool use_normals, bool use_texture);
#endif
bool
entInit(entity& e, const char* model_path)
@ -15,11 +17,13 @@ entInit(entity& e, const char* model_path)
entScale(e, glm::vec3(1.0));
if (meLoadFromFile(e.mesh_group, model_path)) {
initEntityRG(e, shader, e.mesh_group.use_normals);
entSetWorldPosition(e, 0, 0, 0);
#if 0
initEntityRG(e, shader, e.mesh_group.use_normals);
if (!initEntityROs(e))
goto cleanup;
#endif
} else {
goto cleanup;
}
@ -75,6 +79,7 @@ initEntityRG(entity& e, rg_shader_program& shader, bool use_normals)
}
#endif
#if 0
bool
initEntityROs(entity& e)
{
@ -108,7 +113,9 @@ initEntityROs(entity& e)
return true;
}
#endif
#if 0
bool
convertMeshInfo(meMeshInfo* mesh, render_object* ro, bool use_normals, bool use_texture)
{
@ -173,3 +180,5 @@ convertMeshInfo(meMeshInfo* mesh, render_object* ro, bool use_normals, bool use_
return true;
}
#endif

11
src/renderer.cpp

@ -46,8 +46,7 @@ renInit()
if (initSDL(rs->handles) &&
createWindow(rs->handles, rs->viewport_dims) &&
initContext(rs->handles) &&
initGlOptions() &&
rgInitShaderProgram(rs->default_shader, DEFAULT_VERTEX_SHADER, DEFAULT_FRAGMENT_SHADER))
initGlOptions())
{
return rs;
} else {
@ -66,11 +65,14 @@ renShutdown(render_state* rs)
}
void
renRenderFrame(render_state* rs, Entity* entities, uint32 entity_count)
renRenderFrame(render_state* rs)
{
glClearColor(rs->clear_col.R, rs->clear_col.G, rs->clear_col.B, rs->clear_col.A);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
// TODO: loop over new render_groups on render_state
// make call to roDraw for each render_object in each entity
#if 0
// entities
for (uint i = 0; i < entity_count; i++) {
rgDraw(entities[i].ren_group,
@ -81,6 +83,7 @@ renRenderFrame(render_state* rs, Entity* entities, uint32 entity_count)
rs->num_lights
);
}
#endif
}
@ -196,7 +199,7 @@ setDefaults(render_state* rs)
{
rs->viewport_dims = v2i(DEFAULT_WIDTH, DEFAULT_HEIGHT);
rs->max_lights = MAX_LIGHTS;
rs->lights = UTIL_ALLOC(rs->max_lights, rg_point_light);
rs->lights = UTIL_ALLOC(rs->max_lights, point_light);
rs->clear_col.R = CLEAR_COL_R;
rs->clear_col.B = CLEAR_COL_B;
rs->clear_col.G = CLEAR_COL_G;

2
src/shader_program.cpp

@ -9,7 +9,7 @@
shader_program*
initShaderProgram(const char* vertex_code, const char* frag_code)
shaderInit(const char* vertex_code, const char* frag_code)
{
shader_program* sp = UTIL_ALLOC(1, shader_program);
glGenVertexArrays(1, &sp->vertex_array_id);

Loading…
Cancel
Save