47 lines
1009 B
C++
47 lines
1009 B
C++
#ifndef MESH_H
|
|
#define MESH_H
|
|
|
|
#include <vector>
|
|
#include <cmath>
|
|
#include <cstddef>
|
|
|
|
#include <QOpenGLFunctions_4_5_Core>
|
|
#include <QOpenGLShaderProgram>
|
|
#include <QTime>
|
|
|
|
#include "types.h"
|
|
#include "shader.h"
|
|
|
|
class Mesh: protected QOpenGLFunctions_4_5_Core
|
|
{
|
|
private:
|
|
std::vector<TypedVertex> m_vertices;
|
|
std::vector<GLuint> m_indexes;
|
|
|
|
// Mesh class do not own shaders objects.
|
|
// Deleted by Terrain class.
|
|
Shader* m_meshProgram;
|
|
Shader* m_normalProgram;
|
|
|
|
GLuint m_vao;
|
|
GLuint m_vbo;
|
|
GLuint m_ebo;
|
|
|
|
float m_blockWidth;
|
|
|
|
public:
|
|
Mesh(float blockWidth);
|
|
~Mesh();
|
|
void initGl(Shader *meshProgram, Shader *normalProgram);
|
|
void render(QMatrix4x4 &model);
|
|
void renderNormals(QMatrix4x4 &model);
|
|
GLuint addVertex(const TypedVertex &v);
|
|
GLuint addTriangle(GLuint v1, GLuint v2, GLuint v3);
|
|
void normalizeNormals();
|
|
void removeDoubles();
|
|
std::vector<GLuint>& indexes();
|
|
std::vector<TypedVertex>& vertices();
|
|
};
|
|
|
|
#endif // MESH_H
|