mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-10-17 12:09:19 +02:00
pch migration to modules [wip]
This commit is contained in:
33
gl/bindable.cppm
Normal file
33
gl/bindable.cppm
Normal file
@@ -0,0 +1,33 @@
|
||||
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
|
||||
Reference in New Issue
Block a user