Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: I REALLY NEED HELP IN YHE CLIPPING

  1. #1
    Member Newbie
    Join Date
    Dec 2002
    Posts
    32

    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<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;
    }
    SEEK UNDERSTAND and WILL BE UNDERSTOOD

  2. #2
    Senior Member Regular Contributor
    Join Date
    Nov 2002
    Location
    USA
    Posts
    254

    Re: I REALLY NEED HELP IN YHE CLIPPING

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

  3. #3
    Member Newbie
    Join Date
    Dec 2002
    Posts
    32

    Re: I REALLY NEED HELP IN YHE CLIPPING

    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
    SEEK UNDERSTAND and WILL BE UNDERSTOOD

  4. #4
    Senior Member Regular Contributor
    Join Date
    Nov 2002
    Location
    USA
    Posts
    254

    Re: I REALLY NEED HELP IN YHE CLIPPING

    I'll see what I can do!!!

  5. #5
    Member Newbie
    Join Date
    Dec 2002
    Posts
    32

    Re: I REALLY NEED HELP IN YHE CLIPPING

    THANK YOU VERY MUCH


    I well wait you

    best regards
    Moon_Girl
    SEEK UNDERSTAND and WILL BE UNDERSTOOD

  6. #6
    Senior Member Regular Contributor
    Join Date
    Nov 2002
    Location
    USA
    Posts
    254

    Re: I REALLY NEED HELP IN YHE CLIPPING

    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).]

  7. #7
    Junior Member Newbie
    Join Date
    Dec 2002
    Posts
    12

    Re: I REALLY NEED HELP IN YHE CLIPPING

    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..

  8. #8
    Member Newbie
    Join Date
    Dec 2002
    Posts
    32

    Re: I REALLY NEED HELP IN YHE CLIPPING

    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


    2) 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).]
    SEEK UNDERSTAND and WILL BE UNDERSTOOD

  9. #9
    Senior Member Regular Contributor
    Join Date
    Nov 2002
    Location
    USA
    Posts
    254

    Re: I REALLY NEED HELP IN YHE CLIPPING

    Sure, no problem.

    - VC6-OGL

  10. #10
    Senior Member Regular Contributor
    Join Date
    Nov 2002
    Location
    USA
    Posts
    254

    Re: I REALLY NEED HELP IN YHE CLIPPING

    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).]

Page 1 of 2 12 LastLast

Similar Threads

  1. 4D clipping
    By Mungo in forum OpenGL: General
    Replies: 3
    Last Post: 05-06-2004, 06:58 AM
  2. how to do clipping?
    By candy in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 04-11-2004, 04:36 AM
  3. Replies: 1
    Last Post: 09-02-2003, 01:45 PM
  4. Clipping (not clipping) in opengl
    By FunkyLovin in forum OpenGL: Advanced Coding
    Replies: 3
    Last Post: 06-04-2001, 05:08 AM
  5. 3d clipping
    By vic in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 11-04-2000, 08:05 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean