Lots of stuff, ending with Window restruct
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include <NBGraphics/OGLObjects.hpp>
|
||||
#include <NBGraphics/Window.hpp>
|
||||
|
||||
#ifndef GLENUMSTRPAIR
|
||||
#define GLENUMSTRPAIR(x) {x, #x}
|
||||
@@ -10,7 +11,8 @@ const std::string OpenGLObjectError::type = "nb::OpenGLObjectError";
|
||||
const ErrorCodeMap OpenGLObjectError::ErrorMessages = {
|
||||
{ OpenGLObjectError::Codes::UNDEFINED, "Error" },
|
||||
{OpenGLObjectError::Codes::HANGING_OBJECT, "Attempting to leave a hanging OpenGL object"},
|
||||
{OpenGLObjectError::Codes::INVALID_OBJECT, "Attempting operation with invalid object"}
|
||||
{OpenGLObjectError::Codes::INVALID_OBJECT, "Attempting operation with invalid object"},
|
||||
{OpenGLObjectError::Codes::INVALID_CONTEXT, "Object not valid with current OpengGL context"}
|
||||
};
|
||||
|
||||
const std::string OpenGLError::type = "nb::OpenGLError";
|
||||
@@ -30,11 +32,28 @@ OpenGLError OpenGLError::status() {
|
||||
return OpenGLError(glGetError());
|
||||
}
|
||||
|
||||
OpenGLObject::OpenGLObject(OpenGLObject&& rval) {
|
||||
OpenGLError OpenGLError::status(const std::string& note) {
|
||||
return OpenGLError(glGetError(), note);
|
||||
}
|
||||
|
||||
|
||||
// class OpenGLObject
|
||||
|
||||
void OpenGLObject::checkObjectContextValidity() {
|
||||
if (_arena != OGLWindow::getCurrentObjectArena()) {
|
||||
THROW(OpenGLObjectError(OpenGLObjectError::INVALID_CONTEXT));
|
||||
}
|
||||
}
|
||||
|
||||
OpenGLObject::OpenGLObject(OpenGLObject&& rval) : _arena(rval._arena) {
|
||||
checkObjectContextValidity();
|
||||
*this = std::move(rval);
|
||||
}
|
||||
|
||||
OpenGLObject::OpenGLObject() : _arena(OGLWindow::getCurrentObjectArena()) {}
|
||||
|
||||
OpenGLObject& OpenGLObject::operator=(OpenGLObject&& rhs) {
|
||||
rhs.checkObjectContextValidity();
|
||||
if (_id) { THROW(OpenGLObjectError(Codes::HANGING_OBJECT)); }
|
||||
_id = rhs._id;
|
||||
rhs._id = 0;
|
||||
|
||||
Reference in New Issue
Block a user