54 lines
1.0 KiB
C++
54 lines
1.0 KiB
C++
#ifndef OPENGL_WIDGET_HH
|
|
#define OPENGL_WIDGET_HH
|
|
|
|
#include "opengl_mesh.hh"
|
|
|
|
#include <QOpenGLWidget>
|
|
#include <QMatrix4x4>
|
|
#include <QOpenGLFunctions_4_4_Core>
|
|
#include <QOpenGLShaderProgram>
|
|
#include <QOpenGLVertexArrayObject>
|
|
#include <QOpenGLBuffer>
|
|
|
|
#define FOV 70
|
|
|
|
|
|
class OpenGLWidget : public QOpenGLWidget, public QOpenGLFunctions_4_4_Core {
|
|
Q_OBJECT
|
|
|
|
QMatrix4x4 rot, rot_start, proj;
|
|
GLfloat cam_dist = 1;
|
|
QPoint mouse_pos;
|
|
|
|
QOpenGLShaderProgram main_program;
|
|
QOpenGLShaderProgram skybox_program;
|
|
GLuint skybox_tex;
|
|
GLuint skybox_vao;
|
|
GLuint skybox_vbo;
|
|
|
|
void loadSkybox();
|
|
|
|
protected:
|
|
virtual void mousePressEvent(QMouseEvent *e);
|
|
virtual void mouseReleaseEvent(QMouseEvent *e);
|
|
virtual void mouseMoveEvent(QMouseEvent *e);
|
|
virtual void wheelEvent(QWheelEvent *e);
|
|
|
|
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
|