summaryrefslogtreecommitdiffstats
path: root/MainWindow.cpp
diff options
context:
space:
mode:
authormario <mario@notk.org>2011-11-28 21:07:00 +0100
committermario <mario@notk.org>2011-11-28 21:07:00 +0100
commit2d5d3a552bad07d277a892087a011f5d1627105f (patch)
tree5912407dc7c4f27a122abbf5c89fbb3ce59ee6ab /MainWindow.cpp
parent54a60881ae450956593de956f61594b865fcbffe (diff)
Fixed color conversion
Diffstat (limited to 'MainWindow.cpp')
-rw-r--r--MainWindow.cpp45
1 files changed, 19 insertions, 26 deletions
diff --git a/MainWindow.cpp b/MainWindow.cpp
index 5ac7291..e7ead5c 100644
--- a/MainWindow.cpp
+++ b/MainWindow.cpp
@@ -16,7 +16,7 @@
#include <string>
#include <iostream>
-#define WINDOW_TIMER 15
+#define WINDOW_TIMER 100
void f_onChangeSize(int w, int h) {
MainWindow::getInstance().onChangeSize(w, h);
@@ -31,10 +31,10 @@ void f_onTimer(int v) {
float hex2fColor(uint color, char num)
{
- char colors[3];
- colors[0] = (color & 0x0000FF) >> 0;
- colors[1] = (color & 0x00FF00) >> 8;
- colors[2] = (color & 0xFF0000) >> 16;
+ float colors[3];
+ colors[0] = (float) ((color & 0x0000FF) >> 0) / 256.;
+ colors[1] = (float) ((color & 0x00FF00) >> 8) / 256.;
+ colors[2] = (float) ((color & 0xFF0000) >> 16) / 256.;
return colors[num];
}
@@ -64,22 +64,6 @@ void MainWindow::onChangeSize(int w, int h)
void MainWindow::onRenderScene() {
// Clear Color and Depth Buffers
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
- /*glColor3f(0.3f, 0.5f, 0.7f);
-
- glBegin(GL_POLYGON);
- glVertex2f(-1,-1);
- glVertex2f(-1, 1);
- glVertex2f( 1, 1);
- glVertex2f( 1,-1);
- glEnd();
- glColor3f(0.3f, 0.7f, 0.5f);
- glBegin(GL_POLYGON);
- glVertex2f(-0.1,-0.1);
- glVertex2f( 0.1,-0.1);
- glVertex2f( 0.1, 0.1);
- glVertex2f(-0.1, 0.1);
- glEnd();*/
if(! m_pField == NULL)
{
@@ -93,11 +77,14 @@ void MainWindow::onRenderScene() {
{
for(uint coordY = 0; coordY < maxC.y; ++coordY)
{
+
Cell c = m_pField->getCell(Coordinates(coordX, coordY));
+
switch(c.getState())
{
case EMPTY_CELL:
- color = emptyColors[(coordX % 10 || coordY % 10 ? 0 : 1)];
+ color = emptyColors[((coordX % 10 == 0) || (coordY % 10 == 0) ? 0 : 1)];
+ std::cout << color <<std::endl;
glColor3f(hex2fColor(color, 0), hex2fColor(color, 1), hex2fColor(color, 2));
break;
case BOOM:
@@ -109,17 +96,23 @@ void MainWindow::onRenderScene() {
glColor3f(hex2fColor(color, 0), hex2fColor(color, 1), hex2fColor(color, 2));
break;
case PLAYER:
+ std::cout << "kapoué" << std::endl;
color = playerColors[c.getPlayer()->getNumber() % 4];
glColor3f(hex2fColor(color, 0)/2, hex2fColor(color, 1)/2, hex2fColor(color, 2)/2);
break;
}
- glBegin(GL_POLYGON);
+ //glBegin(GL_POLYGON);
+ // float floatCoordX = 2 * ((float) coordX / maxC.x) - 1;
+ // float floatCoordY = 2 * ((float) coordY / maxC.y) - 1;
+ // glVertex2f(floatCoordX , floatCoordY );
+ // glVertex2f(floatCoordX + GridStepX, floatCoordY );
+ // glVertex2f(floatCoordX , floatCoordY + GridStepY);
+ // glVertex2f(floatCoordX + GridStepX, floatCoordY + GridStepY);
+ //glEnd();
+ glBegin(GL_POINTS);
float floatCoordX = 2 * ((float) coordX / maxC.x) - 1;
float floatCoordY = 2 * ((float) coordY / maxC.y) - 1;
glVertex2f(floatCoordX , floatCoordY );
- glVertex2f(floatCoordX + GridStepX, floatCoordY );
- glVertex2f(floatCoordX , floatCoordY + GridStepY);
- glVertex2f(floatCoordX + GridStepX, floatCoordY + GridStepY);
glEnd();
}
}