diff options
author | jjesswan <jessica_wan@brown.edu> | 2024-04-22 21:56:26 -0400 |
---|---|---|
committer | jjesswan <jessica_wan@brown.edu> | 2024-04-22 21:56:26 -0400 |
commit | a556b45abf18f1bd509daaf63b66b7d55e9fd291 (patch) | |
tree | bc9b8a2d184c12aee236e7f9f276a34b84ca552d /engine-ocean/Graphics/GLWrappers/vao.h | |
parent | cd7c76017a12bb548036571c1ff13e551369d06d (diff) |
add engine version
Diffstat (limited to 'engine-ocean/Graphics/GLWrappers/vao.h')
-rw-r--r-- | engine-ocean/Graphics/GLWrappers/vao.h | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/engine-ocean/Graphics/GLWrappers/vao.h b/engine-ocean/Graphics/GLWrappers/vao.h new file mode 100644 index 0000000..8f9bc6a --- /dev/null +++ b/engine-ocean/Graphics/GLWrappers/vao.h @@ -0,0 +1,42 @@ +#pragma once + +#include "vbo.h" +#include <memory> + +enum class VAOAttrib{ + POS = 1, + NORM = 2, + UV = 4, + COLOR = 8 +}; + +inline VAOAttrib operator|(VAOAttrib lhs, VAOAttrib rhs){ + using VAOAttribType = std::underlying_type<VAOAttrib>::type; + return VAOAttrib(static_cast<VAOAttribType>(lhs) | static_cast<VAOAttribType>(rhs)); +} + +inline bool operator&(VAOAttrib lhs, VAOAttrib rhs){ + using VAOAttribType = std::underlying_type<VAOAttrib>::type; + return static_cast<bool>(VAOAttrib(static_cast<VAOAttribType>(lhs) & static_cast<VAOAttribType>(rhs))); +} + +class VAO +{ +public: + VAO(std::shared_ptr<VBO> vbo, VAOAttrib attribs); + ~VAO(); + + void bind(); + void unbind(); + + void draw(); + +private: + void addAttribute(GLuint attrib_index, GLint attrib_size); + + std::shared_ptr<VBO> m_vbo; + GLuint m_handle; + GLint m_curr_offset; + GLuint m_vert_size; + +};
\ No newline at end of file |