From 31e078f73c2673dfcfa1d80ef778fd4ee2783427 Mon Sep 17 00:00:00 2001 From: cinnaboot Date: Fri, 23 Nov 2018 15:17:59 -0500 Subject: [PATCH] remove references to fill_color from render_state --- data/test_scene.json | 2 +- src/hexgame.cpp | 21 ++++++--------------- src/render_group.h | 3 --- src/renderer.cpp | 5 +---- src/renderer.h | 2 -- src/scene_loader.cpp | 6 +++--- src/scene_loader.h | 4 +--- 7 files changed, 12 insertions(+), 31 deletions(-) diff --git a/data/test_scene.json b/data/test_scene.json index 1e01f56..0ecbee2 100644 --- a/data/test_scene.json +++ b/data/test_scene.json @@ -2,7 +2,7 @@ "camera" : { "position" : { "x" : 0, - "y" : -800, + "y" : -400, "z" : 100 }, "target" : { diff --git a/src/hexgame.cpp b/src/hexgame.cpp index 5db2746..0f23cc6 100644 --- a/src/hexgame.cpp +++ b/src/hexgame.cpp @@ -23,14 +23,6 @@ ******************************************************************************/ // Some defaults for the game layout -#if 0 -#define HEX_SIZE 10 -#define HEX_RADIUS 19 -#define HEX_ORIENTATION layout_flat -#define FILL_COLOR 0x565656FF -#define SELECTED_FILL_COLOR 0xF46000FF -#endif - #define DEBUG_DRAW true #define VIEWPORT_WIDTH 1920 #define VIEWPORT_HEIGHT 1080 @@ -120,7 +112,7 @@ void setStartHex(hex_info *hex) { hex->selected = true; - hex->current_color = g_render_state->selected_fill_color; + hex->current_color = g_game_state->grid.selected_fill_color; g_game_state->grid.start_hex = g_game_state->grid.current_hex = hex; g_game_state->grid.is_selecting = true; } @@ -148,7 +140,7 @@ updateHexFill(int32 x, int32 y) if (hex_distance(g_game_state->grid.start_hex->hex, h.hex) <= l) { h.selected = true; - h.current_color = g_render_state->selected_fill_color; + h.current_color = g_game_state->grid.selected_fill_color; } else { @@ -176,7 +168,7 @@ updateHexLineDraw(int32 x, int32 y) if (hex_equal(h1.hex, h2)) { h1.selected = true; - h1.current_color = g_render_state->selected_fill_color; + h1.current_color = g_game_state->grid.selected_fill_color; break; } else if (i == hexLine.size() - 1) @@ -226,7 +218,7 @@ updateHexConeFill(int32 x, int32 y) if (crossingTest(vertices, test_p)) { h.selected = true; - h.current_color = g_render_state->selected_fill_color; + h.current_color = g_game_state->grid.selected_fill_color; } else { @@ -274,7 +266,7 @@ handleMouseDown(SDL_MouseButtonEvent &e) hex->selected = !hex->selected; if (hex->selected) { - hex->current_color = g_render_state->selected_fill_color; + hex->current_color = g_game_state->grid.selected_fill_color; } else { @@ -528,10 +520,9 @@ int main(int argc, char* argv[]) slSceneDoc* sd = slLoadFile(DATA_DIR, DEFAULT_SCENE_FILE, SCENE_SCHEMA_FILE); if (sd != nullptr) { game_state* g = g_game_state; - render_state* r = g_render_state; slParseEntities(sd, g->entities, g->entity_count, MAX_ENTITIES, DATA_DIR); slParseCamera(sd, renGetCamera()); - slParseHexGrid(sd, g->grid, r->fill_color, r->selected_fill_color); + slParseHexGrid(sd, g->grid); slFreeSceneDoc(sd); } else { LOG(ERROR) << "Error loading scene, exiting\n"; diff --git a/src/render_group.h b/src/render_group.h index 279d0e5..e5724ef 100644 --- a/src/render_group.h +++ b/src/render_group.h @@ -64,9 +64,6 @@ bool rgInitEntity(Entity* e); void rgBufferData(gl_buffer* buffer, GLenum usage, GLenum target); -// TODO: fix this function to use just buffers instead of hexes -//void rgFillColorBuffer(GLfloat buf[], int len, std::vector* hexes); - void rgDraw(render_group* rg, glm::mat4 model_matrix, glm::mat4 view_matrix, glm::mat4 projection_matrix, glm::vec3 light_position, GLuint light_id, diff --git a/src/renderer.cpp b/src/renderer.cpp index 5aaf0c4..363df69 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp @@ -3,10 +3,7 @@ #include // trig functions #include // calloc -// TODO: decide on extension library -//#include #include - #if defined (_WIN32) #include #else @@ -107,7 +104,7 @@ initRenderer(SDL_Handles &handles, v2i vpDims) return false; } - if (gl3wInit()) { // TODO: decide on extension library + if (gl3wInit()) { LOG(ERROR) << "failed to initialize OpenGL\n"; return false; } diff --git a/src/renderer.h b/src/renderer.h index dea01c3..2146ece 100644 --- a/src/renderer.h +++ b/src/renderer.h @@ -28,8 +28,6 @@ struct render_state { v2i viewport_dims; bool is_debug_draw; - uint32 fill_color; - uint32 selected_fill_color; }; struct renPointLight diff --git a/src/scene_loader.cpp b/src/scene_loader.cpp index 1c7f1c4..f612364 100644 --- a/src/scene_loader.cpp +++ b/src/scene_loader.cpp @@ -110,7 +110,7 @@ slParseCamera(slSceneDoc* sd, camera& cam) } void -slParseHexGrid(slSceneDoc* sd, hexgrid& hg, uint32& fill_color, uint32&selected_fill_color) +slParseHexGrid(slSceneDoc* sd, hexgrid& hg) { const rapidjson::Value& json_grid = (*sd->doc)["hex_grid"]; @@ -130,9 +130,9 @@ slParseHexGrid(slSceneDoc* sd, hexgrid& hg, uint32& fill_color, uint32&selected_ hg.position.y = pos.y; hg.position.z = pos.z; std::string fill_color_str = json_grid["fill_color"].GetString(); - hg.fill_color = fill_color = std::stoul(fill_color_str, nullptr, 16); + hg.fill_color = std::stoul(fill_color_str, nullptr, 16); std::string selected_fill_color_str = json_grid["selected_fill_color"].GetString(); - hg.selected_fill_color = selected_fill_color = std::stoul(selected_fill_color_str, nullptr, 16); + hg.selected_fill_color = std::stoul(selected_fill_color_str, nullptr, 16); std::string orientation_str = json_grid["hexlib_orientation"].GetString(); hg.hexlib_orientation = (orientation_str == "layout_flat") ? layout_flat : layout_pointy; Layout lo(hg.hexlib_orientation, Point(hg.hex_size, hg.hex_size), Point(hg.position.x, hg.position.y)); diff --git a/src/scene_loader.h b/src/scene_loader.h index 7e0f2ee..dad960a 100644 --- a/src/scene_loader.h +++ b/src/scene_loader.h @@ -18,6 +18,4 @@ bool slParseEntities( ); void slParseCamera(slSceneDoc* sd, camera& cam); - -// TODO: remove fill_color,selected_fill_color refs here, and use hex_grid object in renderer -void slParseHexGrid(slSceneDoc* sd, hexgrid& hg, uint32& fill_color, uint32&selected_fill_color); +void slParseHexGrid(slSceneDoc* sd, hexgrid& hg);