aboutsummaryrefslogtreecommitdiff
path: root/src/opengl_widget.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/opengl_widget.hh')
-rw-r--r--src/opengl_widget.hh16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/opengl_widget.hh b/src/opengl_widget.hh
index abe226f..65c09b2 100644
--- a/src/opengl_widget.hh
+++ b/src/opengl_widget.hh
@@ -9,6 +9,7 @@
#include <QOpenGLShaderProgram>
#include <QOpenGLVertexArrayObject>
#include <QOpenGLBuffer>
+#include <QTimer>
#define FOV 70
@@ -26,8 +27,13 @@ class OpenGLWidget : public QOpenGLWidget, public QOpenGLExtraFunctions {
Q_OBJECT
QMatrix4x4 rot, rot_start, proj;
- GLfloat cam_dist = 1;
+ QMatrix4x4 trans;
QPoint mouse_pos;
+ QTimer move_timer;
+ bool move_forward = false;
+ bool move_back = false;
+ bool move_left = false;
+ bool move_right = false;
QOpenGLShaderProgram main_program;
QOpenGLShaderProgram skybox_program;
@@ -39,14 +45,20 @@ class OpenGLWidget : public QOpenGLWidget, public QOpenGLExtraFunctions {
void loadSkybox();
void loadGround();
+ bool keyEvent(QKeyEvent *e, bool press);
const Painter *painter = nullptr;
+private slots:
+ void move();
+
protected:
virtual void mousePressEvent(QMouseEvent *e);
virtual void mouseReleaseEvent(QMouseEvent *e);
virtual void mouseMoveEvent(QMouseEvent *e);
- virtual void wheelEvent(QWheelEvent *e);
+ virtual void keyPressEvent(QKeyEvent *e);
+ virtual void keyReleaseEvent(QKeyEvent *e);
+ virtual void focusOutEvent(QFocusEvent *e);
public:
static OpenGLWidget *instance;