Jump to content
  • Advertisement
Sign in to follow this  
vbbartlett

Rotation of a view, causes stencil problems

This topic is 5400 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

I have a image rendering ortho view setup to view images without used of the drawpixel function. I have added the image data to a set of tiled textures, 0ing the areas outside the image in the alpha channel. This works quite well, however, now i need to clip the images based on a polygon. To do this I decided to use the stencil buffer. This also worked well initially however when I rotated the view, the image began to have areas of the texture disappear. The question is WHY? I hav changed the stencil peice to become visible, and it draws, however it becomes visible under the image as if the stencil test isn't working correctly or there is rounding problems... here is the piece of code any thoughts? Code: glEnable(GL_STENCIL_TEST); glClear(GL_STENCIL_BUFFER_BIT); glStencilFunc(GL_ALWAYS, 0x1,0x1); glStencilOp(GL_REPLACE,GL_REPLACE,GL_REPLACE); glEnable(GL_COLOR_LOGIC_OP); glLogicOp(GL_XOR); // create a stencil from the files extrema glColor4d(1,0,0,0); glBegin(GL_POLYGON); glVertex3d(ext[0].x*mx,ext[0].y*mx,0); glVertex3d(ext[1].x*mx,ext[0].y*mx,0); glVertex3d(ext[1].x*mx,ext[1].y*mx,0); glVertex3d(ext[0].x*mx,ext[1].y*mx,0); glEnd(); glDisable(GL_COLOR_LOGIC_OP); glEnable(GL_ALPHA_TEST); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glEnable(GL_TEXTURE_2D); glStencilFunc(GL_NOTEQUAL,0x0,0x1); glStencilOp(GL_KEEP,GL_KEEP,GL_KEEP); dx = tsize.x; dy = tsize.y; for(y = 0; y < theight; y++) for(x = 0; x < twidth; x++) { glBindTexture (GL_TEXTURE_2D,tiles[y*twidth+x]); glBegin(GL_QUADS); glTexCoord2d(0,0);glVertex3f((pts[0].x + x*dx)/dpi[0]*mx, (pts[0].y + (y)*dy)/dpi[0]*mx,0); glTexCoord2d(1,0);glVertex3f((pts[0].x + dx*(x+1))/dpi[0]*mx,(pts[0].y + (y)*dy)/dpi[0]*mx,0); glTexCoord2d(1,1);glVertex3f((pts[0].x + dx*(x+1))/dpi[0]*mx,(pts[0].y + (y+1)*dy)/dpi[0]*mx,0); glTexCoord2d(0,1);glVertex3f((pts[0].x + dx*x)/dpi[0]*mx, (pts[0].y + (y+1)*dy)/dpi[0]*mx,0); glEnd(); } glDisable(GL_TEXTURE_2D); glDisable(GL_ALPHA_TEST); glDisable(GL_STENCIL_TEST); glPopMatrix();

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!