Advertisement
Guest User

Untitled

a guest
Nov 26th, 2014
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.86 KB | None | 0 0
  1. /*
  2.          * TODO STEP 31: Set glColorMask and glDepthMask to false. Enable the
  3.          * stencil test.
  4.          */
  5.         gl.glColorMask(false, false, false, false);
  6.         gl.glDepthMask(false);
  7.         gl.glEnable(GL10.GL_STENCIL_TEST);
  8.  
  9.  
  10.         /*
  11.          * TODO STEP 32a: Set the stencil function to always pass. Use 1 as
  12.          * reference value. Set bitmask to ~0.
  13.          */
  14.         gl.glStencilFunc(GL10.GL_ALWAYS, 1, 0);
  15.  
  16.         /*
  17.          * TODO STEP 32b: Set the stencil operation to GL_REPLACE to replace the
  18.          * current value in the stencil buffer. As the stencil test always
  19.          * passes the value for stencil fail does not matter.
  20.          */
  21.         gl.glStencilOp(GL10.GL_REPLACE, GL10.GL_REPLACE, GL10.GL_INCR);
  22.        
  23.         /*
  24.          * TODO STEP 13b: Draw the floor and execute the application!
  25.          */
  26.         mFloor.draw(gl);
  27.  
  28.         /*
  29.          * TODO STEP 33: Set glColorMask and glDepthMask to true and draw the
  30.          * floor a second time. As the stencil function has been inserted, the
  31.          * first call causes the floor to be drawn into the stencil buffer but
  32.          * not on the display anymore.
  33.          */
  34.         gl.glColorMask(true, true, true, true);
  35.         gl.glDepthMask(true);
  36.         mFloor.draw(gl);
  37.  
  38.  
  39.         /*
  40.          * TODO STEP 34a: Change the stencil function to be true when the value
  41.          * in the stencil buffer equals 1 (GL_EQUAL 1). Set the bitmask to ~0
  42.          * again.
  43.          */
  44.         gl.glStencilFunc(GL10.GL_EQUAL, 1, 0);
  45.  
  46.         /*
  47.          * TODO STEP 34b: Change the stencil function to always keep (GL_KEEP)
  48.          * the stencil buffer value in order to get overlaying shadows. If you
  49.          * want to have physically correct shadows use GL_INCR for the z-pass
  50.          * value. However, you won't see the nice cube shadow anymore as the
  51.          * ceiling is taken into account.
  52.          */
  53.         gl.glStencilFunc(GL10.GL_KEEP, 1, 0);
  54.         gl.glStencilOp(GL10.GL_REPLACE, GL10.GL_DECR, GL10.GL_INCR);
  55.  
  56.         gl.glPushMatrix();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement