2022-05-10 10:06:48 +00:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
2011-06-08 15:42:42 +00:00
|
|
|
|
2011-05-11 15:35:46 +00:00
|
|
|
#ifndef MAINWIDGET_H
|
|
|
|
#define MAINWIDGET_H
|
|
|
|
|
2012-12-19 10:27:10 +00:00
|
|
|
#include "geometryengine.h"
|
2011-05-11 15:35:46 +00:00
|
|
|
|
2014-08-02 17:42:15 +00:00
|
|
|
#include <QOpenGLWidget>
|
|
|
|
#include <QOpenGLFunctions>
|
2011-05-11 15:35:46 +00:00
|
|
|
#include <QMatrix4x4>
|
|
|
|
#include <QQuaternion>
|
|
|
|
#include <QVector2D>
|
2012-12-19 10:27:10 +00:00
|
|
|
#include <QBasicTimer>
|
2014-08-02 17:42:15 +00:00
|
|
|
#include <QOpenGLShaderProgram>
|
|
|
|
#include <QOpenGLTexture>
|
2011-05-11 15:35:46 +00:00
|
|
|
|
|
|
|
class GeometryEngine;
|
|
|
|
|
2014-08-02 17:42:15 +00:00
|
|
|
class MainWidget : public QOpenGLWidget, protected QOpenGLFunctions
|
2011-05-11 15:35:46 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
2012-12-19 10:27:10 +00:00
|
|
|
|
2011-05-11 15:35:46 +00:00
|
|
|
public:
|
2019-09-13 18:43:09 +00:00
|
|
|
using QOpenGLWidget::QOpenGLWidget;
|
2012-12-19 10:27:10 +00:00
|
|
|
~MainWidget();
|
2011-05-11 15:35:46 +00:00
|
|
|
|
|
|
|
protected:
|
2016-06-15 08:12:35 +00:00
|
|
|
void mousePressEvent(QMouseEvent *e) override;
|
|
|
|
void mouseReleaseEvent(QMouseEvent *e) override;
|
|
|
|
void timerEvent(QTimerEvent *e) override;
|
2011-05-11 15:35:46 +00:00
|
|
|
|
2016-06-15 08:12:35 +00:00
|
|
|
void initializeGL() override;
|
|
|
|
void resizeGL(int w, int h) override;
|
|
|
|
void paintGL() override;
|
2011-05-11 15:35:46 +00:00
|
|
|
|
|
|
|
void initShaders();
|
|
|
|
void initTextures();
|
|
|
|
|
|
|
|
private:
|
2012-12-19 10:27:10 +00:00
|
|
|
QBasicTimer timer;
|
2014-08-02 17:42:15 +00:00
|
|
|
QOpenGLShaderProgram program;
|
2019-09-13 18:43:09 +00:00
|
|
|
GeometryEngine *geometries = nullptr;
|
2011-05-11 15:35:46 +00:00
|
|
|
|
2019-09-13 18:43:09 +00:00
|
|
|
QOpenGLTexture *texture = nullptr;
|
2011-05-11 15:35:46 +00:00
|
|
|
|
|
|
|
QMatrix4x4 projection;
|
|
|
|
|
|
|
|
QVector2D mousePressPosition;
|
|
|
|
QVector3D rotationAxis;
|
2019-09-13 18:43:09 +00:00
|
|
|
qreal angularSpeed = 0;
|
2011-05-11 15:35:46 +00:00
|
|
|
QQuaternion rotation;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // MAINWIDGET_H
|