49 lines
1.3 KiB
C++
49 lines
1.3 KiB
C++
#ifndef VIEWCUBE_H
|
|
#define VIEWCUBE_H
|
|
|
|
#include <QOpenGLFunctions>
|
|
#include <QMatrix4x4>
|
|
#include <QOpenGLVertexArrayObject>
|
|
#include <QOpenGLBuffer>
|
|
#include <QPoint>
|
|
|
|
class QOpenGLShaderProgram;
|
|
class QOpenGLTexture;
|
|
class QPainter;
|
|
class QSvgRenderer;
|
|
|
|
class ViewCube : protected QOpenGLFunctions
|
|
{
|
|
public:
|
|
ViewCube();
|
|
~ViewCube();
|
|
|
|
void initializeGL();
|
|
void paintGL(QOpenGLShaderProgram* simpleShader, int simpleShaderColorLoc, const QMatrix4x4& viewMatrix, int width, int height, const QPoint& mousePos);
|
|
void paint2D(QPainter& painter, int widgetWidth, int widgetHeight);
|
|
bool handleMousePress(const QPoint& pos, int widgetWidth, int widgetHeight);
|
|
|
|
private:
|
|
void createFaceTextures();
|
|
void initShaders();
|
|
void setupBuffers();
|
|
void drawViewCube(const QMatrix4x4& projection, const QMatrix4x4& view, float opacity);
|
|
void drawAxes(QOpenGLShaderProgram* simpleShader, int colorLoc, const QMatrix4x4& projection, const QMatrix4x4& view);
|
|
|
|
bool m_isHovered = false;
|
|
QRect m_homeButtonRect;
|
|
QSvgRenderer* m_homeButtonRenderer = nullptr;
|
|
|
|
QOpenGLTexture* m_faceTextures[6];
|
|
|
|
QOpenGLShaderProgram* m_textureShaderProgram = nullptr;
|
|
|
|
QOpenGLVertexArrayObject m_cubeVao;
|
|
QOpenGLBuffer m_cubeVbo;
|
|
|
|
QOpenGLVertexArrayObject m_axesVao;
|
|
QOpenGLBuffer m_axesVbo;
|
|
};
|
|
|
|
#endif // VIEWCUBE_H
|