OpenGL FrameBuffer Object 201
The Draw Buffers ExtensionThe first extension, Draw Buffers, builds upon the functionality provided by glDrawBuffer(). As you recall this function allows us to specify which colour buffer we are going to write to, the Draw Buffers extension expands upon this to allow us to specify multiple colour buffers to write to. The number of buffers you can render to at once can be queried as follows: GLuint maxbuffers; glGetIntergeri(GL_MAX_DRAW_BUFFERS, &maxbuffers); After which the variable maxbuffers holds the number of buffers we can render to at once (at the time of writing this value is typically 4, however the GeForce 8x00 series allows for up to 8 buffers to be drawn to). The function used to indicated which buffers to draw to takes the same values as the glDrawBuffer() for the targets, which means we can supply it with GL_COLOR_ATTACHMENTx_EXT values in order to write to multiple attached textures at the same time. Thus if we had textures attached to points 0 and 1, and wanted to render to both of them then we would do the following: GLenum buffers[] = { GL_COLOR_ATTACHMENT0_EXT, GL_COLOR_ATTACHMENT1_EXT }; glDrawBuffers(2, buffers); After this function is executed OpenGL is setup to render to both colour buffers, which brings us on to how this is done. |