Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get maximum number of framebuffer color attachments?

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?

like image 791
xorza Avatar asked Apr 17 '15 19:04

xorza


People also ask

How many color attachments can a framebuffer have?

The minimum value for both these limits is 8 in OpenGL 3.

What is frame buffer in OpenGL?

A Framebuffer is a collection of buffers that can be used as the destination for rendering. OpenGL has two kinds of framebuffers: the Default Framebuffer, which is provided by the OpenGL Context; and user-created framebuffers called Framebuffer Objects (FBOs).

What is a framebuffer attachment?

Framebuffers represent a collection of memory attachments that are used by a render pass instance. Examples of these memory attachments include the color image buffers and depth buffer that we created in previous samples. A framebuffer provides the attachments that a render pass needs while rendering.

What is rendering buffer?

Renderbuffer is simply a data storage object containing a single image of a renderable internal format. It is used to store OpenGL logical buffers that do not have corresponding texture format, such as stencil or depth buffer.


2 Answers

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 value n you can use when specifying attachment points with GL_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 to glDrawBuffers(), 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.

like image 111
Reto Koradi Avatar answered Oct 06 '22 04:10

Reto Koradi


You can get it by querying

int maxColorAttachments;
glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS, &maxColorAttachments);
like image 21
xorza Avatar answered Oct 06 '22 05:10

xorza