Skip to main content
added 77 characters in body
Source Link
user144188
user144188

I assume that you want to draw into a colour attachment (the texture). Let me recommend a short look into the documentation (https://khronos.org/registry/OpenGL-Refpages/gl4/) and chapter 9 of the specification (https://www.khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf) on how framebuffers and their attachments (renderbuffers) are being set up for drawing, there are several ways to do this.

Here's example code to generate a framebuffer with a single colour attachment for rendering (OpenGL 4.5, plain C, no error handling for brevity):

// Create the framebuffer
glCreateFramebuffers( 1, &framebuffer );
// Create a colour attachment
glCreateRenderbuffers( 1, &color_attachment );
// make room (check formats for your need)
glNamedRenderbufferStorage( color_attachment, internal_format, size_x, size_y );
// attach renderbuffer to framebuffer; just a single colour attachment
glNamedFramebufferRenderbuffer( framebuffer, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, color_attachment );
// check for completeness
if( GL_FRAMEBUFFER_COMPLETE != glCheckNamedFramebufferStatus( framebuffer, GL_FRAMEBUFFER ) {
        /* error message;*/
}

when needed, bind the buffer to its target with a call to:

glBindFramebuffer( GL_DRAW_FRAMEBUFFER, framebuffer );

to draw into it.

Cleanup with a call to glDeleteRenderbuffers and glDeleteFramebuffers.

Use the glNamedFramebufferParameteri and glNamedRenderbufferParameteri functions for specific adjustments.

I assume that you want to draw into a colour attachment (the texture). Let me recommend a short look into the documentation (https://khronos.org/registry/OpenGL-Refpages/gl4/) and chapter 9 of the specification (https://www.khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf) on how framebuffers and their attachments (renderbuffers) are being set up for drawing, there are several ways to do this.

Here's example code to generate a framebuffer with a single colour attachment for rendering (OpenGL 4.5, plain C, no error handling for brevity):

// Create the framebuffer
glCreateFramebuffers( 1, &framebuffer );
// Create a colour attachment
glCreateRenderbuffers( 1, &color_attachment );
// make room (check formats for your need)
glNamedRenderbufferStorage( color_attachment, internal_format, size_x, size_y );
// attach renderbuffer to framebuffer; just a single colour attachment
glNamedFramebufferRenderbuffer( framebuffer, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, color_attachment );
// check for completeness
if( GL_FRAMEBUFFER_COMPLETE != glCheckNamedFramebufferStatus( framebuffer, GL_FRAMEBUFFER ) {
        /* error message;*/
}

when needed, bind the buffer to its target with a call to:

glBindFramebuffer( GL_DRAW_FRAMEBUFFER, framebuffer );

to draw into it.

Cleanup with a call to glDeleteRenderbuffers and glDeleteFramebuffers.

I assume that you want to draw into a colour attachment (the texture). Let me recommend a short look into the documentation (https://khronos.org/registry/OpenGL-Refpages/gl4/) and chapter 9 of the specification (https://www.khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf) on how framebuffers and their attachments (renderbuffers) are being set up for drawing.

Here's example code to generate a framebuffer with a single colour attachment for rendering (OpenGL 4.5, plain C, no error handling for brevity):

// Create the framebuffer
glCreateFramebuffers( 1, &framebuffer );
// Create a colour attachment
glCreateRenderbuffers( 1, &color_attachment );
// make room (check formats for your need)
glNamedRenderbufferStorage( color_attachment, internal_format, size_x, size_y );
// attach renderbuffer to framebuffer; just a single colour attachment
glNamedFramebufferRenderbuffer( framebuffer, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, color_attachment );
// check for completeness
if( GL_FRAMEBUFFER_COMPLETE != glCheckNamedFramebufferStatus( framebuffer, GL_FRAMEBUFFER ) {
        /* error message;*/
}

when needed, bind the buffer to its target with a call to:

glBindFramebuffer( GL_DRAW_FRAMEBUFFER, framebuffer );

to draw into it.

Cleanup with a call to glDeleteRenderbuffers and glDeleteFramebuffers.

Use the glNamedFramebufferParameteri and glNamedRenderbufferParameteri functions for specific adjustments.

added 120 characters in body
Source Link
user144188
user144188

I assume that you want to draw into a colour attachment (the texture). Let me recommend a short look into the documentation (https://khronos.org/registry/OpenGL-Refpages/gl4/) and chapter 9 of the specification (https://www.khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf) on how framebuffers and their attachments (renderbuffers) are being set up for drawing, there are several ways to do this.

Here's example code to generate a framebuffer with a single colour attachment for rendering (OpenGL 4.5, plain C, no error handling for brevity):

// Create the framebuffer
glCreateFramebuffers( 1, &framebuffer );
// Create a colour attachment
glCreateRenderbuffers( 1, &color_attachment );
// make room (check formats for your need)
glNamedRenderbufferStorage( color_attachment, internal_format, size_x, size_y );
// attach renderbuffer to framebuffer; just a single colour attachment
glNamedFramebufferRenderbuffer( framebuffer, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, color_attachment );
// check for completeness
if( GL_FRAMEBUFFER_COMPLETE != glCheckNamedFramebufferStatus( framebuffer, GL_FRAMEBUFFER ) {
        /* error message;*/
}

when needed, bind the buffer to its target with a call to:

glBindFramebuffer( GL_DRAW_FRAMEBUFFER, framebuffer );

to draw into it.

Cleanup with a call to glDeleteRenderbuffers and glDeleteFramebuffers.

I assume that you want to draw into a colour attachment (the texture). Let me recommend a short look into the documentation (https://khronos.org/registry/OpenGL-Refpages/gl4/) on how framebuffers and their attachments are being set up for drawing, there are several ways to do this.

Here's example code to generate a framebuffer with a single colour attachment for rendering (OpenGL 4.5, plain C, no error handling for brevity):

// Create the framebuffer
glCreateFramebuffers( 1, &framebuffer );
// Create a colour attachment
glCreateRenderbuffers( 1, &color_attachment );
// make room (check formats for your need)
glNamedRenderbufferStorage( color_attachment, internal_format, size_x, size_y );
// attach renderbuffer to framebuffer; just a single colour attachment
glNamedFramebufferRenderbuffer( framebuffer, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, color_attachment );
// check for completeness
if( GL_FRAMEBUFFER_COMPLETE != glCheckNamedFramebufferStatus( framebuffer, GL_FRAMEBUFFER ) {
        /* error message;*/
}

when needed, bind the buffer to its target with a call to:

glBindFramebuffer( GL_DRAW_FRAMEBUFFER, framebuffer );

to draw into it.

Cleanup with a call to glDeleteRenderbuffers and glDeleteFramebuffers.

I assume that you want to draw into a colour attachment (the texture). Let me recommend a short look into the documentation (https://khronos.org/registry/OpenGL-Refpages/gl4/) and chapter 9 of the specification (https://www.khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf) on how framebuffers and their attachments (renderbuffers) are being set up for drawing, there are several ways to do this.

Here's example code to generate a framebuffer with a single colour attachment for rendering (OpenGL 4.5, plain C, no error handling for brevity):

// Create the framebuffer
glCreateFramebuffers( 1, &framebuffer );
// Create a colour attachment
glCreateRenderbuffers( 1, &color_attachment );
// make room (check formats for your need)
glNamedRenderbufferStorage( color_attachment, internal_format, size_x, size_y );
// attach renderbuffer to framebuffer; just a single colour attachment
glNamedFramebufferRenderbuffer( framebuffer, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, color_attachment );
// check for completeness
if( GL_FRAMEBUFFER_COMPLETE != glCheckNamedFramebufferStatus( framebuffer, GL_FRAMEBUFFER ) {
        /* error message;*/
}

when needed, bind the buffer to its target with a call to:

glBindFramebuffer( GL_DRAW_FRAMEBUFFER, framebuffer );

to draw into it.

Cleanup with a call to glDeleteRenderbuffers and glDeleteFramebuffers.

added 34 characters in body
Source Link
user144188
user144188

I assume that you want to draw into a colour attachment (the texture). Let me recommend a short look into the documentation (https://khronos.org/registry/OpenGL-Refpages/gl4/) on how framebuffers and their attachments are being set up for drawing, there are several ways to do this.

Here's example code to generate a framebuffer with a single colour attachment for rendering (OpenGL 4.5, plain C, no error handling for brevity):

// Create the framebuffer
glCreateFramebuffers( 1, &framebuffer );
// Create a colour attachment
glCreateRenderbuffers( 1, &color_attachment );
// make room (check formats for your need)
glNamedRenderbufferStorage( color_attachment, internal_format, size_x, size_y );
// attach renderbuffer to framebuffer; just a single colour attachment
glNamedFramebufferRenderbuffer( framebuffer, attachment_pointGL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, color_attachment );
// check for completeness
if( GL_FRAMEBUFFER_COMPLETE != glCheckNamedFramebufferStatus( framebuffer, GL_FRAMEBUFFER ) {
        /* error message;*/
}

when needed, bind the buffer to its target with a call to:

glBindFramebuffer( targetGL_DRAW_FRAMEBUFFER, framebuffer );

to draw into it.

Cleanup with a call to glDeleteRenderbuffers and glDeleteFramebuffers.

I assume that you want to draw into a colour attachment (the texture). Let me recommend a short look into the documentation (https://khronos.org/registry/OpenGL-Refpages/gl4/) on how framebuffers and their attachments are being set up for drawing, there are several ways to do this.

Here's example code to generate a framebuffer with a single colour attachment for rendering (OpenGL 4.5, plain C, no error handling for brevity):

// Create the framebuffer
glCreateFramebuffers( 1, &framebuffer );
// Create a colour attachment
glCreateRenderbuffers( 1, &color_attachment );
// make room
glNamedRenderbufferStorage( color_attachment, internal_format, size_x, size_y );
// attach renderbuffer to framebuffer; just a single colour attachment
glNamedFramebufferRenderbuffer( framebuffer, attachment_point, GL_RENDERBUFFER, color_attachment );
// check for completeness
if( GL_FRAMEBUFFER_COMPLETE != glCheckNamedFramebufferStatus( framebuffer, GL_FRAMEBUFFER ) {
        /* error message;*/
}

when needed, bind the buffer to its target with a call to:

glBindFramebuffer( target, framebuffer );

to draw into it.

Cleanup with a call to glDeleteRenderbuffers and glDeleteFramebuffers.

I assume that you want to draw into a colour attachment (the texture). Let me recommend a short look into the documentation (https://khronos.org/registry/OpenGL-Refpages/gl4/) on how framebuffers and their attachments are being set up for drawing, there are several ways to do this.

Here's example code to generate a framebuffer with a single colour attachment for rendering (OpenGL 4.5, plain C, no error handling for brevity):

// Create the framebuffer
glCreateFramebuffers( 1, &framebuffer );
// Create a colour attachment
glCreateRenderbuffers( 1, &color_attachment );
// make room (check formats for your need)
glNamedRenderbufferStorage( color_attachment, internal_format, size_x, size_y );
// attach renderbuffer to framebuffer; just a single colour attachment
glNamedFramebufferRenderbuffer( framebuffer, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, color_attachment );
// check for completeness
if( GL_FRAMEBUFFER_COMPLETE != glCheckNamedFramebufferStatus( framebuffer, GL_FRAMEBUFFER ) {
        /* error message;*/
}

when needed, bind the buffer to its target with a call to:

glBindFramebuffer( GL_DRAW_FRAMEBUFFER, framebuffer );

to draw into it.

Cleanup with a call to glDeleteRenderbuffers and glDeleteFramebuffers.

Source Link
user144188
user144188
Loading