Browse Source

rearrange some dependencies

master
cinnaboot 8 years ago
parent
commit
1da3c0bcd1
  1. 2
      src/gooey.h
  2. 1
      src/hexgame.cpp
  3. 47
      src/hexgame.h
  4. 21
      src/hexgrid.cpp
  5. 32
      src/hexgrid.h
  6. 6
      src/hexlib.h
  7. 1
      src/render_group.h
  8. 24
      src/renderer.h

2
src/gooey.h

@ -2,6 +2,8 @@
#pragma once
#include "hexgame.h"
#include "hexgrid.h"
#include "renderer.h"
bool initGooey(SDL_Handles &handles, v2i vp_dims);
void shutdownGooey();

1
src/hexgame.cpp

@ -65,7 +65,6 @@
#include "gooey.h"
#include "hexgame.h"
#include "hexlib.h"
#include "mesh.h"
#include "platform_wait_for_vblank.h"
#include "renderer.h"

47
src/hexgame.h

@ -3,58 +3,14 @@
#include <vector>
#if defined (_WIN32)
#include <SDL.h>
#else
#include <SDL2/SDL.h>
#endif
#include <glm/glm.hpp>
#include "entity.h"
#include "hexgrid.h"
#include "hexlib.h"
#include "mesh.h"
#include "util.h"
// TODO: should move this to renderer.h
struct SDL_Handles
{
SDL_Window *window;
SDL_GLContext glContext;
SDL_DisplayMode currentDisplayMode;
std::vector<SDL_Surface*> texSurfaces;
};
struct hex_info
{
int32 hexID = 0;
Hex hex = {};
real64 XPos = 0;
real64 YPos = 0;
uint32 current_color = 0; // RGBA
uint32 stored_color = 0; // RGBA
bool selected = false;
std::vector<Point> vertices;
};
enum HexDrawMode
{
NONE,
FILL,
LINE,
CONE_FILL,
PATHFINDING
};
struct render_state
{
v2i viewport_dims;
bool is_debug_draw;
uint32 fill_color;
uint32 selected_fill_color;
};
struct game_state
{
std::vector<hex_info> *hex_array;
@ -80,6 +36,7 @@ struct game_state
bool is_rotateCW = false;
bool is_rotateCCW = false;
// TODO: initialize this in hexgrid.h to remove hexlib.h dep?
game_state(Layout &l) : hex_layout(l) {}
};

21
src/hexgrid.cpp

@ -0,0 +1,21 @@
#include "hexgrid.h"
void
hgCreateHexes(vector<hex_info> *hxi_array, const Layout &layout, uint32 color)
{
}
hex_info*
hgGetSingleHex(int32 x, int32 y)
{
return nullptr;
}
void
hgResetHexes()
{
}

32
src/hexgrid.h

@ -1,10 +1,38 @@
#pragma once
#include <vector>
#include "hexlib.h"
#include "util.h"
// TODO: move hex_info definition here and update references
struct hex_info;
enum HexDrawMode
{
NONE,
FILL,
LINE,
CONE_FILL,
PATHFINDING
};
struct hex_info
{
int32 hexID = 0;
Hex hex = {};
real64 XPos = 0;
real64 YPos = 0;
uint32 current_color = 0; // RGBA
uint32 stored_color = 0; // RGBA
bool selected = false;
std::vector<Point> vertices;
};
struct hexgrid
{
Layout hex_layout;
};
void hgCreateHexes(vector<hex_info> *hxi_array, const Layout &layout, uint32 color);
hex_info* hgGetSingleHex(int32 x, int32 y);

6
src/hexlib.h

@ -56,9 +56,9 @@ const Orientation layout_flat = Orientation(3.0 / 2.0, 0.0, sqrt(3.0) / 2.0, sqr
struct Layout
{
const Orientation orientation;
const Point size;
const Point origin;
Orientation orientation;
Point size;
Point origin;
Layout(Orientation orientation_, Point size_, Point origin_):
orientation(orientation_), size(size_), origin(origin_) {}
};

1
src/render_group.h

@ -4,7 +4,6 @@
#include <GL/gl3w.h>
#include "entity.h"
//#include "hexgame.h"
#include "util.h"
struct Entity;

24
src/renderer.h

@ -3,12 +3,34 @@
#include <vector>
#if defined (_WIN32)
#include <SDL.h>
#else
#include <SDL2/SDL.h>
#endif
#include <glm/glm.hpp>
#include "camera.h"
#include "entity.h"
#include "hexgrid.h"
#include "util.h"
#include "hexgame.h" // TODO: should move hex_info object out of hexgame.h
struct SDL_Handles
{
SDL_Window *window;
SDL_GLContext glContext;
SDL_DisplayMode currentDisplayMode;
std::vector<SDL_Surface*> texSurfaces;
};
struct render_state
{
v2i viewport_dims;
bool is_debug_draw;
uint32 fill_color;
uint32 selected_fill_color;
};
struct renPointLight
{

Loading…
Cancel
Save