40 lines
1004 B
C++
40 lines
1004 B
C++
#ifndef VIEWCUBE_H
|
|
#define VIEWCUBE_H
|
|
|
|
#include <QOpenGLFunctions>
|
|
#include <QMatrix4x4>
|
|
#include <QOpenGLVertexArrayObject>
|
|
#include <QOpenGLBuffer>
|
|
|
|
class QOpenGLShaderProgram;
|
|
class QOpenGLTexture;
|
|
|
|
class ViewCube : protected QOpenGLFunctions
|
|
{
|
|
public:
|
|
ViewCube();
|
|
~ViewCube();
|
|
|
|
void initializeGL();
|
|
void paintGL(QOpenGLShaderProgram* simpleShader, int simpleShaderColorLoc, const QMatrix4x4& viewMatrix, int width, int height);
|
|
|
|
private:
|
|
void createFaceTextures();
|
|
void initShaders();
|
|
void setupBuffers();
|
|
void drawViewCube(const QMatrix4x4& projection, const QMatrix4x4& view);
|
|
void drawAxes(QOpenGLShaderProgram* simpleShader, int colorLoc, const QMatrix4x4& projection, const QMatrix4x4& view);
|
|
|
|
QOpenGLTexture* m_faceTextures[6];
|
|
|
|
QOpenGLShaderProgram* m_textureShaderProgram = nullptr;
|
|
|
|
QOpenGLVertexArrayObject m_cubeVao;
|
|
QOpenGLBuffer m_cubeVbo;
|
|
|
|
QOpenGLVertexArrayObject m_axesVao;
|
|
QOpenGLBuffer m_axesVbo;
|
|
};
|
|
|
|
#endif // VIEWCUBE_H
|