create buffers for overlay hex tiles
This commit is contained in:
parent
ab65139951
commit
89fc42251f
@ -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();
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user