Browse Source

remove references to fill_color from render_state

master
cinnaboot 8 years ago
parent
commit
31e078f73c
  1. 2
      data/test_scene.json
  2. 21
      src/hexgame.cpp
  3. 3
      src/render_group.h
  4. 5
      src/renderer.cpp
  5. 2
      src/renderer.h
  6. 6
      src/scene_loader.cpp
  7. 4
      src/scene_loader.h

2
data/test_scene.json

@ -2,7 +2,7 @@
"camera" : {
"position" : {
"x" : 0,
"y" : -800,
"y" : -400,
"z" : 100
},
"target" : {

21
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";

3
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<hex_info>* 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,

5
src/renderer.cpp

@ -3,10 +3,7 @@
#include <cmath> // trig functions
#include <cstdlib> // calloc
// TODO: decide on extension library
//#include <GL/glew.h>
#include <GL/gl3w.h>
#if defined (_WIN32)
#include <SDL.h>
#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;
}

2
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

6
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));

4
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);

Loading…
Cancel
Save