Files
maszyna/gl/bindable.h
2018-10-14 21:52:37 +02:00

28 lines
487 B
C++

#pragma once
namespace gl
{
template <typename T>
class bindable
{
protected:
static bindable<T>* active;
public:
void bind()
{
if (active == this)
return;
active = this;
T::bind(*static_cast<T*>(active));
}
static void unbind()
{
active = nullptr;
T::bind(0);
}
};
template <typename T> bindable<T>* bindable<T>::active;
}