2021-10-11 11:37:58 -04:00
|
|
|
#ifndef VERTEXBUFFER_H__
|
|
|
|
#define VERTEXBUFFER_H__
|
|
|
|
|
|
|
|
#include "define.h"
|
2021-12-12 23:31:38 -05:00
|
|
|
#include <mutex>
|
2021-10-11 11:37:58 -04:00
|
|
|
|
|
|
|
class VertexBuffer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
// Structure représentant toutes les informations de chacuns des vertex
|
|
|
|
// S'assurer que le size de cette struct reste un multiple de 32
|
|
|
|
// octet pour un maximum de performance
|
|
|
|
// Au besoin, ajouter du padding
|
|
|
|
struct VertexData
|
|
|
|
{
|
|
|
|
float x, y, z;
|
|
|
|
float r, g, b;
|
|
|
|
float u, v;
|
|
|
|
|
|
|
|
VertexData() {}
|
|
|
|
VertexData(float x, float y, float z, float r, float g, float b, float u, float v) : x(x), y(y), z(z), r(r), g(g), b(b), u(u), v(v) {}
|
|
|
|
};
|
|
|
|
|
|
|
|
public:
|
|
|
|
VertexBuffer();
|
|
|
|
~VertexBuffer();
|
|
|
|
|
|
|
|
bool IsValid() const;
|
|
|
|
void SetMeshData(VertexData* vd, int vertexCount);
|
|
|
|
void Render() const;
|
|
|
|
|
|
|
|
int Count() const;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
2021-12-13 23:24:12 -05:00
|
|
|
// static std::mutex m_opgl;
|
2021-10-11 11:37:58 -04:00
|
|
|
bool m_isValid;
|
|
|
|
int m_vertexCount;
|
|
|
|
GLuint m_vertexVboId;
|
|
|
|
GLuint m_indexVboId;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // VERTEXBUFFER_H__
|