From: Mikko Rasa Date: Sun, 19 Sep 2021 11:04:02 +0000 (+0300) Subject: Query the attachments of the default framebuffer X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=d6122b75b00c0889a54536b5cea971d08184af8f;p=libs%2Fgl.git Query the attachments of the default framebuffer The exact pixel formats are unimportant for now and would be somewhat convoluted to query. --- diff --git a/source/core/framebuffer.cpp b/source/core/framebuffer.cpp index 1dd2f61f..01a41074 100644 --- a/source/core/framebuffer.cpp +++ b/source/core/framebuffer.cpp @@ -34,6 +34,24 @@ Framebuffer::Framebuffer(unsigned i): if(id) throw invalid_argument("System framebuffer must have id 0"); + if(EXT_framebuffer_object) + { + int value; + glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_BACK, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &value); + if(value==GL_NONE) + glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_FRONT, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &value); + if(value!=GL_NONE) + format = (format,COLOR_ATTACHMENT); + + glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_DEPTH, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &value); + if(value!=GL_NONE) + format = (format,DEPTH_ATTACHMENT); + + glGetFramebufferAttachmentParameteriv(GL_FRAMEBUFFER, GL_STENCIL, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &value); + if(value!=GL_NONE) + format = (format,STENCIL_ATTACHMENT); + } + int view[4]; glGetIntegerv(GL_VIEWPORT, view); width = view[2]; @@ -80,7 +98,7 @@ Framebuffer::~Framebuffer() void Framebuffer::set_format(const FrameFormat &fmt) { - if(!format.empty()) + if(!format.empty() || !id) throw invalid_operation("Framebuffer::set_format"); if(fmt.empty()) throw invalid_argument("Framebuffer::set_format");