2 #ifndef KJY_OBJECT_ORIENTED_OPENGL_CORE_HPP_ 3 #define KJY_OBJECT_ORIENTED_OPENGL_CORE_HPP_ 16 enum oglbindstatus :
unsigned int {BINDINGS_CLEAN = 0U, BINDINGS_UNCLEAN = 1U, BINDINGS_UNKNOWN = 2U};
17 static unsigned int binding_purity = BINDINGS_CLEAN;
19 enum class GpuSyncStatus : unsigned int {GPU_CURRENT = 1, GPU_STALE, GPU_ONLY, GPU_UNINITIALIZED};
23 typedef void (*OglObjectDestroyer)(
const GLuint* id);
27 virtual GLuint getName()
const = 0;
28 operator GLuint()
const{
return(getName());}
35 MutableOglName(OglObjectDestroyer destroyer) : destroyer(destroyer){}
36 MutableOglName(GLuint
id, OglObjectDestroyer destroyer) : oglID(
id), destroyer(destroyer){}
38 GLuint* getIdPtr(){
return(&oglID);}
39 const GLuint* getIdPtr()
const {
return(&oglID);}
40 virtual GLuint getName()
const override {
return(oglID);}
41 inline GLuint getNameDirect()
const {
return(oglID);}
42 const OglObjectDestroyer getDestroyer(){
return(destroyer);}
45 virtual void makeZombie() {
if(destroyer !=
nullptr) {destroyer(&oglID);} oglID = 0; _is_zombie_ =
true;}
46 virtual bool isZombie()
const {
return(_is_zombie_);}
50 const OglObjectDestroyer destroyer =
nullptr;
51 bool _is_zombie_ =
false;
56 ConstOglName(OglObjectDestroyer destroyer) : destroyer(destroyer) {}
57 ConstOglName(GLuint
id, OglObjectDestroyer destroyer) : oglID(
id), destroyer(destroyer) {}
59 ~
ConstOglName() {
if(destroyer !=
nullptr) destroyer(&oglID);}
60 const GLuint* getIdPtr()
const {
return(&oglID);}
61 virtual GLuint getName()
const override {
return(oglID);}
62 inline GLuint getNameDirect()
const {
return(oglID);}
63 const OglObjectDestroyer getDestroyer(){
return(destroyer);}
65 const GLuint oglID = 0;
66 const OglObjectDestroyer destroyer =
nullptr;
71 virtual bool isPossessible()
const = 0;
77 PersistentOglName(OglObjectDestroyer destroyer) : std::shared_ptr<MutableOglName>(std::make_shared<MutableOglName>(destroyer)) {}
78 PersistentOglName(GLuint
id, OglObjectDestroyer destroyer) : std::shared_ptr<MutableOglName>(std::make_shared<MutableOglName>(id, destroyer)) {}
80 GLuint* getIdPtr(){
return(
get()->getIdPtr());}
81 const GLuint* getIdPtr()
const {
return(
get()->getIdPtr());}
82 virtual GLuint getName()
const override {
return(
get()->getNameDirect());}
83 inline GLuint getNameDirect()
const {
return(
get()->getNameDirect());}
84 virtual bool isPossessible()
const override {
return(
true);}
86 virtual void makeZombie() {
get()->makeZombie();}
87 virtual bool isZombie()
const {
return(
get() ==
nullptr ||
get()->isZombie());}
95 ConstPersistentOglName(OglObjectDestroyer destroyer) : std::shared_ptr<ConstOglName>(std::make_shared<ConstOglName>(destroyer)) {}
96 ConstPersistentOglName(GLuint
id, OglObjectDestroyer destroyer) : std::shared_ptr<ConstOglName>(std::make_shared<ConstOglName>(id, destroyer)) {}
99 const GLuint* getIdPtr()
const {
return(
get()->getIdPtr());}
100 virtual GLuint getName()
const override {
return(
get()->getNameDirect());}
101 inline GLuint getNameDirect()
const {
return(
get()->getNameDirect());}
102 virtual bool isPossessible()
const override {
return(
true);}
121 template<
class Possessible,
class... Possessibles>
123 static_assert(std::is_base_of<PossessibleInteraface, Possessible>::value);
127 virtual size_t numPossessed()
const = 0;
128 virtual void possessObject(Possessible t) = 0;
129 virtual bool doesPossessObject(Possessible t)
const = 0;
130 virtual void dispossessObject(
const Possessible&
object) = 0;
135 virtual const std::string& getTag()
const {
return(tag);}
136 virtual void setTag(
const std::string& tag) {this->tag = tag;}
146 virtual const char* what()
const noexcept
override{
147 return(
"Base OOOGL graphics exception");
154 : file(file), linenum(line), tag(tag),
155 _whatstr_(
"Missing implementation for " + tag +
" at " + file +
":" +
"line")
157 virtual const char* what()
const noexcept
override{
158 return(_whatstr_.c_str());
162 const std::string file;
164 const std::string tag;
167 const std::string _whatstr_;
172 GenericIndexOutOfBoundsException(
size_t index,
const std::string& note = std::string()) : index(index), _whatstr_(
"Index out of bounds exception with index '" + std::to_string(index) +
"'" + (note.empty() ?
"" :
" with note: " + note)) {}
173 virtual const char* what()
const noexcept
override{
174 return(_whatstr_.c_str());
178 const std::string _whatstr_;
Definition: OOOGL_Core.hpp:33
Definition: OOOGL_Core.hpp:92
Definition: OOOGL_Core.hpp:119
Definition: OOOGL_Core.hpp:133
Definition: OOOGL_Core.hpp:144
Definition: OOOGL_Core.hpp:105
Definition: OOOGL_Core.hpp:151
Definition: OOOGL_Core.hpp:170
Definition: OOOGL_Core.hpp:74
Definition: OOOGL_Core.hpp:70
Definition: OOOGL_Core.hpp:54
Definition: OOOGL_Core.hpp:25
Definition: Core_Utilities.cpp:3