summaryrefslogtreecommitdiffstats
path: root/src/glchessboard.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/glchessboard.cpp')
-rw-r--r--src/glchessboard.cpp32
1 files changed, 32 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);
+ }
+}