mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-10-17 14:29:20 +02:00
34 lines
556 B
C++
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
|