Thread: GL_CLIP_PLANE not working

  1. #1
    Join Date
    Jan 2006

    GL_CLIP_PLANE not working

    My OpenGL clipping plane doesn't work--can anyone tell me what I am doing wrong? here is my code:

    	double eqr[] = {0.0f, -1.0f, 0.0f, 0.0f};	// clip plane equation
    	glLoadIdentity();			// reset the view
    	glTranslatef(0.0f, -0.6f, zoom); // move down a bit and back by the value in zoom
    	glEnable(GL_CLIP_PLANE0);					// enable clipping
    	glClipPlane(GL_CLIP_PLANE0, eqr);			// tell opengl where we want to clip
    	glPushMatrix();								// push the matrix
    		glScalef(1.0f, -1.0f, 1.0f);			// mirror everthing (it's supposed to be a reflection, after all)
    		glLightfv(GL_LIGHT0, GL_POSITION, light_pos);	// set up light 0
    		glTranslatef(0.0f, height, 0.0f);		// move to where we want to draw the ball (opposite, because it's mirrored)
    		glRotatef(xrot, 1.0f, 0.0f, 0.0f);		// rotate on the x axis
    		glRotatef(yrot, 0.0f, 1.0f, 0.0f);		// rotate on the y axis
    		draw_object();							// now draw the ball
    	glPopMatrix();								// pop the matrix
    	glDisable(GL_CLIP_PLANE0);					// disable clipping
    	glDisable(GL_STENCIL_TEST);					// turn off the stencil buffer
    The idea is to draw a hovering ball above a floor, and, using the stencil buffer, draw a reflection of the ball. draw_object() draws the ball. It's supposed to clip to keep the reflection on the floor like an accurate reflection would . Everthing works, except the clipping. (I'm not sure if my picture attachment will come through or not)

  2. #2
    vae victus! skorman00's Avatar
    Join Date
    Nov 2003
    1) that plane equation looks fishy to me, but that may just be me
    2) I noticed that code doesn't enable the stencil test
    3) Are you certain the stencil buffer is being filled?

  3. #3
    Join Date
    Jan 2006
    Yeah, I think there's something wrong with my stencil buffer, because having played around with the clipping equation, there's nothing wrong with the plane clipping. So I guess I'll have to figure out what I'm doing wrong with my stencil buffer.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Function not working
    By sloopy in forum C Programming
    Replies: 31
    Last Post: 11-12-2005, 08:08 PM
  2. Program Not working Right
    By raven420smoke in forum C++ Programming
    Replies: 2
    Last Post: 09-16-2005, 03:21 AM
  3. Trying to eject D drive using code, but not working... :(
    By snowfrog in forum C++ Programming
    Replies: 3
    Last Post: 05-07-2005, 07:47 PM
  4. x on upper right corner not working
    By caduardo21 in forum Windows Programming
    Replies: 1
    Last Post: 02-20-2005, 08:35 PM
  5. cygwin -> unix , my code not working properly ;(
    By CyC|OpS in forum C Programming
    Replies: 4
    Last Post: 05-18-2002, 04:08 AM