From 89fc42251fd4be9bab1220b3e949221c46d0eaec Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Thu, 13 Sep 2012 23:43:04 -0400 Subject: [PATCH] create buffers for overlay hex tiles --- src/client/Client-gl.cc | 25 +++++++++++++++++++++++++ src/client/Client.h | 2 ++ 2 files changed, 27 insertions(+) diff --git a/src/client/Client-gl.cc b/src/client/Client-gl.cc index e8f207e..9490a06 100644 --- a/src/client/Client-gl.cc +++ b/src/client/Client-gl.cc @@ -32,6 +32,19 @@ static const char *obj_uniform_names[] = { #define OBJ_MODELVIEW obj_uniform_locations[6] "modelview" }; +/* points of a horizontal hexagon 1.0 units high */ +static const float overlay_hex_attributes[][2] = { + {0.0, 0.0}, + {HEX_WIDTH_TO_HEIGHT / 2.0, 0.0}, + {HEX_WIDTH_TO_HEIGHT / 4.0, 0.5}, + {-HEX_WIDTH_TO_HEIGHT / 4.0, 0.5}, + {-HEX_WIDTH_TO_HEIGHT / 2.0, 0.0}, + {-HEX_WIDTH_TO_HEIGHT / 4.0, -0.5}, + {HEX_WIDTH_TO_HEIGHT / 4.0, -0.5} +}; +static const GLshort overlay_hex_indices[] = { + 0, 1, 2, 3, 4, 5, 6 +}; static bool load_file(const char *fname, WFObj::Buffer & buff) { @@ -104,6 +117,18 @@ bool Client::initgl() cerr << "Error loading hex-tile model" << endl; return false; } + if (!m_overlay_hex_attributes.create(GL_ARRAY_BUFFER, GL_STATIC_DRAW, + overlay_hex_attributes, sizeof(overlay_hex_attributes))) + { + cerr << "Error creating overlay hex attribute buffer" << endl; + return false; + } + if (!m_overlay_hex_indices.create(GL_ELEMENT_ARRAY_BUFFER, GL_STATIC_DRAW, + overlay_hex_indices, sizeof(overlay_hex_indices))) + { + cerr << "Error creating overlay hex indices buffer" << endl; + return false; + } m_obj_program.get_uniform_locations(obj_uniform_names, NUM_OBJ_UNIFORMS, obj_uniform_locations); m_obj_program.use(); diff --git a/src/client/Client.h b/src/client/Client.h index 6c321bb..8f6f5f7 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -36,6 +36,8 @@ class Client WFObj m_tile_obj; GLMatrix m_projection; GLMatrix m_modelview; + GLBuffer m_overlay_hex_attributes; + GLBuffer m_overlay_hex_indices; }; #endif