]> git.tdb.fi Git - libs/gl.git/blob - source/backends/opengl/systemframebuffer.cpp
Restructure system framebuffer and make WindowView own it
[libs/gl.git] / source / backends / opengl / systemframebuffer.cpp
1 #include <msp/gl/extensions/ext_framebuffer_object.h>
2 #include "gl.h"
3 #include "systemframebuffer.h"
4
5 namespace Msp {
6 namespace GL {
7
8 OpenGLSystemFramebuffer::OpenGLSystemFramebuffer():
9         Framebuffer(true)
10 {
11         FrameFormat sys_format;
12
13         if(EXT_framebuffer_object)
14         {
15                 int value;
16                 glGetFramebufferAttachmentParameteriv(GL_DRAW_FRAMEBUFFER, GL_BACK, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &value);
17                 if(value==GL_NONE)
18                         glGetFramebufferAttachmentParameteriv(GL_DRAW_FRAMEBUFFER, GL_FRONT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &value);
19                 if(value!=GL_NONE)
20                         sys_format = (sys_format, COLOR_ATTACHMENT);
21
22                 glGetFramebufferAttachmentParameteriv(GL_DRAW_FRAMEBUFFER, GL_DEPTH, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &value);
23                 if(value!=GL_NONE)
24                         sys_format = (sys_format, DEPTH_ATTACHMENT);
25
26                 glGetFramebufferAttachmentParameteriv(GL_DRAW_FRAMEBUFFER, GL_STENCIL, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &value);
27                 if(value!=GL_NONE)
28                         sys_format = (sys_format, STENCIL_ATTACHMENT);
29         }
30         else
31                 // Make a guess if we can't query the format
32                 sys_format = (COLOR_ATTACHMENT, DEPTH_ATTACHMENT);
33
34         set_system_format(sys_format);
35 }
36
37 void OpenGLSystemFramebuffer::resize(unsigned w, unsigned h)
38 {
39         resize_system(w, h);
40 }
41
42 } // namespace GL
43 } // namespace Msp