Large OpenGL Object handling overhaul
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
#pragma once
|
||||
#ifndef _NB_OGL_OBJECTS
|
||||
#define _NB_OGL_OBJECTS
|
||||
|
||||
#include "GLLoad.hpp"
|
||||
|
||||
#include <NBCore/Errors.hpp>
|
||||
|
||||
namespace nb {
|
||||
|
||||
class OGLError : public Error<OGLError> {
|
||||
using Base = Error<OGLError>;
|
||||
|
||||
public:
|
||||
using Base::Base;
|
||||
|
||||
enum Codes : unsigned int {
|
||||
UNDEFINED, HANGING_OBJECT
|
||||
};
|
||||
|
||||
static const std::string type;
|
||||
static const ErrorCodeMap ErrorMessages;
|
||||
};
|
||||
|
||||
class OpenGLObject {
|
||||
public:
|
||||
OpenGLObject(const OpenGLObject&) = delete;
|
||||
OpenGLObject& operator=(const OpenGLObject&) = delete;
|
||||
~OpenGLObject() { remove(); }
|
||||
|
||||
virtual void bind() const = 0;
|
||||
virtual void unbind() const = 0;
|
||||
GLuint id() const { return _id; }
|
||||
|
||||
protected:
|
||||
OpenGLObject() = default;
|
||||
|
||||
virtual GLuint declare() = 0;
|
||||
virtual void remove() { this->remove(); };
|
||||
|
||||
GLuint _id;
|
||||
};
|
||||
|
||||
} // namespace nb
|
||||
#endif // _NB_OGL_OBJECTS
|
||||
Reference in New Issue
Block a user