summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/glchessboard.cpp8
-rw-r--r--src/glchessboard.h2
2 files changed, 10 insertions, 0 deletions
diff --git a/src/glchessboard.cpp b/src/glchessboard.cpp
index afab9e8..c47fea5 100644
--- a/src/glchessboard.cpp
+++ b/src/glchessboard.cpp
@@ -30,3 +30,11 @@ void GLChessboard::drawBoard(GLESRenderer *renderer)
field.draw(renderer);
}
}
+
+QVector3D GLChessboard::fieldToPosition(const QPoint &field)
+{
+ double fieldWidth = m_width / 8;
+ double fieldHeight = m_height / 8;
+
+ return QVector3D(fieldWidth/2 + field.x() * fieldWidth, fieldHeight/2 + field.y() * fieldHeight, 0.0);
+}
diff --git a/src/glchessboard.h b/src/glchessboard.h
index c761aa8..12f8000 100644
--- a/src/glchessboard.h
+++ b/src/glchessboard.h
@@ -12,6 +12,8 @@ public:
void drawBoard(GLESRenderer *renderer);
+ QVector3D fieldToPosition(const QPoint & field);
+
private:
QVector<GLCube> m_fields;