]> git.tdb.fi Git - libs/gl.git/commitdiff
Remove the Bindable class
authorMikko Rasa <tdb@tdb.fi>
Sat, 28 Aug 2021 08:41:08 +0000 (11:41 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sat, 28 Aug 2021 08:46:20 +0000 (11:46 +0300)
It's no longer used anywere

source/core/batch.cpp
source/core/bindable.h [deleted file]
source/core/framebuffer.h
source/core/program.h
source/core/texture.cpp
source/core/texture1d.cpp
source/core/texture2d.cpp
source/core/texture3d.cpp
source/core/texturecube.cpp
source/core/vertexsetup.h
source/render/object.h

index 2bc44c9ddfe285c1dac5afa2fb2cd28ef63fba16..51746b37178a6345ca3e3ff1982a6bcdf7333e88 100644 (file)
@@ -1,7 +1,6 @@
 #include <msp/gl/extensions/arb_draw_instanced.h>
 #include <msp/gl/extensions/msp_primitive_restart.h>
 #include "batch.h"
-#include "bindable.h"
 #include "buffer.h"
 #include "error.h"
 #include "mesh.h"
diff --git a/source/core/bindable.h b/source/core/bindable.h
deleted file mode 100644 (file)
index b2634ea..0000000
+++ /dev/null
@@ -1,225 +0,0 @@
-#ifndef MSP_GL_BINDABLE_H_
-#define MSP_GL_BINDABLE_H_
-
-namespace Msp {
-namespace GL {
-
-/**
-A helper class for single-point binding.  Provides tracking of the currently
-bound object.
-*/
-template<typename T>
-class Bindable
-{
-protected:
-       static const T *cur_obj;
-
-       Bindable() { }
-       ~Bindable() { if(cur_obj==this) T::unbind(); }
-
-       static bool set_current(const T *obj)
-       {
-               if(obj==cur_obj)
-                       return false;
-
-               cur_obj = obj;
-               return true;
-       }
-
-public:
-       static const T *current() { return cur_obj; }
-};
-
-template<typename T>
-const T *Bindable<T>::cur_obj;
-
-
-/**
-A helper class for Bindables that revert to a default object on unbind.
-*/
-template<typename T>
-class BindableWithDefault: protected Bindable<T>
-{
-       friend class Bindable<T>;
-
-protected:
-       BindableWithDefault() { }
-       ~BindableWithDefault() { if(this==&default_object()) Bindable<T>::set_current(0); }
-
-public:
-       static const T *current()
-       {
-               if(!Bindable<T>::cur_obj)
-                       Bindable<T>::cur_obj = &default_object();
-               return Bindable<T>::cur_obj;
-       }
-
-       static void unbind()
-       {
-               if(Bindable<T>::cur_obj)
-                       default_object().bind();
-       }
-
-       static const T &default_object()
-       {
-               static T obj;
-               return obj;
-       }
-};
-
-
-/**
-RAII class for binding things.  Binds the thing upon construction and unbinds
-it upon destruction.  If a null pointer is given, unbinds upon construction and
-does nothing upon destruction.
-*/
-class Bind
-{
-private:
-       typedef void CleanupFunc(int);
-
-       int slot;
-       CleanupFunc *cleanup;
-
-public:
-       template<typename T>
-       Bind(T *o) { init(o); }
-
-       template<typename T>
-       Bind(const T *o) { init(o); }
-
-       template<typename T>
-       Bind(const T &o) { init(&o); }
-
-       template<typename T, typename S>
-       Bind(T *o, S s) { init(o, s); }
-
-       template<typename T, typename S>
-       Bind(const T *o, S s) { init(o, s); }
-
-       template<typename T, typename S>
-       Bind(const T &o, S s) { init(&o, s); }
-
-private:
-       template<typename T>
-       void init(const T *o)
-       {
-               cleanup = (o ? static_cast<CleanupFunc *>(&unbind<T>) : 0);
-               slot = 0;
-               if(o)
-                       o->bind();
-               else
-                       T::unbind();
-       }
-
-       template<typename T, typename S>
-       void init(const T *o, S s)
-       {
-               cleanup = (o ? static_cast<CleanupFunc *>(&unbind_from<T, S>) : 0);
-               slot = s;
-               if(o)
-                       o->bind_to(s);
-               else
-                       T::unbind_from(s);
-       }
-
-public:
-       ~Bind()
-       { if(cleanup) cleanup(slot); }
-
-private:
-       template<typename T>
-       static void unbind(int)
-       { T::unbind(); }
-
-       template<typename T, typename S>
-       static void unbind_from(int s)
-       { T::unbind_from(static_cast<S>(s)); }
-};
-
-
-/**
-Similar to Bind, but restores previous binding upon destruction.
-*/
-class BindRestore
-{
-private:
-       typedef void CleanupFunc(const void *, int);
-
-       const void *old;
-       int slot;
-       CleanupFunc *cleanup;
-
-public:
-       template<typename T>
-       BindRestore(T *o) { init(o); }
-
-       template<typename T>
-       BindRestore(const T *o) { init(o); }
-
-       template<typename T>
-       BindRestore(const T &o) { init(&o); }
-
-       template<typename T, typename S>
-       BindRestore(T *o, S s) { init(o, s); }
-
-       template<typename T, typename S>
-       BindRestore(const T *o, S s) { init(o, s); }
-
-       template<typename T, typename S>
-       BindRestore(const T &o, S s) { init(&o, s); }
-
-private:
-       template<typename T>
-       void init(T *o)
-       {
-               old = T::current();
-               slot = 0;
-               cleanup = (o!=old ? static_cast<CleanupFunc *>(&restore<T>) : 0);
-               if(o)
-                       o->bind();
-               else if(old)
-                       T::unbind();
-       }
-
-       template<typename T, typename S>
-       void init(T *o, S s)
-       {
-               old = T::current(s);
-               slot = s;
-               cleanup = (o!=old ? static_cast<CleanupFunc *>(&restore_to<T, S>) : 0);
-               if(o)
-                       o->bind_to(s);
-               else if(old)
-                       T::unbind_from(s);
-       }
-
-public:
-       ~BindRestore()
-       { if(cleanup) cleanup(old, slot); }
-
-private:
-       template<typename T>
-       static void restore(const void *o, int)
-       {
-               if(o)
-                       reinterpret_cast<const T *>(o)->bind();
-               else
-                       T::unbind();
-       }
-
-       template<typename T, typename S>
-       static void restore_to(const void *o, int si)
-       {
-               S s = static_cast<S>(si);
-               if(o)
-                       reinterpret_cast<const T *>(o)->bind_to(s);
-               else
-                       T::unbind_from(s);
-       }
-};
-
-} // namespace GL
-} // namespace Msp
-
-#endif
index 2e1b367791f7f7065d0634df1845a1854876b050..275f516e8d4d3b22acca3393a48065cb5d5422fb 100644 (file)
@@ -2,7 +2,6 @@
 #define MSP_GL_FRAMEBUFFER_H_
 
 #include <vector>
-#include "bindable.h"
 #include "gl.h"
 #include "texturecube.h"
 #include <msp/gl/extensions/arb_geometry_shader4.h>
index a494e0798f5d67ef5ecaf7f770d7e289a06bc150..f2d7d07672643edb8c83dd4a214bd45a7594be4b 100644 (file)
@@ -4,7 +4,6 @@
 #include <string>
 #include <vector>
 #include <msp/datafile/objectloader.h>
-#include "bindable.h"
 #include "datatype.h"
 #include "gl.h"
 #include "module.h"
index 3adc511e23ca2640d0ed7e5a4fc6644b50a65c40..347634d4c27fa204d169c6a731f39139165f3213 100644 (file)
@@ -3,7 +3,6 @@
 #include <msp/gl/extensions/ext_framebuffer_object.h>
 #include <msp/gl/extensions/khr_debug.h>
 #include <msp/io/memory.h>
-#include "bindable.h"
 #include "error.h"
 #include "resourcemanager.h"
 #include "resources.h"
index 7685d39e99abaeca025ae1c4750b6a53903ff08a..4c58d4701639d777b0471b846acc7717d480c90b 100644 (file)
@@ -2,7 +2,6 @@
 #include <msp/gl/extensions/arb_direct_state_access.h>
 #include <msp/gl/extensions/arb_texture_storage.h>
 #include <msp/gl/extensions/msp_texture1d.h>
-#include "bindable.h"
 #include "error.h"
 #include "texture1d.h"
 
index 528c4a58d216416ad2ca9816852bd0a7001d2a9e..b5194858b480483ebe5cf45719f41c9502b67d71 100644 (file)
@@ -2,7 +2,6 @@
 #include <msp/gl/extensions/arb_direct_state_access.h>
 #include <msp/gl/extensions/arb_texture_storage.h>
 #include <msp/graphics/imageloader.h>
-#include "bindable.h"
 #include "buffer.h"
 #include "error.h"
 #include "resources.h"
index ab8bca7cba1c8cfd4f5598b73c8dfa759d96488c..768af91233aa6158c7d336d98a6386e3fa634f5c 100644 (file)
@@ -5,7 +5,6 @@
 #include <msp/gl/extensions/ext_texture3d.h>
 #include <msp/gl/extensions/ext_texture_array.h>
 #include <msp/graphics/image.h>
-#include "bindable.h"
 #include "error.h"
 #include "texture3d.h"
 
index 5c7f61029c3c736eb3245e99b559b29c7e79f2aa..ae06557dfe2ae40fa26ab9700e6a628ed0f5f7fc 100644 (file)
@@ -5,7 +5,6 @@
 #include <msp/gl/extensions/arb_texture_storage.h>
 #include <msp/io/memory.h>
 #include <msp/strings/format.h>
-#include "bindable.h"
 #include "error.h"
 #include "texturecube.h"
 
index 408d738012fb196be44555c3bb25b9fe9672582a..7eb903aeae9f819e43258c0b510bfebba638c73f 100644 (file)
@@ -1,7 +1,6 @@
 #ifndef MSP_GL_VERTEXSETUP_H_
 #define MSP_GL_VERTEXSETUP_H_
 
-#include "bindable.h"
 #include "vertexformat.h"
 
 namespace Msp {
index 522d3adc335be01519e8c69df5a9a952c9b7129f..b7b549536f4b92bd97c0ee9506e8ab3c48d42111 100644 (file)
@@ -2,7 +2,6 @@
 #define MSP_GL_OBJECT_H_
 
 #include <vector>
-#include "bindable.h"
 #include "renderable.h"
 #include "renderpass.h"
 #include "resourceobserver.h"