Created
December 29, 2013 18:51
-
-
Save prabindh/8173489 to your computer and use it in GitHub Desktop.
Taken from https://github.com/prabindh/sgxperf/blob/master/sgxperf_gles20_vg.cpp (test17)
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
//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 display buffer | |
_test17(0); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment