Created
December 29, 2012 18:41
-
-
Save agrif/4408619 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| glGenFramebuffers(1, &(priv->framebuffer)); | |
| glGenRenderbuffers(1, &(priv->depthbuffer)); | |
| glGenTextures(1, &(priv->colorbuffer)); | |
| /* set up the color buffer */ | |
| glBindTexture(GL_TEXTURE_2D, priv->colorbuffer); | |
| glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8UI, im->width, im->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); | |
| glBindTexture(GL_TEXTURE_2D, 0); | |
| /* set up our depth buffer */ | |
| glBindRenderbuffer(GL_RENDERBUFFER, priv->depthbuffer); | |
| glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, im->width, im->height); | |
| glBindRenderbuffer(GL_RENDERBUFFER, 0); | |
| /* bind everything to our framebuffer */ | |
| glBindFramebuffer(GL_FRAMEBUFFER, priv->framebuffer); | |
| glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, priv->colorbuffer, 0); | |
| glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, priv->depthbuffer); | |
| /* make sure we're good */ | |
| if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { | |
| /* FIXME fail! */ | |
| printf("ack! failed to make framebuffer! 0x%x\n", glCheckFramebufferStatus(GL_FRAMEBUFFER)); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment