Skip to content

Instantly share code, notes, and snippets.

@roxlu
Created February 5, 2012 14:05
Show Gist options
  • Select an option

  • Save roxlu/1745723 to your computer and use it in GitHub Desktop.

Select an option

Save roxlu/1745723 to your computer and use it in GitHub Desktop.
Light Rays 0.7 - identity projection and view matrix to render full screen
// 2a: now that we've got the scene in a texture we're going to apply an
// effect on it. To apply an effect we need to draw it again now using the
// mode = 3.
//
// note that we use a trick here to draw the rendered scene onto a plane
// with a width and height of 2. (-1 to 1). which are the normalized
// device coordinates. Basically what we do here is drawing the captured
// scene (captured with fbo) onto a plane which is almost the same size
// of the window. I say almost because we use 1.9 here (instead of 2).
//
/*
*
* -1,1 1,1
* ----------
* | |
* | |
* | |
* | |
* | |
* ----------
* -1,-1 1,-1
*
*
*/
Mat4 ident;
Mat4 scale = Mat4::scaling(1.9,1.9,1);
shader.uniformMat4fv("projection_matrix", ident.getPtr());
shader.uniformMat4fv("view_matrix", scale.getPtr());
glDisable(GL_DEPTH_TEST);
glEnable(GL_TEXTURE_2D); // just to make sure textures are enabled.
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, fbo.getTextureID(0)); // make this our active texture
shader.uniform1i("mode", 3);
glDrawArrays(GL_QUADS, 0, 4);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment