the problems about stencil buffer in android open gl

Put your problem here if it does not fit any of the other categories.

the problems about stencil buffer in android open gl

Postby yaolin170 » Tue Nov 24, 2009 10:10 am

Hi
I am developing a demo about the use of stencil buffer by java . but it seems that the sencil buffer can't work normally in android plarform .my simple code are like these:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. // disable depth test
  2.  
  3.         gl.glDisable(GL10.GL_DEPTH_TEST);
  4.  
  5.      // disable modification of colors
  6.  
  7.         gl.glColorMask(false, false, false, false);
  8.  
  9.      // enable stencil test
  10.  
  11.         gl.glEnable(GL10.GL_STENCIL_TEST);
  12.  
  13.      // set the reference value for stencil buffer
  14.  
  15.         gl.glStencilOp(GL10.GL_KEEP, GL10.GL_KEEP, GL10.GL_REPLACE);
  16.  
  17.         gl.glStencilFunc(GL10.GL_ALWAYS, 1, 1);
  18.  
  19.         drawFloor(gl,floorTexId);
  20.  
  21.        
  22.  
  23.         // enable modification of colors
  24.  
  25.         gl.glColorMask(true, true, true, true);
  26.  
  27.         // enable depth testing
  28.  
  29.         gl.glEnable(GL10.GL_DEPTH_TEST);
  30.  
  31.         // only render where the stencil buffer is equal to 1
  32.  
  33.         gl.glStencilFunc(GL10.GL_EQUAL, 1, 1);
  34.  
  35.         gl.glStencilOp(GL10.GL_KEEP, GL10.GL_KEEP, GL10.GL_KEEP);
  36.  
  37.        
  38.  
  39.         // draw the reflectional cube
  40.  
  41.         gl.glPushMatrix();
  42.  
  43.                 gl.glScalef(1.0f, -1.0f, 1.0f);
  44.  
  45.         mCube.draw(gl, cubeTexId,mAngle);
  46.  
  47.         gl.glPopMatrix();
  48.  
  49. // disable stencil testing
  50.  
  51.         gl.glDisable(GL10.GL_STENCIL_TEST);
  52.  
  53.    // blend the floor so we can see the reflectional cube
  54.  
  55.         gl.glEnable(GL10.GL_BLEND);
  56.  
  57.         gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
  58.  
  59.         gl.glColor4f(1.0f, 1.0f, 1.0f, 0.4f);
  60.  
  61.         drawFloor(gl,floorTexId);
  62.  
  63.         gl.glDisable(GL10.GL_BLEND);
  64.  
  65.         // draw the "real" cube
  66.  
  67.         mCube.draw(gl, cubeTexId,mAngle);
Parsed in 0.036 seconds, using GeSHi 1.0.8.4



I think they are supposed to be ok ,but I always can't get the right result . in theory ,the reflectional cube can only be painted inside the floor . but the result is the reflectional cube can also be painted out of floor .It's very weird ! could anyone tell me the reason ? Thanks for your help in advance !
No Gods ,No Kings,Only Man!
yaolin170
Junior Developer
Junior Developer
 
Posts: 10
Joined: Fri Oct 23, 2009 7:21 am

Top

Postby cr80expert5 » Sun Jan 03, 2010 1:14 am

I believe they are having some issues in using the stencil buffer, as I have been told. Are you using the G1, G2, G3, or the new Droid? I'm in the process of creating an app for the new Droid which I will be using the stencil buffer so I shall post back when the time comes in the development of my code.
cr80expert5
Once Poster
Once Poster
 
Posts: 1
Joined: Sun Jan 03, 2010 1:10 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Yahoo [Bot] and 14 guests