|
|
|
@ -110,6 +110,7 @@ void openglDebugCallback(GLenum source, GLenum type, GLuint id, GLenum severity, |
|
|
|
GLsizei length, const GLchar* message, const void* userParam); |
|
|
|
GLsizei length, const GLchar* message, const void* userParam); |
|
|
|
void fillTriangleBufferFromHex(GLfloat buf[], int idx, const hex_info &hex); |
|
|
|
void fillTriangleBufferFromHex(GLfloat buf[], int idx, const hex_info &hex); |
|
|
|
void fillColorBuffer(GLfloat buf[], int len, std::vector<hex_info> *hexes); |
|
|
|
void fillColorBuffer(GLfloat buf[], int len, std::vector<hex_info> *hexes); |
|
|
|
|
|
|
|
void convertColor(GLfloat buf[], uint32 color); |
|
|
|
void fillHexLineBuffer(GLfloat buf[], int len, std::vector<hex_info>* hexes); |
|
|
|
void fillHexLineBuffer(GLfloat buf[], int len, std::vector<hex_info>* hexes); |
|
|
|
bool checkGLBufferSize(GLenum buf_type, int expected_size, int line_num); |
|
|
|
bool checkGLBufferSize(GLenum buf_type, int expected_size, int line_num); |
|
|
|
bool initGLBufferObject(gl_buffer* buf_obj, int len, GLenum usage, GLfloat data[]); |
|
|
|
bool initGLBufferObject(gl_buffer* buf_obj, int len, GLenum usage, GLfloat data[]); |
|
|
|
@ -319,19 +320,34 @@ fillTriangleBufferFromHex(GLfloat buf[], int idx, const hex_info &hex) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// NOTE: helper for fillColorBuffer() to convert uint32 color to GLfloat triplet
|
|
|
|
|
|
|
|
void |
|
|
|
|
|
|
|
convertColor(GLfloat buf[3], uint32 color) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// NOTE: not using the alpha values for now
|
|
|
|
|
|
|
|
buf[0] = (GLfloat) ((color >> 24) & 0xFF) / (GLfloat) 255;
|
|
|
|
|
|
|
|
buf[1] = (GLfloat) ((color >> 16) & 0xFF) / (GLfloat) 255;
|
|
|
|
|
|
|
|
buf[2] = (GLfloat) ((color >> 8) & 0xFF) / (GLfloat) 255;
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void |
|
|
|
void |
|
|
|
fillColorBuffer(GLfloat buf[], int len, std::vector<hex_info>* hexes) |
|
|
|
fillColorBuffer(GLfloat buf[], int len, std::vector<hex_info>* hexes) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int buf_idx; |
|
|
|
int buf_idx; |
|
|
|
int buf_len_per_hex = 54; // NOTE: 3 * 3 * 6
|
|
|
|
int buf_len_per_hex = 54; // NOTE: 3 * 3 * 6
|
|
|
|
|
|
|
|
GLfloat color_buf[3]; |
|
|
|
for (int i = 0; i < (int) hexes->size(); i++) |
|
|
|
for (int i = 0; i < (int) hexes->size(); i++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
buf_idx = i * buf_len_per_hex; |
|
|
|
buf_idx = i * buf_len_per_hex; |
|
|
|
hex_info hxi = (*hexes)[i]; |
|
|
|
hex_info hxi = (*hexes)[i]; |
|
|
|
GLfloat color = (GLfloat) hxi.current_color / (GLfloat) UINT32_MAX; |
|
|
|
convertColor(color_buf, hxi.current_color); |
|
|
|
|
|
|
|
|
|
|
|
for (int j = 0; j < buf_len_per_hex; j++) |
|
|
|
for (int j = 0; j < buf_len_per_hex; j+=3) |
|
|
|
buf[buf_idx + j] = color; |
|
|
|
{ |
|
|
|
|
|
|
|
buf[buf_idx + j] = color_buf[0]; |
|
|
|
|
|
|
|
buf[buf_idx + j + 1] = color_buf[1]; |
|
|
|
|
|
|
|
buf[buf_idx + j + 2] = color_buf[2]; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|