SWBF2-Classic-Msh-Viewer/MeshViewerQt/Header/OpenGlViewer.h

68 lines
1.6 KiB
C
Raw Normal View History

#pragma once
#include <QOpenGLWidget>
#include <QOpenGLFunctions>
2016-12-10 13:42:00 +00:00
#include <QOpenGLBuffer>
#include <QOPenGLVertexArrayObject>
#include <QOpenGlShaderProgram>
2016-12-14 16:20:20 +00:00
#include "..\Header\Texture.h"
#include "..\Header\FileInterface.h"
struct Vertex {
GLfloat position[3];
GLfloat uv[2];
};
2016-12-14 16:20:20 +00:00
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();
2016-12-10 13:42:00 +00:00
private:
// OpenGL ======================================
int m_uniformMVP;
2016-12-14 16:20:20 +00:00
GLuint m_oglTexture;
GLuint m_vertexBuffer;
QOpenGLVertexArrayObject m_vertexArray;
QOpenGLShaderProgram* m_program = nullptr;
2016-12-10 13:42:00 +00:00
// Data ========================================
std::vector<Model*>* m_vModels = nullptr;
2016-12-14 16:20:20 +00:00
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;
2016-12-10 13:42:00 +00:00
private:
virtual void initializeGL() override final;
virtual void paintGL() override final;
2016-12-10 13:42:00 +00:00
void printContextInformation();
QMatrix4x4 getModelMatrix(unsigned int index) const;
QMatrix4x4 getMVPMatrix(unsigned int index) const;
void deleteData();
2016-12-10 13:42:00 +00:00
public:
2016-12-14 16:20:20 +00:00
void setData(std::vector<Model*>* models, std::vector<TextureData*>* textures, BoundingBox bbox);
};