aboutsummaryrefslogtreecommitdiff
path: root/src/opengl_widget.hh
diff options
context:
space:
mode:
authorccolin2021-01-04 17:37:49 +0100
committerccolin2021-01-04 17:37:49 +0100
commit03da9c5cf9fb6a0572814cd5332e5438cc21b00c (patch)
treef4e47aaf6b8b3c7aa32a67d90ce3ccbd26c3df73 /src/opengl_widget.hh
parent81108c1b0fa8f710ff7417476c10c83e70ae7a15 (diff)
replace the orbital cam by a free flying cam
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;