summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/glchessboard.cpp32
-rw-r--r--src/glchessboard.h22
2 files changed, 54 insertions, 0 deletions
diff --git a/src/glchessboard.cpp b/src/glchessboard.cpp
new file mode 100644
index 0000000..afab9e8
--- /dev/null
+++ b/src/glchessboard.cpp
@@ -0,0 +1,32 @@
+#include "glchessboard.h"
+
+GLChessboard::GLChessboard(float width, float height)
+{
+ m_width = width;
+ m_height = height;
+}
+
+void GLChessboard::createBoard()
+{
+ double fieldWidth = m_width / 8;
+ double fieldHeight = m_height / 8;
+
+ for(int fieldY = 0; fieldY < 8; fieldY++)
+ {
+ for(int fieldX = 0; fieldX < 8; fieldX++)
+ {
+ if((fieldY+fieldX) % 2)
+ {
+ m_fields.append(GLCube(QVector3D(fieldX * fieldWidth, fieldY * fieldHeight, 0.0), QVector3D((fieldX + 1) * fieldWidth, (fieldY + 1) * fieldHeight, 0.0)));
+ }
+ }
+ }
+}
+
+void GLChessboard::drawBoard(GLESRenderer *renderer)
+{
+ foreach(GLCube field, m_fields)
+ {
+ field.draw(renderer);
+ }
+}
diff --git a/src/glchessboard.h b/src/glchessboard.h
new file mode 100644
index 0000000..c761aa8
--- /dev/null
+++ b/src/glchessboard.h
@@ -0,0 +1,22 @@
+#ifndef GLCHESSBOARD_H
+#define GLCHESSBOARD_H
+
+#include "glcube.h"
+
+class GLChessboard
+{
+public:
+ GLChessboard(float width, float height);
+
+ void createBoard();
+
+ void drawBoard(GLESRenderer *renderer);
+
+private:
+ QVector<GLCube> m_fields;
+
+ float m_width;
+ float m_height;
+};
+
+#endif // GLCHESSBOARD_H