MCPcopy Create free account
hub / github.com/crownengine/crown / isFramebufferFormatValid

Function isFramebufferFormatValid

3rdparty/bgfx/src/renderer_gl.cpp:2071–2165  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2069#endif
2070
2071 static bool isFramebufferFormatValid(
2072 TextureFormat::Enum _format
2073 , bool _srgb = false
2074 , bool _writeOnly = false
2075 , GLsizei _dim = 16
2076 )
2077 {
2078#if BX_PLATFORM_EMSCRIPTEN
2079 // On web platform read the validity of framebuffers based on the available GL context and extensions
2080 // to avoid developer unfriendly console error noise that would come from probing.
2081 BX_UNUSED(_dim);
2082 return isFramebufferFormatValidPerSpec(_format, _srgb, _writeOnly);
2083#else
2084 // On other platforms probe the supported textures.
2085 const TextureFormatInfo& tfi = s_textureFormat[_format];
2086 GLenum internalFmt = _srgb
2087 ? tfi.m_internalFmtSrgb
2088 : tfi.m_internalFmt
2089 ;
2090 if (GL_ZERO == internalFmt)
2091 {
2092 return false;
2093 }
2094
2095 if (_writeOnly)
2096 {
2097 GLuint rbo;
2098 glGenRenderbuffers(1, &rbo);
2099 glBindRenderbuffer(GL_RENDERBUFFER, rbo);
2100
2101 glRenderbufferStorage(GL_RENDERBUFFER
2102 , s_rboFormat[_format]
2103 , _dim
2104 , _dim
2105 );
2106 glBindRenderbuffer(GL_RENDERBUFFER, 0);
2107 glDeleteRenderbuffers(1, &rbo);
2108
2109 GLenum err = getGlError();
2110 return 0 == err;
2111 }
2112
2113 GLuint fbo;
2114 GL_CHECK(glGenFramebuffers(1, &fbo) );
2115 GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, fbo) );
2116
2117 GLuint id;
2118 GL_CHECK(glGenTextures(1, &id) );
2119 GL_CHECK(glBindTexture(GL_TEXTURE_2D, id) );
2120
2121 GLenum err = initTestTexture(_format, _srgb, false, false, _dim);
2122
2123 GLenum attachment;
2124 if (bimg::isDepth(bimg::TextureFormat::Enum(_format) ) )
2125 {
2126 const bimg::ImageBlockInfo& info = bimg::getBlockInfo(bimg::TextureFormat::Enum(_format) );
2127 if (0 == info.depthBits)
2128 {

Callers 1

initMethod · 0.85

Calls 5

getGlErrorFunction · 0.85
initTestTextureFunction · 0.85
isDepthFunction · 0.85
EnumEnum · 0.70

Tested by

no test coverage detected