]> git.tdb.fi Git - libs/gl.git/blobdiff - source/backends/opengl/systemframebuffer.cpp
Restructure system framebuffer and make WindowView own it
[libs/gl.git] / source / backends / opengl / systemframebuffer.cpp
diff --git a/source/backends/opengl/systemframebuffer.cpp b/source/backends/opengl/systemframebuffer.cpp
new file mode 100644 (file)
index 0000000..dbfe0b8
--- /dev/null
@@ -0,0 +1,43 @@
+#include <msp/gl/extensions/ext_framebuffer_object.h>
+#include "gl.h"
+#include "systemframebuffer.h"
+
+namespace Msp {
+namespace GL {
+
+OpenGLSystemFramebuffer::OpenGLSystemFramebuffer():
+       Framebuffer(true)
+{
+       FrameFormat sys_format;
+
+       if(EXT_framebuffer_object)
+       {
+               int value;
+               glGetFramebufferAttachmentParameteriv(GL_DRAW_FRAMEBUFFER, GL_BACK, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &value);
+               if(value==GL_NONE)
+                       glGetFramebufferAttachmentParameteriv(GL_DRAW_FRAMEBUFFER, GL_FRONT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &value);
+               if(value!=GL_NONE)
+                       sys_format = (sys_format, COLOR_ATTACHMENT);
+
+               glGetFramebufferAttachmentParameteriv(GL_DRAW_FRAMEBUFFER, GL_DEPTH, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &value);
+               if(value!=GL_NONE)
+                       sys_format = (sys_format, DEPTH_ATTACHMENT);
+
+               glGetFramebufferAttachmentParameteriv(GL_DRAW_FRAMEBUFFER, GL_STENCIL, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &value);
+               if(value!=GL_NONE)
+                       sys_format = (sys_format, STENCIL_ATTACHMENT);
+       }
+       else
+               // Make a guess if we can't query the format
+               sys_format = (COLOR_ATTACHMENT, DEPTH_ATTACHMENT);
+
+       set_system_format(sys_format);
+}
+
+void OpenGLSystemFramebuffer::resize(unsigned w, unsigned h)
+{
+       resize_system(w, h);
+}
+
+} // namespace GL
+} // namespace Msp