diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-04-17 22:43:51 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-04-17 22:43:51 +0100 |
commit | 9b0828ea5bb6cb4e92d6019785b3ceb88e2a58be (patch) | |
tree | fad012153b02c786c3471e2e70119feaf5b8fe43 /gfx/gl | |
parent | Revamp how VertexArrayObject configures attributes and data (diff) | |
download | ilt-9b0828ea5bb6cb4e92d6019785b3ceb88e2a58be.tar.bz2 ilt-9b0828ea5bb6cb4e92d6019785b3ceb88e2a58be.tar.xz ilt-9b0828ea5bb6cb4e92d6019785b3ceb88e2a58be.zip |
Separate storing of mesh vertex/index data from configuring VAO
Diffstat (limited to 'gfx/gl')
-rw-r--r-- | gfx/gl/vertexArrayObject.hpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/gfx/gl/vertexArrayObject.hpp b/gfx/gl/vertexArrayObject.hpp index 3e2a18b..8c828c8 100644 --- a/gfx/gl/vertexArrayObject.hpp +++ b/gfx/gl/vertexArrayObject.hpp @@ -7,7 +7,7 @@ class VertexArrayObject { public: - [[nodiscard]] VertexArrayObject(const GLuint arrayObject) + template<typename T> [[nodiscard]] VertexArrayObject(const T & arrayObject) { glBindVertexArray(arrayObject); } @@ -54,7 +54,13 @@ public: return *this; } -private: + VertexArrayObject & + addIndices(const GLuint arrayBuffer) + { + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, arrayBuffer); + return *this; + } + template<typename Data> static void data(const Data & data, const GLuint arrayBuffer, GLenum target) @@ -64,6 +70,7 @@ private: glBufferData(target, static_cast<GLsizeiptr>(sizeof(Value) * data.size()), data.data(), GL_STATIC_DRAW); } +private: template<typename VertexT, typename T> static void set_pointer(const GLuint vertexArrayId, const void * ptr) |