]> git.tdb.fi Git - libs/gl.git/blobdiff - source/core/device.cpp
Create a Device class to hold the graphics context
[libs/gl.git] / source / core / device.cpp
diff --git a/source/core/device.cpp b/source/core/device.cpp
new file mode 100644 (file)
index 0000000..9a24a1f
--- /dev/null
@@ -0,0 +1,29 @@
+#include "device.h"
+#include "error.h"
+
+namespace Msp {
+namespace GL {
+
+Device *Device::current = 0;
+
+Device::Device(Graphics::Window &w, const DeviceOptions &o):
+       DeviceBackend(w, o)
+{
+       current = this;
+}
+
+Device::~Device()
+{
+       if(this==current)
+               current = 0;
+}
+
+Device &Device::get_current()
+{
+       if(!current)
+               throw invalid_operation("no current device");
+       return *current;
+}
+
+} // namespace GL
+} // namespace Msp