OpenGL-utility/include/object.hpp

45 lines
1 KiB
C++
Raw Normal View History

2021-01-19 19:47:54 +01:00
#ifndef DRAWABLE_HPP
#define DRAWABLE_HPP
#include <core.hpp>
2021-01-19 19:47:54 +01:00
namespace oglu
{
2021-01-20 00:18:31 +01:00
typedef OGLU_API struct {
2021-01-19 19:47:54 +01:00
GLuint index;
GLint size;
GLenum type;
GLboolean normalized;
GLsizei stride;
const GLvoid* pointer;
} VertexAttribute;
2021-01-21 12:07:43 +01:00
class OGLU_API AbstractVertexArray
2021-01-19 19:47:54 +01:00
{
public:
2021-01-21 12:07:43 +01:00
AbstractVertexArray(const AbstractVertexArray& other);
~AbstractVertexArray();
2021-01-21 12:07:43 +01:00
friend std::shared_ptr<AbstractVertexArray> OGLU_API MakeObject(const GLfloat* vertices, size_t verticesSize, const GLuint* indices, size_t indicesSize, const VertexAttribute* topology, size_t topologySize);
2021-01-19 19:47:54 +01:00
GLuint GetVAO() { return VAO; }
2021-01-20 16:51:55 +01:00
void Bind();
void Unbind();
void Draw();
void BindAndDraw();
2021-01-19 19:47:54 +01:00
private:
2021-01-21 12:07:43 +01:00
AbstractVertexArray(const GLfloat* vertices, size_t verticesSize, const GLuint* indices, size_t indicesSize, const VertexAttribute* topology, size_t topologySize);
2021-01-20 16:51:55 +01:00
inline void RegisterVertexAttribPointer(GLuint index, const VertexAttribute& topology);
2021-01-21 01:26:14 +01:00
GLuint VAO, VBO, EBO;
2021-01-20 16:51:55 +01:00
GLsizei count;
2021-01-19 19:47:54 +01:00
};
2021-01-21 12:07:43 +01:00
typedef std::shared_ptr<AbstractVertexArray> VertexArray;
2021-01-19 19:47:54 +01:00
}
#endif