HI
I want implement code for clipping the upper left quarter of sphere
i meane disable only the upper left of the sphear
i don’t how i can do that
i write this code but this code dont work as what i want
any body can help me??
#include <GL/glut.h>
float x,y,x1,y1;
//GLdouble eqn[4];
//GLdouble eqn2[4];
//GLdouble eqn3[4];
void init(void)
{
glClearColor(1.0,1.0,1.0,0.0);
glShadeModel(GL_FLAT);
}
void display(void)
{
//GLdouble eqn[4]={0.0,1.0,0.0,0.0};
GLdouble eqn[4]={x,y,0.0,0.0};
GLdouble eqn1[4]={x1,y1,0.0,0.0};
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0,0.0,0.0);
glPushMatrix();
glTranslatef(0.0,0.0,-5.0);
/* clip lower half --y<0 */
glClipPlane(GL_CLIP_PLANE0,eqn);
glEnable(GL_CLIP_PLANE0);
glClipPlane(GL_CLIP_PLANE1,eqn1);
glEnable(GL_CLIP_PLANE1);
glRotatef(90.0,1.0,0.0,0.0);
glutWireSphere(1.0,20,16);
glPopMatrix();
glFlush();
}
void reshape(int w,int h)
{
glViewport(0,0,(GLsizei) w,(GLsizei) h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60.0,(GLfloat) w / (GLfloat) h,1.0,20.0);
glMatrixMode(GL_MODELVIEW);
}
//----------------------------------------
void clip (int selection)
{
switch (selection)
{
case 1:
//clip with plane x=y
x=1.0;
y=1.0;
x1=0.0;
y1=0.0;
break;
case 2:
//clip the upper right quarter
x=1.0;
y=0.0;
x1=0.0;
y1=1.0;
break;
case 3:
//clip the upper lift quarter
x=-1.0;
y=0.0;
x1=0.0;
y1=1.0;
break;
case 4:
x=0.0;
y=0.0;
x1=0.0;
y1=0.0;
break;
case 0:exit(0);
}
}
//------------------------------------------
int main(int argc,char** argv)
{
glutInit(&argc,argv);
glutInitWindowPosition(100,100);
glutInitWindowSize(500,500);
glutInitDisplayMode(GLUT_RGB|GLUT_SINGLE);
glutCreateWindow(argv[0]);
init();
glutReshapeFunc(reshape);
glutDisplayFunc(display);
//main menu
glutCreateMenu(clip);
glutAddMenuEntry(“clip x=y.”,1);
glutAddMenuEntry(“clip the upper right quarter.”,2);
glutAddMenuEntry(“clip the upper left quarter .”,3);
glutAddMenuEntry(“Disable any clippung”,4);
glutAddMenuEntry(“Quit”,0);
glutAttachMenu(GLUT_RIGHT_BUTTON);
glutMainLoop();
return 0;
}