41 lines
835 B
C++
41 lines
835 B
C++
#ifndef VIEWPORTWIDGET_H
|
|
#define VIEWPORTWIDGET_H
|
|
|
|
#include <QOpenGLWidget>
|
|
#include <QOpenGLFunctions>
|
|
#include <QMatrix4x4>
|
|
#include <QPoint>
|
|
|
|
class ViewportWidget : public QOpenGLWidget, protected QOpenGLFunctions
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit ViewportWidget(QWidget *parent = nullptr);
|
|
|
|
protected:
|
|
void initializeGL() override;
|
|
void paintGL() override;
|
|
void resizeGL(int w, int h) override;
|
|
|
|
void mousePressEvent(QMouseEvent *event) override;
|
|
void mouseMoveEvent(QMouseEvent *event) override;
|
|
void wheelEvent(QWheelEvent *event) override;
|
|
|
|
private:
|
|
void drawCube();
|
|
void drawViewCube();
|
|
void drawAxes();
|
|
|
|
QMatrix4x4 projection;
|
|
|
|
float xRot = 0;
|
|
float yRot = 0;
|
|
float zoom = -5.0f;
|
|
float panX = 0;
|
|
float panY = 0;
|
|
QPoint lastPos;
|
|
};
|
|
|
|
#endif // VIEWPORTWIDGET_H
|