Created
February 25, 2014 03:05
-
-
Save prabindh/9201855 to your computer and use it in GitHub Desktop.
fbo summary, full test at https://github.com/prabindh/sgxperf/blob/master/sgxperf_test17.cpp
This file contains 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
//Creation of FBO | |
glGenFramebuffers(NUM_FBO, fboId); | |
//fbo texture | |
glGenTextures(NUM_FBO, fboTextureId); | |
//Regular first texture | |
glGenTextures(1, ®ularTextureId); | |
//Bind offscreen texture | |
GL_CHECK(glBindTexture(GL_TEXTURE_2D, 0)); | |
GL_CHECK(glBindTexture(GL_TEXTURE_2D, fboTextureId[i])); | |
GL_CHECK(glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, inTextureWidth, inTextureHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL)); | |
GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); | |
GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); | |
GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, fboId[i])); | |
GL_CHECK(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, fboTextureId[i], 0)); | |
if(glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) | |
{ | |
printf("FB is not complete for rendering offscreen\n"); | |
goto err; | |
} | |
//Bind regular texture | |
GL_CHECK(glBindTexture(GL_TEXTURE_2D, 0)); | |
GL_CHECK(glBindTexture(GL_TEXTURE_2D, regularTextureId)); | |
add_texture(inTextureWidth, inTextureHeight, textureData, inPixelFormat); | |
GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); | |
GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); | |
//Draw with regular draw calls to FBO | |
GL_CHECK(_test17(1)); | |
//Now get back display framebuffer and unbind the FBO | |
GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, 0)); | |
GL_CHECK(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0)); | |
if(glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) | |
{ | |
printf("FB is not complete for rendering to display\n"); | |
goto err; | |
} | |
//bind to texture | |
GL_CHECK(glBindTexture(GL_TEXTURE_2D, 0)); | |
GL_CHECK(glBindTexture(GL_TEXTURE_2D, fboTextureId[i])); | |
GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)); | |
GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)); | |
//draw to regular display buffer using regular vertex/texure coordinates, and using the above texture and then call swapbuffers | |
draw_regular(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment