I REALLY NEED HELP IN YHE CLIPPING

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&lt;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;
}

Hope this helps:

#include <GL/glut.h>

float x, y, x1, y1;

void init( void ) {
glClearColor( 1.0, 1.0, 1.0, 0.0 );
glShadeModel( GL_SMOOTH );
glEnable( GL_DEPTH_TEST );
}

void display( void ) {
GLdouble eqn[4] = { x,y, 0.0, 0.0 };
GLdouble eqn1[4] = { x1, y1, 0.0, 0.0 };

glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_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();
glutSwapBuffers();
}

void reshape( int w,int h ) {
if( h == 0 )
h = 1;

float ratio = 1.0 * w / h;

glMatrixMode( GL_PROJECTION );

glLoadIdentity();

glViewport( 0, 0, w, h );

gluPerspective( 45, ratio, 1, 1000 );
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
}
//----------------------------------------
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;
glutPostRedisplay();
break;

case 2:
//clip the upper right quarter
x = 1.0;
y = 0.0;
x1 = 0.0;
y1 = 1.0;
glutPostRedisplay();
break;

case 3:
//clip the upper lift quarter
x = -1.0;
y = 0.0;
x1 = 0.0;
y1 = 1.0;
glutPostRedisplay();
break;

case 4:
x = 0.0;
y = 0.0;
x1 = 0.0;
y1 = 0.0;
glutPostRedisplay();
break;
case 0:
exit(0);
}
}
//------------------------------------------
int main( int argc,char** argv ) {
glutInit( &argc, argv );
glutInitWindowPosition( 100, 100 );
glutInitWindowSize( 500, 500 );
glutInitDisplayMode( GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA );
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 clipping”, 4);
glutAddMenuEntry( “Quit”, 0);
glutAttachMenu( GLUT_RIGHT_BUTTON );
glutMainLoop();
return 0;
}

HI

THNAK YOU

BUT YOUR CODE DO EXACTLY WHAT MY CODE DO

I WANT CLIP UPPER LEFT QARTER

I mean disable left upper quarter and show the sphear with the out left upper quarter

best regards
Moon_Girl

I’ll see what I can do!!!

THANK YOU VERY MUCH

I well wait you

best regards
Moon_Girl

I have tried for the past two hours and haven’t figured out a way. I tried creating two Spheres and overlapping them, but that still didn’t work. My best suggestion is to use GL_QUADS and try to simulate clipping (when really not clipping). For example, creating different QUADS, and then when the entry selection has been changed:

  1. to erase the background
  2. then load the other QUAD
    (which is just an idea).

I’m sorry, but I really tried.

  • VC6-OGL

[This message has been edited by VC6-OGL (edited 12-23-2002).]

[This message has been edited by VC6-OGL (edited 12-23-2002).]

hmm… MOON-GIRL i would like to ask you what you think about openGL programming…

Is it hard to learn?
How long did it take for you to learn
everything you need to do whatever you can do right now?? and what did you have to learn??

I would be very pleased if you could answer my questions…

HI

THANK YOU

I THINK DRAW RCTINGLE BUT THE REALLY PROBLEM WITH ME ITS WORK WITH 3D BECUASE THIS IS FIRST PROGRAM FOR ME IN 3D

BUT I WELL TRY READ IN THIS AND APPLIYED YOUR IDEA

i saw your profile and your Interests: Game Programming

I try design code for ( x /o ) games
but is very simple
can I send it for you
and tell me if my idea is good or so bad

WELCOME Deniz

1)IN FACT I very beginer in opengl but i see its not hard

for me becuase i have some knowldge in c++ and c

  1. i begin learn opengl befor 2 months but to learn everythings comes from bracticing not from studying
    i use some book and some sits

3)MY knowldge until now in 2D if i learn it very good i try learn 3d
but i found some example in 3d and i try change in it and i see what is happend

i want my answers help you

but

seek understand and it well be understoooooooooood

best regards
Moon_Girl

[This message has been edited by MOON-GIRL (edited 12-24-2002).]

Sure, no problem.

  • VC6-OGL

Your (x/o) Program is very nice. I saw that if you lose it says you “lose” and if you win you “win” and if you tie the game it says nothing but that can always be changeable, but so far it is a very nice code/game. You are on the right track.

Your idea is GREAT!!!

I’ll see if I can change that resize problem.

Good Luck.

  • VC6-OGL

[This message has been edited by VC6-OGL (edited 12-24-2002).]

I tried, but no luck. I believe it is the way you are programming your gluOrtho2D. If you want it to resize to fit the window, you might have to re-program the whole thing.

  • VC6-OGL

HI

thank you for you

but i want in space area but some button for repaly
select x or o

but i don’t now how i can make change for computer in win better than that

i want make intlegent code

can you help me in this trick

best regards
Moon_Girl

You can find examples of programming the game X/O’s (Tic Tac Toe), maybe will give you an better idea of the game logic.

This site had a forum on programming X/O’s and the logic behind it.
http://www.experts-exchange.com/Programming/Programming_Languages/Cplusplus/Q_10837641.html

Originally posted by MOON-GIRL:
[b]HI

thank you for you

but i want in space area but some button for repaly
select x or o

but i don’t now how i can make change for computer in win better than that

i want make intlegent code

can you help me in this trick

best regards
Moon_Girl[/b]

HI

thank you

i well see it now and try modify my code

best regards
Moon_Girl