#pragma once #include "vbo.h" #include enum class VAOAttrib{ POS = 1, NORM = 2, UV = 4, COLOR = 8 }; inline VAOAttrib operator|(VAOAttrib lhs, VAOAttrib rhs){ using VAOAttribType = std::underlying_type::type; return VAOAttrib(static_cast(lhs) | static_cast(rhs)); } inline bool operator&(VAOAttrib lhs, VAOAttrib rhs){ using VAOAttribType = std::underlying_type::type; return static_cast(VAOAttrib(static_cast(lhs) & static_cast(rhs))); } class VAO { public: VAO(std::shared_ptr vbo, VAOAttrib attribs); ~VAO(); void bind(); void unbind(); void draw(); private: void addAttribute(GLuint attrib_index, GLint attrib_size); std::shared_ptr m_vbo; GLuint m_handle; GLint m_curr_offset; GLuint m_vert_size; };