Jump to content
  • Advertisement
Sign in to follow this  
cool mr croc

using stencils to make polys with holes

This topic is 2525 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi. not quite sure ive got a firm grasp on what im doing. i have code which is sort of working, i have a poly with a hole in (yay), now im trying to display it over background, but at the moment the stencil is applied to the background too. i would like to be able to draw the background completely seperate to the stencil so i was hoping there was a setting within the stencil functions to leave the background alone.

this is code i have, can anyone show me something i can change to leave the background image (blueSquare) alone?


public void onSurfaceCreated(GL10 gl, EGLConfig config) {
gl.glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
gl.glShadeModel(GL10.GL_SMOOTH);
gl.glClearDepthf(1.0f);
gl.glEnable(GL10.GL_DEPTH_TEST);
gl.glDepthFunc(GL10.GL_LEQUAL);
gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_NICEST);
gl.glClearStencil(0);
gl.glStencilMask(1);
gl.glEnable(GL10.GL_STENCIL_TEST);
}
public void onDrawFrame(GL10 gl) {
gl.glLoadIdentity();
gl.glTranslatef(0, 1.5f, -7);

gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT | GL10.GL_STENCIL_BUFFER_BIT);

gl.glPushMatrix();
gl.glTranslatef(0.5f, 0.0f, 0.0f);
blueSquare.draw(gl);
gl.glPopMatrix();

gl.glStencilFunc(GL10.GL_ALWAYS, 1, 1);
gl.glStencilOp(GL10.GL_KEEP, GL10.GL_KEEP, GL10.GL_REPLACE);

gl.glPushMatrix();
gl.glTranslatef(0.0f, -0.3f, 0.0f);
gl.glScalef(0.5f, 0.5f, 0.5f);
poly.draw(gl);
gl.glPopMatrix();

gl.glStencilFunc(GL10.GL_EQUAL, 2, 1);
gl.glStencilOp(GL10.GL_KEEP, GL10.GL_KEEP, GL10.GL_KEEP);

greenSquare.draw(gl);
}

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!