glFramebufferRenderbuffer — attach a renderbuffer as a logical buffer to the currently bound framebuffer object
Specifies the framebuffer target.
target must be
GL_FRAMEBUFFER is equivalent to
Specifies the attachment point of the framebuffer.
Specifies the renderbuffer target and must be
Specifies the name of an existing renderbuffer object of type
renderbuffertarget to attach.
glFramebufferRenderbuffer attaches a renderbuffer as one of the logical buffers of the currently bound framebuffer object.
renderbuffer is the name of the renderbuffer object to attach and must be either zero, or the name of an existing renderbuffer object of type
renderbuffer is not zero and if
glFramebufferRenderbuffer is successful, then the renderbuffer name
renderbuffer will be used as the logical buffer identified by
attachment of the framebuffer currently bound to
The value of
GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE for the specified attachment point is set to
GL_RENDERBUFFER and the value of
GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME is set to
renderbuffer. All other state values of the attachment point specified by
attachment are set to their default values. No change is made to the state of the renderbuuffer object and any previous attachment to the
attachment logical buffer of the framebuffer
target is broken.
glFramebufferRenderbuffer with the renderbuffer name zero will detach the image, if any, identified by
attachment, in the framebuffer currently bound to
target. All state values of the attachment point specified by attachment in the object bound to target are set to their default values.
attachment to the value
GL_DEPTH_STENCIL_ATTACHMENT is a special case causing both the depth and stencil attachments of the framebuffer object to be set to
renderbuffer, which should have the base internal format
GL_INVALID_ENUM is generated if
target is not one of the accepted tokens.
GL_INVALID_ENUM is generated if
renderbuffertarget is not
GL_INVALID_OPERATION is generated if zero is bound to
// fbo_width and fbo_height are the desired width and height of the FBO. // For Opengl <= 4.4 or if the GL_ARB_texture_non_power_of_two extension // is present, fbo_width and fbo_height can be values other than 2^n for // some integer n. // Build the texture that will serve as the color attachment for the framebuffer. GLuint color_renderbuffer; glGenRenderbuffers(1, &color_renderbuffer); glBindRenderbuffer( GL_RENDERBUFFER, (GLuint)color_renderbuffer ); glRenderbufferStorage( GL_RENDERBUFFER, GL_RGBA8, fbo_width, fbo_height ); glBindRenderbuffer( GL_RENDERBUFFER, 0 ); // Build the texture that will serve as the depth attachment for the framebuffer. GLuint depth_renderbuffer; glGenRenderbuffers(1, &depth_renderbuffer); glBindRenderbuffer( GL_RENDERBUFFER, (GLuint)depth_renderbuffer ); glRenderbufferStorage( GL_RENDERBUFFER, GL_DEPTH_COMPONENT, fbo_width, fbo_height ); glBindRenderbuffer( GL_RENDERBUFFER, 0 ); // Build the framebuffer. GLuint framebuffer; glGenFramebuffers(1, &framebuffer); glBindFramebuffer(GL_FRAMEBUFFER, (GLuint)framebuffer); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, color_renderbuffer); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depth_renderbuffer); GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER); if (status != GL_FRAMEBUFFER_COMPLETE) // Error glBindFramebuffer(GL_FRAMEBUFFER, 0);
Copyright © 2010 Khronos Group. This material may be distributed subject to the terms and conditions set forth in the Open Publication License, v 1.0, 8 June 1999. http://opencontent.org/openpub/.