m2-ar-projet/src/opengl_widget.hh

54 lines
1.0 KiB
C++
Raw Normal View History

2020-12-22 13:15:23 +01:00
#ifndef OPENGL_WIDGET_HH
#define OPENGL_WIDGET_HH
#include "opengl_mesh.hh"
#include <QOpenGLWidget>
#include <QMatrix4x4>
#include <QOpenGLFunctions_4_4_Core>
#include <QOpenGLShaderProgram>
2020-12-28 17:36:45 +01:00
#include <QOpenGLVertexArrayObject>
#include <QOpenGLBuffer>
2020-12-22 13:15:23 +01:00
#define FOV 70
class OpenGLWidget : public QOpenGLWidget, public QOpenGLFunctions_4_4_Core {
Q_OBJECT
2020-12-28 17:36:45 +01:00
QMatrix4x4 rot, rot_start, proj;
2020-12-22 16:35:25 +01:00
GLfloat cam_dist = 1;
QPoint mouse_pos;
2020-12-28 17:36:45 +01:00
QOpenGLShaderProgram main_program;
QOpenGLShaderProgram skybox_program;
GLuint skybox_tex;
GLuint skybox_vao;
GLuint skybox_vbo;
void loadSkybox();
2020-12-22 16:35:25 +01:00
protected:
virtual void mousePressEvent(QMouseEvent *e);
virtual void mouseReleaseEvent(QMouseEvent *e);
virtual void mouseMoveEvent(QMouseEvent *e);
virtual void wheelEvent(QWheelEvent *e);
2020-12-22 13:15:23 +01:00
public:
static OpenGLWidget *instance;
QVector<OpenGLMesh> meshes;
OpenGLWidget(QWidget *parent=nullptr);
~OpenGLWidget();
void initializeGL() override;
void resizeGL(int w, int h) override;
void paintGL() override;
signals:
void initialized();
};
#endif