removed vertex class (i have my own data structure)
implemented the glInit and glPaint function
This commit is contained in:
@@ -4,6 +4,8 @@
|
||||
#include <QOpenGLBuffer>
|
||||
#include <QOPenGLVertexArrayObject>
|
||||
#include <QOpenGlShaderProgram>
|
||||
#include <QOpenGlTexture>
|
||||
#include <QImage>
|
||||
#include "..\Header\MshFile.h"
|
||||
|
||||
struct Vertex {
|
||||
@@ -11,13 +13,6 @@ struct Vertex {
|
||||
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
|
||||
@@ -28,13 +23,15 @@ public:
|
||||
|
||||
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<textureData*> m_vTextures;
|
||||
std::vector<QImage*> m_vTextures;
|
||||
BoundingBox m_sceneBoundings;
|
||||
|
||||
// Transformation ==============================
|
||||
@@ -56,8 +53,9 @@ private:
|
||||
virtual void paintGL() override final;
|
||||
|
||||
void printContextInformation();
|
||||
QMatrix4x4 getMVPMatrix(unsigned int index) const;
|
||||
void deleteData();
|
||||
|
||||
public:
|
||||
void setData(std::vector<Model*>* models, std::vector<textureData*> textures);
|
||||
void setData(std::vector<Model*>* models, std::vector<QImage*> textures);
|
||||
};
|
||||
|
@@ -1,52 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <QVector3D>
|
||||
|
||||
class Vertex
|
||||
{
|
||||
public:
|
||||
// Constructors
|
||||
Q_DECL_CONSTEXPR Vertex();
|
||||
Q_DECL_CONSTEXPR explicit Vertex(const QVector3D &position);
|
||||
Q_DECL_CONSTEXPR Vertex(const QVector3D &position, const QVector3D &color);
|
||||
|
||||
// Accessors / Mutators
|
||||
Q_DECL_CONSTEXPR const QVector3D& position() const;
|
||||
Q_DECL_CONSTEXPR const QVector3D& color() const;
|
||||
void setPosition(const QVector3D& position);
|
||||
void setColor(const QVector3D& color);
|
||||
|
||||
// OpenGL Helpers
|
||||
static const int PositionTupleSize = 3;
|
||||
static const int ColorTupleSize = 3;
|
||||
static Q_DECL_CONSTEXPR int positionOffset();
|
||||
static Q_DECL_CONSTEXPR int colorOffset();
|
||||
static Q_DECL_CONSTEXPR int stride();
|
||||
|
||||
private:
|
||||
QVector3D m_position;
|
||||
QVector3D m_color;
|
||||
};
|
||||
|
||||
/*******************************************************************************
|
||||
* Inline Implementation
|
||||
******************************************************************************/
|
||||
|
||||
// Note: Q_MOVABLE_TYPE means it can be memcpy'd.
|
||||
Q_DECLARE_TYPEINFO(Vertex, Q_MOVABLE_TYPE);
|
||||
|
||||
// Constructors
|
||||
Q_DECL_CONSTEXPR inline Vertex::Vertex() {}
|
||||
Q_DECL_CONSTEXPR inline Vertex::Vertex(const QVector3D &position) : m_position(position) {}
|
||||
Q_DECL_CONSTEXPR inline Vertex::Vertex(const QVector3D &position, const QVector3D &color) : m_position(position), m_color(color) {}
|
||||
|
||||
// Accessors / Mutators
|
||||
Q_DECL_CONSTEXPR inline const QVector3D& Vertex::position() const { return m_position; }
|
||||
Q_DECL_CONSTEXPR inline const QVector3D& Vertex::color() const { return m_color; }
|
||||
void inline Vertex::setPosition(const QVector3D& position) { m_position = position; }
|
||||
void inline Vertex::setColor(const QVector3D& color) { m_color = color; }
|
||||
|
||||
// OpenGL Helpers
|
||||
Q_DECL_CONSTEXPR inline int Vertex::positionOffset() { return offsetof(Vertex, m_position); }
|
||||
Q_DECL_CONSTEXPR inline int Vertex::colorOffset() { return offsetof(Vertex, m_color); }
|
||||
Q_DECL_CONSTEXPR inline int Vertex::stride() { return sizeof(Vertex); }
|
Reference in New Issue
Block a user