I'm developing an OpenGL application and I need to find how many framebuffer color attachments are supported. Is there a way to query OpenGL for that value?
There are two values that can potentially limit how many attachments you can use:
GL_MAX_COLOR_ATTACHMENTS
specifies how many color attachment points an FBO has. In other words, it correspond to the maximum valuen
you can use when specifying attachment points withGL_COLOR_ATTACHMENTn
. This will limit how many color textures/renderbuffers can be attached to the FBO concurrently. You can get this limit with:GLint maxAttach = 0; glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS, &maxAttach);
GL_MAX_DRAW_BUFFERS
specifies how many buffers you can draw to at the same time. It is the maximum number of buffers you're allowed to pass toglDrawBuffers()
, and also the maximum number of outputs allowed in fragment shaders. You can get this limit with:GLint maxDrawBuf = 0; glGetIntegerv(GL_MAX_DRAW_BUFFERS, &maxDrawBuf);
These two values do not have to be the same. So it is possible that you can have a certain number of attachments, but you can't draw to all of them at the same time.
The minimum value for both these limits is 8 in OpenGL 3.x and higher, up to and including the current 4.5 spec.
You can get it by querying
int maxColorAttachments;
glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS, &maxColorAttachments);
© 2022 - 2024 — McMap. All rights reserved.