17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-17 03:59:19 +02:00
Files
maszyna/gl/bindable.cppm
2026-09-09 20:35:26 +02:00

34 lines
556 B
C++

module;
export module eu07.gl.bindable;
export {
namespace gl
{
template <typename T>
class bindable
{
protected:
thread_local 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> thread_local bindable<T>* bindable<T>::active;
}
} // export