30 lines
902 B
C++
30 lines
902 B
C++
#include "GLObject.hpp"
|
|
|
|
/* A deleter function is required for freeing the memory allocated to the object (this could be, for example,
|
|
* glDeleteTextures for a Texture object, or a custom function that does something in addition to calling
|
|
* the appropriate GL deleter function) */
|
|
GLObject::GLObject(std::function<void(GLuint*)> deleter)
|
|
{
|
|
this->deleter = deleter;
|
|
}
|
|
|
|
/* Set the shared pointer to point to a new GLuint with specified ID value */
|
|
void GLObject::id(GLuint id)
|
|
{
|
|
/* The deleter will be called when the object and all of its copies have gone out of scope */
|
|
object_id = std::shared_ptr<GLuint>(new GLuint, deleter);
|
|
*object_id = id;
|
|
}
|
|
|
|
/* Return the GL ID that was set for this object */
|
|
GLuint GLObject::id() const
|
|
{
|
|
return *object_id;
|
|
}
|
|
|
|
/* Returns true if an ID has been generated */
|
|
bool GLObject::generated() const
|
|
{
|
|
return static_cast<bool>(object_id);
|
|
};
|