51 lines
1.2 KiB
C++
51 lines
1.2 KiB
C++
// Basé sur :
|
|
// CC-BY Edouard.Thiel@univ-amu.fr - 22/01/2019
|
|
|
|
#ifndef GLAREA_H
|
|
#define GLAREA_H
|
|
|
|
#include <QKeyEvent>
|
|
#include <QOpenGLWidget>
|
|
#include <QOpenGLExtraFunctions>
|
|
#include <QOpenGLBuffer>
|
|
#include <QOpenGLShaderProgram>
|
|
#include <QOpenGLTexture>
|
|
#include <QColor>
|
|
|
|
|
|
class GLArea : public QOpenGLWidget,
|
|
protected QOpenGLExtraFunctions
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit GLArea(QWidget *parent = nullptr);
|
|
~GLArea() override;
|
|
|
|
signals:
|
|
void onInit(QOpenGLExtraFunctions *glf);
|
|
void onPaint(QOpenGLExtraFunctions *glf,
|
|
const QMatrix4x4 &projection,
|
|
const QMatrix4x4 &view);
|
|
|
|
protected:
|
|
void initializeGL() override;
|
|
void doProjection();
|
|
void resizeGL(int w, int h) override;
|
|
void paintGL() override;
|
|
void keyPressEvent(QKeyEvent *ev) override;
|
|
void keyReleaseEvent(QKeyEvent *ev) override;
|
|
void mousePressEvent(QMouseEvent *ev) override;
|
|
void mouseReleaseEvent(QMouseEvent *ev) override;
|
|
void mouseMoveEvent(QMouseEvent *ev) override;
|
|
|
|
private:
|
|
float xRot=20.0f, yRot=0.0f, zRot=0.0f;
|
|
float xPos=0.0f, yPos=0.0f, zPos=-50.0f;
|
|
float dt = 0;
|
|
float windowRatio = 1.0f;
|
|
QPoint lastPos;
|
|
};
|
|
|
|
#endif // GLAREA_H
|