add initial Array class
This commit is contained in:
parent
e9cdd72ffc
commit
f8de8368bb
@ -1,9 +1,10 @@
|
||||
#ifndef GLCXX_HPP
|
||||
#define GLCXX_HPP
|
||||
|
||||
#include "glcxx/Array.hpp"
|
||||
#include "glcxx/Buffer.hpp"
|
||||
#include "glcxx/Error.hpp"
|
||||
#include "glcxx/Program.hpp"
|
||||
#include "glcxx/Shader.hpp"
|
||||
#include "glcxx/Error.hpp"
|
||||
|
||||
#endif
|
||||
|
31
include/glcxx/Array.hpp
Normal file
31
include/glcxx/Array.hpp
Normal file
@ -0,0 +1,31 @@
|
||||
#ifndef GLCXX_ARRAY_HPP
|
||||
#define GLCXX_ARRAY_HPP
|
||||
|
||||
#include "glcxx/gl.hpp"
|
||||
|
||||
namespace glcxx
|
||||
{
|
||||
class Array
|
||||
{
|
||||
public:
|
||||
Array();
|
||||
|
||||
~Array();
|
||||
|
||||
void create();
|
||||
|
||||
void bind()
|
||||
{
|
||||
glBindVertexArray(m_id);
|
||||
}
|
||||
|
||||
GLuint id() const { return m_id; }
|
||||
|
||||
bool valid() const { return m_id > 0u; }
|
||||
|
||||
protected:
|
||||
GLuint m_id;
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
28
src/glcxx/Array.cpp
Normal file
28
src/glcxx/Array.cpp
Normal file
@ -0,0 +1,28 @@
|
||||
#include "glcxx/Array.hpp"
|
||||
#include "glcxx/Error.hpp"
|
||||
|
||||
namespace glcxx
|
||||
{
|
||||
Array::Array()
|
||||
{
|
||||
m_id = 0u;
|
||||
}
|
||||
|
||||
Array::~Array()
|
||||
{
|
||||
if (m_id != 0u)
|
||||
{
|
||||
glDeleteVertexArrays(1, &m_id);
|
||||
}
|
||||
}
|
||||
|
||||
void Array::create()
|
||||
{
|
||||
glGenVertexArrays(1, &m_id);
|
||||
|
||||
if (m_id == 0u)
|
||||
{
|
||||
throw Error("Failed to allocate an OpenGL array");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user