From 04757ec527b59c1afdfa4274ea3c9e688fd97239 Mon Sep 17 00:00:00 2001 From: cinnaboot Date: Sun, 16 Dec 2018 14:31:57 -0500 Subject: [PATCH] add prefixes to interface function names in renderer and gooey --- src/gooey.cpp | 8 ++++---- src/gooey.h | 11 +++++++---- src/hexgame.cpp | 19 +++++++++---------- src/renderer.cpp | 12 ++++++------ src/renderer.h | 17 +++++++++++------ 5 files changed, 37 insertions(+), 30 deletions(-) diff --git a/src/gooey.cpp b/src/gooey.cpp index 753a8cb..27dca26 100644 --- a/src/gooey.cpp +++ b/src/gooey.cpp @@ -15,7 +15,7 @@ #include "gooey.h" bool -initGooey(SDL_Handles &handles, v2i vp_dims) +gooInit(SDL_Handles &handles, v2i vp_dims) { IMGUI_CHECKVERSION(); ImGui::CreateContext(); @@ -33,7 +33,7 @@ initGooey(SDL_Handles &handles, v2i vp_dims) } void -shutdownGooey() +gooFree() { ImGui_ImplOpenGL3_Shutdown(); ImGui_ImplSDL2_Shutdown(); @@ -41,14 +41,14 @@ shutdownGooey() } bool -gooeyProcessEvent(SDL_Event &event) +gooProcessEvent(SDL_Event &event) { ImGui_ImplSDL2_ProcessEvent(&event); return ImGui::GetIO().WantCaptureMouse; } void -renderGooey(SDL_Handles &handles, hexgrid* grid, bool &is_debug, camera* cam) +gooRender(SDL_Handles &handles, hexgrid* grid, bool &is_debug, camera* cam) { assert(grid != nullptr); diff --git a/src/gooey.h b/src/gooey.h index 5fa24ed..d234e7d 100644 --- a/src/gooey.h +++ b/src/gooey.h @@ -6,8 +6,11 @@ #include "hexgrid.h" #include "renderer.h" -bool initGooey(SDL_Handles &handles, v2i vp_dims); -void shutdownGooey(); -bool gooeyProcessEvent(SDL_Event &event); -void renderGooey(SDL_Handles &handles, hexgrid* grid, bool &is_debug, camera* cam); +bool gooInit(SDL_Handles &handles, v2i vp_dims); + +void gooFree(); + +bool gooProcessEvent(SDL_Event &event); + +void gooRender(SDL_Handles &handles, hexgrid* grid, bool &is_debug, camera* cam); diff --git a/src/hexgame.cpp b/src/hexgame.cpp index 18d28ce..7183a0a 100644 --- a/src/hexgame.cpp +++ b/src/hexgame.cpp @@ -1,7 +1,6 @@ /******************************************************************************* * TODO: * - renderer - * - add prefix to interface function names for eg) gooey.h, renderer.h * - clean up main(), split out initialization and scene loading to new functions * - check over renderer, camera, gooey init after changes * - pass in frame time to camera movement functions to decouple speed from framerate @@ -191,7 +190,7 @@ processSDLEvents() // let gooey have event // TODO: need to check for both io.WantCaptureKeyboard and io.WantCaptureMouse // to fix bug with 'ESC' not passing through while in imgui - bool gooey_wants = gooeyProcessEvent(e); + bool gooey_wants = gooProcessEvent(e); game_state* g = g_game_state; switch (e.type) @@ -269,7 +268,7 @@ cleanUp(SDL_Handles &handles) #if 0 shutdownGooey(); #endif - freeBuffers(g_render_state); // renderer.h + renFreeBuffers(g_render_state); // renderer.h for (SDL_Surface *surface : handles.texSurfaces) SDL_FreeSurface(surface); meShutdownAssimp(); // mesh.h @@ -324,12 +323,12 @@ int main(int argc, char* argv[]) return 1; } - if (!initRenderer(g_render_state)) { + if (!renInit(g_render_state)) { LOG(ERROR) << "Unable to initialize graphics, exiting\n"; return 1; } - if (!initGooey(g_render_state->handles, g_render_state->viewport_dims)) { + if (!gooInit(g_render_state->handles, g_render_state->viewport_dims)) { LOG(ERROR) << "Fooey, No Gooey!\n"; return 1; } @@ -347,7 +346,7 @@ int main(int argc, char* argv[]) // pre-load textures const char * path = "../data/coords.layout.flat.png"; - if (!addTexture(g_render_state->handles, path)) + if (!renAddTexture(g_render_state->handles, path)) { LOG(ERROR) << "Error adding " << path << "\n"; return 1; @@ -394,7 +393,7 @@ int main(int argc, char* argv[]) return 1; } - if (!createScene(g_render_state, g_game_state->entities, g_game_state->entity_count)) + if (!renCreateScene(g_render_state, g_game_state->entities, g_game_state->entity_count)) { LOG(ERROR) << "Error in vertex data, exiting\n"; return 1; @@ -424,12 +423,12 @@ int main(int argc, char* argv[]) cameraMove(r->cam, g->is_moveup, g->is_moveleft, g->is_movedown, g->is_moveright, g->is_moveforward, g->is_movebackward); - renderFrame(r, g->grid.hex_array, g->entities, g->entity_count); + renRenderFrame(r, g->grid.hex_array, g->entities, g->entity_count); if (r->is_debug_draw && g->grid.draw_mode == CONE_FILL) - renderDebug(r, g_polygon_select_vertices); + renRenderDebug(r, g_polygon_select_vertices); - renderGooey(r->handles, &g->grid, r->is_debug_draw, &r->cam); + gooRender(r->handles, &g->grid, r->is_debug_draw, &r->cam); SDL_GL_SwapWindow(r->handles.window); diff --git a/src/renderer.cpp b/src/renderer.cpp index 48fb426..eb008bc 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp @@ -42,7 +42,7 @@ void openglDebugCallback(GLenum source, GLenum type, GLuint id, GLenum severity, // interface bool -initRenderer(render_state* rs) +renInit(render_state* rs) { SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG); SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); @@ -119,7 +119,7 @@ initRenderer(render_state* rs) } void -freeBuffers(render_state* rs) +renFreeBuffers(render_state* rs) { utilSafeFree(rs->lights); rgFree(rs->filled_hex_render_group); @@ -128,7 +128,7 @@ freeBuffers(render_state* rs) } bool -addTexture(SDL_Handles &handles, const char * path) +renAddTexture(SDL_Handles &handles, const char * path) { // testing LOG(INFO) << "Loading image: " << path << "\n"; @@ -156,7 +156,7 @@ addTexture(SDL_Handles &handles, const char * path) } bool -createScene(render_state* rs, Entity* entities, uint32 entity_count) +renCreateScene(render_state* rs, Entity* entities, uint32 entity_count) { // entities @@ -195,7 +195,7 @@ createScene(render_state* rs, Entity* entities, uint32 entity_count) } void -renderFrame(render_state* rs, std::vector *hexes, Entity* entities, uint32 entity_count) +renRenderFrame(render_state* rs, std::vector *hexes, Entity* entities, uint32 entity_count) { glClearColor(g_clear_col.R, g_clear_col.G, g_clear_col.B, g_clear_col.A); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); @@ -226,7 +226,7 @@ renderFrame(render_state* rs, std::vector *hexes, Entity* entities, ui } void -renderDebug(render_state* rs, std::vector &vertices) +renRenderDebug(render_state* rs, std::vector &vertices) { GLfloat* buf = rs->debug_render_group->render_objects[0]->vertex_buffer.buffer; buf[0] = vertices[0].x; buf[1] = vertices[0].y; buf[2] = 0; diff --git a/src/renderer.h b/src/renderer.h index a475aeb..4287c52 100644 --- a/src/renderer.h +++ b/src/renderer.h @@ -44,10 +44,15 @@ struct render_state uint max_lights = 0; }; -bool initRenderer(render_state* rs); -void freeBuffers(render_state* rs); -bool addTexture(SDL_Handles &handles, const char * path); -bool createScene(render_state* rs, Entity* entities, uint32 entity_count); -void renderFrame(render_state* rs, std::vector* hexes, Entity* entities, uint32 entity_count); -void renderDebug(render_state* rs, std::vector &vertices); +bool renInit(render_state* rs); + +void renFreeBuffers(render_state* rs); + +bool renAddTexture(SDL_Handles &handles, const char * path); + +bool renCreateScene(render_state* rs, Entity* entities, uint32 entity_count); + +void renRenderFrame(render_state* rs, std::vector* hexes, Entity* entities, uint32 entity_count); + +void renRenderDebug(render_state* rs, std::vector &vertices);