GL_CLIP_PLANE not working

This is a discussion on GL_CLIP_PLANE not working within the Game Programming forums, part of the General Programming Boards category; My OpenGL clipping plane doesn't work--can anyone tell me what I am doing wrong? here is my code: Code: double ...

  1. #1
    User
    Join Date
    Jan 2006
    Location
    Canada
    Posts
    498

    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:

    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)
    Attached Images Attached Images  

  2. #2
    vae victus! skorman00's Avatar
    Join Date
    Nov 2003
    Posts
    594
    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
    User
    Join Date
    Jan 2006
    Location
    Canada
    Posts
    498
    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, 04: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, 08: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, 05:08 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21