12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- #ifndef VERTEXBUFFER_H
- #define VERTEXBUFFER_H
- #include "data/ArrayList.h"
- #include "rendering/GL.h"
- #include "utils/Buffer.h"
- #include "utils/TypedBuffer.h"
- class VertexBuffer final {
- GL::VertexArray vertexArray;
- GL::Buffer vertexBuffer;
- int size;
- public:
- class Attributes final {
- ArrayList<GL::Attribute, 10> attributes;
- friend class VertexBuffer;
- public:
- Attributes& addFloat(int count);
- Attributes& addColor4();
- Attributes& addSpacer();
- private:
- void set() const;
- };
- VertexBuffer();
- ~VertexBuffer();
- VertexBuffer(const VertexBuffer& other) = delete;
- VertexBuffer(VertexBuffer&& other) = delete;
- VertexBuffer& operator=(const VertexBuffer& other) = delete;
- VertexBuffer& operator=(VertexBuffer&& other) = delete;
- void init(const Attributes& attributes);
- void setData(int size, const void* data, GL::BufferUsage usage);
- void setData(const Buffer& buffer, GL::BufferUsage usage);
- template<typename T>
- void setData(GL::BufferUsage usage, const TypedBuffer<T>& buffer) {
- setData(buffer.getByteLength(), buffer, usage);
- }
- void updateData(int offset, int size, const void* data);
- void draw(int vertices, int offset = 0);
- void drawStrip(int vertices, int offset = 0);
- void drawPoints(int vertices, int offset = 0);
- int getSize() const;
- private:
- void bindArray() const;
- void bindBuffer() const;
- };
- #endif
|