From: Mikko Rasa Date: Sun, 19 Sep 2021 10:37:13 +0000 (+0300) Subject: Check supported attachment formats in Framebuffer::set_format X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=ad574f042d59513eec36af64c38aaf9abe6deed2;p=libs%2Fgl.git Check supported attachment formats in Framebuffer::set_format --- diff --git a/extensions/arb_internalformat_query.glext b/extensions/arb_internalformat_query.glext new file mode 100644 index 00000000..6e8d5fca --- /dev/null +++ b/extensions/arb_internalformat_query.glext @@ -0,0 +1 @@ +extension ARB_internalformat_query diff --git a/extensions/arb_internalformat_query2.glext b/extensions/arb_internalformat_query2.glext new file mode 100644 index 00000000..d02bc6a9 --- /dev/null +++ b/extensions/arb_internalformat_query2.glext @@ -0,0 +1,22 @@ +extension ARB_internalformat_query2 +# Some of the constants are only defined in conjunction of other extensions +ignore GL_SRGB_DECODE_ARB +ignore GL_VIEW_CLASS_EAC_R11 +ignore GL_VIEW_CLASS_EAC_RG11 +ignore GL_VIEW_CLASS_ETC2_RGB +ignore GL_VIEW_CLASS_ETC2_RGBA +ignore GL_VIEW_CLASS_ETC2_EAC_RGBA +ignore GL_VIEW_CLASS_ASTC_4x4_RGBA +ignore GL_VIEW_CLASS_ASTC_5x4_RGBA +ignore GL_VIEW_CLASS_ASTC_5x5_RGBA +ignore GL_VIEW_CLASS_ASTC_6x5_RGBA +ignore GL_VIEW_CLASS_ASTC_6x6_RGBA +ignore GL_VIEW_CLASS_ASTC_8x5_RGBA +ignore GL_VIEW_CLASS_ASTC_8x6_RGBA +ignore GL_VIEW_CLASS_ASTC_8x8_RGBA +ignore GL_VIEW_CLASS_ASTC_10x5_RGBA +ignore GL_VIEW_CLASS_ASTC_10x6_RGBA +ignore GL_VIEW_CLASS_ASTC_10x8_RGBA +ignore GL_VIEW_CLASS_ASTC_10x10_RGBA +ignore GL_VIEW_CLASS_ASTC_12x10_RGBA +ignore GL_VIEW_CLASS_ASTC_12x12_RGBA diff --git a/source/core/framebuffer.cpp b/source/core/framebuffer.cpp index ffd92a22..1dd2f61f 100644 --- a/source/core/framebuffer.cpp +++ b/source/core/framebuffer.cpp @@ -1,5 +1,7 @@ #include #include +#include +#include #include #include #include @@ -83,6 +85,19 @@ void Framebuffer::set_format(const FrameFormat &fmt) if(fmt.empty()) throw invalid_argument("Framebuffer::set_format"); + if(ARB_internalformat_query && ARB_internalformat_query2) + { + unsigned target = (fmt.get_samples()>1 ? GL_TEXTURE_2D_MULTISAMPLE : GL_TEXTURE_2D); + for(FrameAttachment a: fmt) + { + unsigned pf = get_gl_pixelformat(get_attachment_pixelformat(a)); + int supported = 0; + glGetInternalformativ(target, pf, GL_FRAMEBUFFER_RENDERABLE, 1, &supported); + if(supported!=GL_FULL_SUPPORT) + throw invalid_argument("Framebuffer::set_format"); + } + } + format = fmt; attachments.resize(format.size()); }