back-face culling

This is an old ar­ti­cle from 2011. I was a kid. I learned a lot since then, so please do think twice when tak­ing ad­vice from me as a kid.

I re­cent­ly found a tu­to­ri­al on back-face culling. It means telling OpenGL not to draw in­vis­i­ble faces (faces on the back side ;) ) of a mesh, which does speed up the ren­der­ing a lot.

I was look­ing for some­thing like this af­ter I in­creased the height of the world in Mi­neshoot­er from 4 to 10 and sud­den­ly had to ren­der about 130.000 blocks in­stead of 25.000 and there­fore got a ma­jor per­for­mance prob­lem.

So I found that en­abling back-face culling in OpenGL is very easy. Just write the fol­low­ing lines where you ini­tial­ize OpenGL:

glEnable(GL_CULL_FACE); //Enable face-culling
glCullFace(GL_BACK); //Cull back-faces. You could also cull front-faces
glFrontFace(GL_CCW); //drawing counter-clockwise... (GL_CW for Clockwise...)

That helped a lot. But be­fore ap­ply­ing shaders I am go­ing to op­ti­mize the world a bit.

This post was im­port­ed from tum­blr


Archived blog posts from squareys.tum­