62 lines
1.5 KiB
C++
62 lines
1.5 KiB
C++
#pragma once
|
|
#include <QOpenGLWidget>
|
|
#include <QOpenGLFunctions>
|
|
#include <QOpenGLBuffer>
|
|
#include <QOPenGLVertexArrayObject>
|
|
#include <QOpenGlShaderProgram>
|
|
#include <QOpenGlTexture>
|
|
#include <QImage>
|
|
#include "..\Header\FileInterface.h"
|
|
|
|
struct Vertex {
|
|
GLfloat position[3];
|
|
GLfloat uv[2];
|
|
};
|
|
|
|
class OpenGlViewer : public QOpenGLWidget, protected QOpenGLFunctions
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
OpenGlViewer(QWidget *parent);
|
|
~OpenGlViewer();
|
|
|
|
private:
|
|
// OpenGL ======================================
|
|
int m_uniformMVP;
|
|
QOpenGLTexture* m_oglTexture;
|
|
QOpenGLBuffer m_vertexBuffer;
|
|
QOpenGLVertexArrayObject m_vertexArray;
|
|
QOpenGLShaderProgram* m_program = nullptr;
|
|
|
|
// Data ========================================
|
|
std::vector<Model*>* m_vModels = nullptr;
|
|
std::vector<QImage*>* m_vTextures = nullptr;
|
|
BoundingBox m_sceneBoundings;
|
|
|
|
// Transformation ==============================
|
|
float m_fRotX = 0;
|
|
float m_fRotY = 0;
|
|
float m_fRotZ = 0;
|
|
float m_fTranX = 0;
|
|
float m_fTranY = 0;
|
|
float m_fTranZ = 0;
|
|
|
|
// Camera ======================================
|
|
float m_fFOV = 45.0f;
|
|
float m_fMinView = 0.1f;
|
|
float m_fMaxView = 100.0f;
|
|
|
|
private:
|
|
virtual void initializeGL() override final;
|
|
virtual void paintGL() override final;
|
|
|
|
void printContextInformation();
|
|
QMatrix4x4 getModelMatrix(unsigned int index) const;
|
|
QMatrix4x4 getMVPMatrix(unsigned int index) const;
|
|
void deleteData();
|
|
|
|
public:
|
|
void setData(std::vector<Model*>* models, std::vector<QImage*>* textures, BoundingBox bbox);
|
|
};
|