68 lines
1.6 KiB
C++
68 lines
1.6 KiB
C++
#pragma once
|
|
#include <QOpenGLWidget>
|
|
#include <QOpenGLFunctions>
|
|
#include <QOpenGLBuffer>
|
|
#include <QOPenGLVertexArrayObject>
|
|
#include <QOpenGlShaderProgram>
|
|
#include "..\Header\Texture.h"
|
|
#include "..\Header\FileInterface.h"
|
|
|
|
struct Vertex {
|
|
GLfloat position[3];
|
|
GLfloat uv[2];
|
|
};
|
|
|
|
struct TextureData {
|
|
bool alpha;
|
|
std::uint32_t width;
|
|
std::uint32_t height;
|
|
std::vector<std::uint8_t>* data;
|
|
};
|
|
|
|
class OpenGlViewer : public QOpenGLWidget, protected QOpenGLFunctions
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
OpenGlViewer(QWidget *parent);
|
|
~OpenGlViewer();
|
|
|
|
private:
|
|
// OpenGL ======================================
|
|
int m_uniformMVP;
|
|
GLuint m_oglTexture;
|
|
GLuint m_vertexBuffer;
|
|
QOpenGLVertexArrayObject m_vertexArray;
|
|
QOpenGLShaderProgram* m_program = nullptr;
|
|
|
|
// Data ========================================
|
|
std::vector<Model*>* m_vModels = nullptr;
|
|
std::vector<TextureData*>* 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<TextureData*>* textures, BoundingBox bbox);
|
|
};
|