Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 6 of 6

Thread: 3D my objects move themselves

Hybrid View

  1. #1
    Junior Member Newbie
    Join Date
    Sep 2013
    Posts
    3

    Exclamation 3D my objects move themselves

    please help me ,this is my project to apply to teacher

    I can't post picture or link tell me how to post it pls T_T
    Last edited by cherry; 09-14-2013 at 12:46 AM.

  2. #2
    Junior Member Newbie
    Join Date
    Sep 2013
    Posts
    3

    my code

    Code cpp:
    #include<GL\glut.h>
    float xx = 3,yy = 1,zz = 4;
    void color(float rd,float gd,float bd,float ad,float ra,float ga,float ba,float sh)
    {
        GLfloat mat_diffuse[] = {rd,gd,bd,ad};
        GLfloat mat_specular[] = {1.0f,1.0f,1.0f,1.0f};
        GLfloat mat_ambient[] = {ra,ga,ba,1.0f};
        GLfloat mat_shininess[] = {sh};
     
        glMaterialfv(GL_FRONT,GL_AMBIENT,mat_ambient);
        glMaterialfv(GL_FRONT,GL_DIFFUSE,mat_diffuse);
        glMaterialfv(GL_FRONT,GL_SPECULAR,mat_specular);
        glMaterialfv(GL_FRONT,GL_SHININESS,mat_shininess);
    }
     
    void roundChair()
    {
     
        //rounded chair
     
        GLUquadricObj *theObj;
        theObj = gluNewQuadric();
        gluQuadricDrawStyle(theObj,GLU_FILL);
     
        //top
        glPushMatrix();
        glTranslated(0.3,0.45,0.2);
        glRotated(90,1,0,0);
        gluCylinder(theObj,0.21,0.21,0.025,30,30);
        glPopMatrix();
     
     
        //close top
        glPushMatrix();
        glTranslated(0.3,0.45,0.2);
        glScaled(1,0.1,1);
        glutSolidSphere(0.21,30,30);
        glPopMatrix();
     
        //leg
        glPushMatrix();
        glTranslated(0.3,0.45,0.2);
        glRotated(90,1,0,0);
        gluCylinder(theObj,0.02,0.02,0.5,30,30);
        glPopMatrix();
     
        gluDeleteQuadric(theObj);
    }
     
     
     
    void wall(double thickness)
    {
        glPushMatrix();
        glTranslated(0.5,0.5*thickness,0.5);
        glScaled(1.5,thickness,1.5);
        glutSolidCube(1);
        glPopMatrix();
    }
     
     
    void slot(int rS,int gS,int bS,int rC,int gC,int bC)
    {
        ////slot machine
     
        color(rS,gS,bS,1,0,0,0,10);
        GLUquadricObj *theObj;
        theObj = gluNewQuadric();
        gluQuadricDrawStyle(theObj,GLU_FILL);
     
        //cylinder and close end
        glPushMatrix();
        glTranslated(0,-.53,0);
     
     
            glPushMatrix();
            glScaled(1,.7,.7);
            glTranslated(-0.004,.85,-.05);
     
                color(1, 1, 0,1,0,0,0,200);
     
                glPushMatrix();
                glTranslated(0.3,2,0.2);
                glRotated(90,0,1,0);
                gluCylinder(theObj,0.31,0.31,0.15,30,30);
                glPopMatrix();
     
                color(1, 0.501, 0.752,1,0,0,0,200);
     
                glPushMatrix();
                glTranslated(0.5,2,0.2);
                glRotated(90,0,1,0);
                gluCylinder(theObj,0.31,0.31,0.15,30,30);
                glPopMatrix();
     
                color(0.909, 0.313, 0.141,1,0,0,0,200);
     
                glPushMatrix();
                glTranslated(0.7,2,0.2);
                glRotated(90,0,1,0);
                gluCylinder(theObj,0.31,0.31,0.15,30,30);
                glPopMatrix();
     
                //lid cylinder
     
                glPushMatrix();    
                glTranslated(0.85,2,0.2);
                glRotated(90,0,0,1);
                glScaled(1,0.1,1);
                gluSphere(theObj,0.31,31,30);
                glPopMatrix();
     
                glPushMatrix();
                glTranslated(0.3,2,0.2);
                glRotated(90,0,0,1);
                glScaled(1,0.1,1);
                gluSphere(theObj,0.31,31,30);
                glPopMatrix();
     
            glPopMatrix();
     
            color(rS,gS,bS,1,1,1,0,100);
            //upper cube 
     
            glPushMatrix();
            glTranslated(0.57,1.6,0.11);
            glScaled(1,0.5,.7);
            glutSolidCube(.62);
            glPopMatrix();
     
            //lower cube
     
            glPushMatrix();
            glTranslated(0.57,1,0.2);
            glScaled(1,1.5,1);
            glutSolidCube(.62);
            glPopMatrix();
     
     
     
            //intervention
     
            glPushMatrix();
            glTranslated(0.29,2,0.11);
            glScaled(.1,1,.7);
            glutSolidCube(.62);
            glPopMatrix();
     
            glPushMatrix();
            glTranslated(0.476,2,0.11);
            glScaled(.1,1,.7);
            glutSolidCube(.62);
            glPopMatrix();
     
            glPushMatrix();
            glTranslated(0.662,2,0.11);
            glScaled(.1,1,.7);
            glutSolidCube(.62);
            glPopMatrix();
     
            glPushMatrix();
            glTranslated(0.85,2,0.11);
            glScaled(.1,1,.7);
            glutSolidCube(.62);
            glPopMatrix();
     
            //surface lid
     
            glEnable(GL_BLEND);
            glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
            color(0, 1, 1,.25,1,1,1,500);
     
            glPushMatrix();
            glTranslated(.58,2,0.35);
            glScaled(1,.8,.05);
            glutSolidCube(.62);
            glPopMatrix();
     
            //beyond lid
     
            color(rS,gS,bS,1,1,1,0,100);
     
            glPushMatrix();
            glTranslated(0.57,2.3,0.09);
            glScaled(1,.2,1);
            glutSolidCube(.62);
            glPopMatrix();
     
     
            color(1, 0, 1,1,0,0,0,5);
            //button
     
            glPushMatrix();
            glTranslated(0.78,1.45,0.42);
            glutSolidCube(.08);
            glPopMatrix();
     
            color(0.501, 1, 0.501,1,0,0,0,5);
     
            glPushMatrix();
            glTranslated(0.58,1.45,0.42);
            glutSolidCube(.08);
            glPopMatrix();
     
            color(0, 0, 1,1,0,0,0,5);
     
            glPushMatrix();
            glTranslated(0.38,1.45,0.42);
            glutSolidCube(.08);
            glPopMatrix();
     
            //side bar
     
            color(0, 0, 0,1,0,0,0,5);
     
            glPushMatrix();
                glTranslated(.88,1.6,0.2);
                glRotated(90,0,1,0);
                gluCylinder(theObj,0.1,0.1,0.05,30,30);
            glPopMatrix();
     
            glPushMatrix();    
                glTranslated(.93,1.6,0.2);
                glRotated(90,0,0,1);
                glScaled(1,0.3,1);
                gluSphere(theObj,0.1,31,30);
            glPopMatrix();
     
            glPushMatrix();
                glTranslated(.95,1.6,0.2);
                glRotated(250,1,0,0);
                gluCylinder(theObj,0.03,0.03,0.5,30,30);
            glPopMatrix();
     
            glPushMatrix();    
                glTranslated(0.95,2.11,0.03);
                gluSphere(theObj,0.05,31,30);
            glPopMatrix();
     
            color(0, 0, 0,1,0,0,0,200);
            //drawer
            glPushMatrix();
                glRotated(-10,1,0,0);
                glTranslated(.58,1,0.75);
                glScaled(1,.8,.05);
                glutSolidCube(.62);
            glPopMatrix();
     
            color(rC,gC,bC,1,0,0,0,200);
     
            glPushMatrix();
                glScaled(1.5,1.5,1.5);
                glTranslated(0.09,.4,0.5);
                roundChair();
            glPopMatrix();
            gluDeleteQuadric(theObj);
     
    }
    //end slot
    void dart()
    {
        glPushMatrix();
        glTranslated(1.2,1.7,0);
        glScaled(0.7,0.7,0.7);
     
            GLUquadricObj *theObj;
            theObj = gluNewQuadric();
            gluQuadricDrawStyle(theObj,GLU_FILL);
     
            color(1,0,0,1,1,1,1,10);
            gluPartialDisk(theObj,0,0.5,70,70,0,20);
            gluDeleteQuadric(theObj);
     
            color(0,1,0,1,1,1,1,10);
     
            theObj = gluNewQuadric();
            gluPartialDisk(theObj,0,0.5,70,70,21,20);
            gluDeleteQuadric(theObj);
     
            color(0,0,1,1,1,1,1,10);
     
            theObj = gluNewQuadric();
            gluPartialDisk(theObj,0,0.5,70,70,41,20);
            gluDeleteQuadric(theObj);
     
            color(1,0,0,1,1,1,1,10);
     
            theObj = gluNewQuadric();
            gluPartialDisk(theObj,0,0.5,70,70,61,20);
            gluDeleteQuadric(theObj);
     
            color(0,1,0,1,1,1,1,10);
     
            theObj = gluNewQuadric();
            gluPartialDisk(theObj,0,0.5,70,70,81,20);
            gluDeleteQuadric(theObj);
     
            color(0,0,1,1,1,1,1,10);
     
            theObj = gluNewQuadric();
            gluPartialDisk(theObj,0,0.5,70,70,101,20);
            gluDeleteQuadric(theObj);
            color(1,0,0,1,1,1,1,10);
     
     
            theObj = gluNewQuadric();
            gluPartialDisk(theObj,0,0.5,70,70,121,20);
            gluDeleteQuadric(theObj);
            color(0,1,0,1,1,1,1,10);
     
     
            theObj = gluNewQuadric();
            gluPartialDisk(theObj,0,0.5,70,70,141,20);
            gluDeleteQuadric(theObj);
            color(0,0,1,1,1,1,1,10);
     
     
            theObj = gluNewQuadric();
            gluPartialDisk(theObj,0,0.5,70,70,161,20);
            gluDeleteQuadric(theObj);
            color(1,0,0,1,1,1,1,10);
     
     
            theObj = gluNewQuadric();
            gluPartialDisk(theObj,0,0.5,70,70,181,20);
            gluDeleteQuadric(theObj);
            color(0,1,0,1,1,1,1,10);
     
     
            theObj = gluNewQuadric();
            gluPartialDisk(theObj,0,0.5,70,70,201,20);
            gluDeleteQuadric(theObj);
            color(0,0,1,1,1,1,1,10);
     
     
            theObj = gluNewQuadric();
            gluPartialDisk(theObj,0,0.5,70,70,221,20);
            gluDeleteQuadric(theObj);
            color(1,0,0,1,1,1,1,10);
     
     
            theObj = gluNewQuadric();
            gluPartialDisk(theObj,0,0.5,70,70,241,20);
            gluDeleteQuadric(theObj);
            color(0,1,0,1,1,1,1,10);
     
     
            theObj = gluNewQuadric();
            gluPartialDisk(theObj,0,0.5,70,70,261,20);
            gluDeleteQuadric(theObj);
            color(0,0,1,1,1,1,1,10);
     
     
            theObj = gluNewQuadric();
            gluPartialDisk(theObj,0,0.5,70,70,281,20);
            gluDeleteQuadric(theObj);
            color(1,0,0,1,1,1,1,10);
     
     
            theObj = gluNewQuadric();
            gluPartialDisk(theObj,0,0.5,70,70,301,20);
            gluDeleteQuadric(theObj);
            color(0,1,0,1,1,1,1,10);
     
     
            theObj = gluNewQuadric();
            gluPartialDisk(theObj,0,0.5,70,70,321,20);
            gluDeleteQuadric(theObj);
            color(0,0,1,1,1,1,1,10);
     
     
            theObj = gluNewQuadric();
            gluPartialDisk(theObj,0,0.5,70,70,341,20);
            gluDeleteQuadric(theObj);
     
            //frame
     
            color (1,1,1,1,1,1,1,100);
            glutSolidTorus(0.02,0.5,50,50);
     
            color (1,1,1,1,1,1,1,100);
            glPushMatrix();
            glTranslated(0,0,0);
            glScaled(1,1,.05);
            glutSolidSphere(0.2,50,50);
     
            glPopMatrix();
     
     
        //arrow
     
            glPushMatrix();
                color(0,0,0,1,1,1,1,10);
                glRotated(30,1,0,1);
                theObj = gluNewQuadric();
                gluCylinder(theObj,.016,.016,.9,30,30);
     
                color(1,0,0,1,1,1,1,10);
                glPushMatrix();
                    glTranslated(0,0,.9);
                    glScaled(.07,.5,.2);
                    glutSolidCube(0.5);
                glPopMatrix();
            glPopMatrix();
     
            glPushMatrix();
                color(0,0,0,1,1,1,1,10);
                glTranslated(0,0.1,0);
                glRotated(-50,1,0,1);
                theObj = gluNewQuadric();
                gluCylinder(theObj,.016,.016,.9,30,30);
     
                color(1,0,0,1,1,1,1,10);
                glPushMatrix();
                    glTranslated(0,0,.9);
                    glScaled(.07,.5,.2);
                    glutSolidCube(0.5);
                glPopMatrix();
            glPopMatrix();
     
     
            glPushMatrix();
                color(0,0,0,1,1,1,1,10);
                glTranslated(0.1,-.07,0);
                glRotated(90,1,0,1);
                theObj = gluNewQuadric();
                gluCylinder(theObj,.016,.016,.9,30,30);
     
                color(1,0,0,1,1,1,1,10);
                glPushMatrix();
                    glTranslated(0,0,.84);
                    glScaled(.07,.5,.2);
                    glutSolidCube(0.5);
                glPopMatrix();
            glPopMatrix();
     
            glPushMatrix();
                color(0,0,0,1,1,1,1,10);
                glTranslated(-0.1,0,0);
                glRotated(-60,1,1,1);
                theObj = gluNewQuadric();
                gluCylinder(theObj,.016,.016,.9,30,30);
     
                color(1,0,0,1,1,1,1,10);
                glPushMatrix();
                    glTranslated(0,0,.9);
                    glScaled(.07,.5,.2);
                    glutSolidCube(0.5);
                glPopMatrix();
            glPopMatrix();
     
            color(0.501, 0.250, 0,1,1,1,1,10);
     
        // arrow bucket
            glPushMatrix();
                glTranslated(-1,-1.5,0.5);
                glRotated(90,1,0,0);
                theObj = gluNewQuadric();
                gluCylinder(theObj,.2,.2,.9,30,30);
     
     
            glPopMatrix();
        // arrows
                glPushMatrix();
     
                    glTranslated(-1,-1,0.5);
                    glRotated(90,1,0,0);
                        color(0,0,0,1,0,0,0,100);
                        theObj = gluNewQuadric();
                        gluCylinder(theObj,.016,.016,.9,30,30);
                glPopMatrix();
     
            color(1,0,0,1,0,0,0,100);
     
            //tail
                glPushMatrix();
                    glTranslated(-1,-1,0.5);
                    glScaled(2.4,1.17,0.7);
                        glutSolidCube(0.1);
                glPopMatrix();
     
                glPushMatrix();
                    glTranslated(-.75,0.3,0.7);
                    glRotated(30,1,0,1);
                    glPushMatrix();
     
                        glTranslated(-1,-1,0.5);
                        glRotated(90,1,0,0);
                            color(0,0,0,1,0,0,0,100);
                            theObj = gluNewQuadric();
                            gluCylinder(theObj,.016,.016,.9,30,30);
                    glPopMatrix();
     
                    color(1,0,0,1,0,0,0,100);
     
                    //tail
                    glPushMatrix();
                        glTranslated(-1,-1,0.5);
                        glScaled(2.4,1.17,0.7);
                        glutSolidCube(0.1);
                    glPopMatrix();
                glPopMatrix();
     
                glPushMatrix();
                    glTranslated(-.18,0.2,0);
                    glRotated(5,0,0,1);
                    glPushMatrix();
     
                        glTranslated(-1,-1,0.5);
                        glRotated(90,1,0,0);
                            color(0,0,0,1,0,0,0,100);
                            theObj = gluNewQuadric();
                            gluCylinder(theObj,.016,.016,.9,30,30);
                    glPopMatrix();
     
                    color(1,0,0,1,0,0,0,100);
     
                    //tail
                    glPushMatrix();
                        glTranslated(-1,-1,0.5);
                        glScaled(2.4,1.17,0.7);
                            glutSolidCube(0.1);
                    glPopMatrix();
                glPopMatrix();
     
                glPushMatrix();
                    glTranslated(.4,-0.3,-.3);
                    glRotated(-20,1,0,1);
                    glPushMatrix();
     
                        glTranslated(-1,-1,0.5);
                        glRotated(90,1,0,0);
                            color(0,0,0,1,0,0,0,100);
                            theObj = gluNewQuadric();
                            gluCylinder(theObj,.016,.016,.9,30,30);
                    glPopMatrix();
     
                    color(1,0,0,1,0,0,0,100);
     
                    //tail
                    glPushMatrix();
                        glTranslated(-1,-1,0.5);
                        glScaled(2.4,1.17,0.7);
                            glutSolidCube(0.1);
                    glPopMatrix();
                glPopMatrix();
     
                color(0.501, 1, 0,1,0,0,0,100);
     
                //carpet
                glPushMatrix();
                        glTranslated(0,-2.4,1.6);
                        glScaled(25,0.2,30.4);
                            glutSolidCube(0.1);
                glPopMatrix();
            glPopMatrix();
    }
    //end dart
     
    void coinRouleteRed()
    {
        int ht = 0;
        color(1,1,1,1.0f,1,1,1,50.0f);
     
            glPushMatrix();
            glTranslated(-.12,0,0.2);
            glScaled(0.8,1,0.8);
                glPushMatrix();
                    glTranslated(0,0.99,3);
                    glScaled(1,0.15,1);
                    glutSolidSphere(0.07,30,30);
                glPopMatrix();
     
                glPushMatrix();
                    glTranslated(0,0.99,3);
                    glRotated(90,1,0,0);
                    color(0.980, 0.243, 0.113,1.0f,1,1,1,50.0f);
                    glutSolidTorus(0.01,0.08,30,30);
                glPopMatrix();
            glPopMatrix();
     
            color(1,1,1,1.0f,1,1,1,50.0f);
     
            glPushMatrix();
            glTranslated(-.12,0.022,0.2);
            glScaled(0.8,1,0.8);
                glPushMatrix();
                    glTranslated(0,0.99,3);
                    glScaled(1,0.15,1);
                    glutSolidSphere(0.07,30,30);
                glPopMatrix();
     
                glPushMatrix();
                    glTranslated(0,0.99,3);
                    glRotated(90,1,0,0);
                    color(0.980, 0.243, 0.113,1.0f,1,1,1,50.0f);
                    glutSolidTorus(0.01,0.08,30,30);
                glPopMatrix();
            glPopMatrix();
     
            color(1,1,1,1.0f,1,1,1,50.0f);
     
            glPushMatrix();
            glTranslated(-.12,.044,0.2);
            glScaled(0.8,1,0.8);
                glPushMatrix();
                    glTranslated(0,0.99,3);
                    glScaled(1,0.15,1);
                    glutSolidSphere(0.07,30,30);
                glPopMatrix();
     
                glPushMatrix();
                    glTranslated(0,0.99,3);
                    glRotated(90,1,0,0);
                    color(0.980, 0.243, 0.113,1.0f,1,1,1,50.0f);
                    glutSolidTorus(0.01,0.08,30,30);
                glPopMatrix();
            glPopMatrix();
     
            color(1,1,1,1.0f,1,1,1,50.0f);
            glPushMatrix();
            glTranslated(-.12,.066,0.2);
            glScaled(0.8,1,0.8);
                glPushMatrix();
                    glTranslated(0,0.99,3);
                    glScaled(1,0.15,1);
                    glutSolidSphere(0.07,30,30);
                glPopMatrix();
     
                glPushMatrix();
                    glTranslated(0,0.99,3);
                    glRotated(90,1,0,0);
                    color(0.980, 0.243, 0.113,1.0f,1,1,1,50.0f);
                    glutSolidTorus(0.01,0.08,30,30);
                glPopMatrix();
            glPopMatrix();
     
            color(1,1,1,1.0f,1,1,1,50.0f);
            glPushMatrix();
            glTranslated(-.12,.088,0.2);
            glScaled(0.8,1,0.8);
                glPushMatrix();
                    glTranslated(0,0.99,3);
                    glScaled(1,0.15,1);
                    glutSolidSphere(0.07,30,30);
                glPopMatrix();
     
                glPushMatrix();
                    glTranslated(0,0.99,3);
                    glRotated(90,1,0,0);
                    color(0.980, 0.243, 0.113,1.0f,1,1,1,50.0f);
                    glutSolidTorus(0.01,0.08,30,30);
                glPopMatrix();
            glPopMatrix();
    }
    void coinRouleteBlue()
    {
        color(1,1,1,1.0f,1,1,1,50.0f);
     
        glPushMatrix();
        glTranslated(-.26,0,0.3);
        glScaled(0.8,1,0.8);
            glPushMatrix();
                glTranslated(0,0.99,3);
                glScaled(1,0.15,1);
                glutSolidSphere(0.07,30,30);
            glPopMatrix();
     
            glPushMatrix();
                glTranslated(0,0.99,3);
                glRotated(90,1,0,0);
                color(0, 0, 0.913,1.0f,1,1,1,50.0f);
                glutSolidTorus(0.01,0.08,30,30);
            glPopMatrix();
        glPopMatrix();
     
     
            color(1,1,1,1.0f,1,1,1,50.0f);
     
            glPushMatrix();
            glTranslated(-.26,0.022,0.3);
            glScaled(0.8,1,0.8);
                glPushMatrix();
                    glTranslated(0,0.99,3);
                    glScaled(1,0.15,1);
                    glutSolidSphere(0.07,30,30);
                glPopMatrix();
     
                glPushMatrix();
                    glTranslated(0,0.99,3);
                    glRotated(90,1,0,0);
                    color(0, 0, 0.913,1.0f,1,1,1,50.0f);
                    glutSolidTorus(0.01,0.08,30,30);
                glPopMatrix();
            glPopMatrix();
     
            color(1,1,1,1.0f,1,1,1,50.0f);
     
            glPushMatrix();
            glTranslated(-.26,.044,0.3);
            glScaled(0.8,1,0.8);
                glPushMatrix();
                    glTranslated(0,0.99,3);
                    glScaled(1,0.15,1);
                    glutSolidSphere(0.07,30,30);
                glPopMatrix();
     
                glPushMatrix();
                    glTranslated(0,0.99,3);
                    glRotated(90,1,0,0);
                    color(0, 0, 0.913,1.0f,1,1,1,50.0f);
                    glutSolidTorus(0.01,0.08,30,30);
                glPopMatrix();
            glPopMatrix();
     
            color(1,1,1,1.0f,1,1,1,50.0f);
            glPushMatrix();
            glTranslated(-.26,.066,0.3);
            glScaled(0.8,1,0.8);
                glPushMatrix();
                    glTranslated(0,0.99,3);
                    glScaled(1,0.15,1);
                    glutSolidSphere(0.07,30,30);
                glPopMatrix();
     
                glPushMatrix();
                    glTranslated(0,0.99,3);
                    glRotated(90,1,0,0);
                    color(0, 0, 0.913,1.0f,1,1,1,50.0f);
                    glutSolidTorus(0.01,0.08,30,30);
                glPopMatrix();
            glPopMatrix();
     
            color(1,1,1,1.0f,1,1,1,50.0f);
            glPushMatrix();
            glTranslated(-.26,.088,0.3);
            glScaled(0.8,1,0.8);
                glPushMatrix();
                    glTranslated(0,0.99,3);
                    glScaled(1,0.15,1);
                    glutSolidSphere(0.07,30,30);
                glPopMatrix();
     
                glPushMatrix();
                    glTranslated(0,0.99,3);
                    glRotated(90,1,0,0);
                    color(0, 0, 0.913,1.0f,1,1,1,50.0f);
                    glutSolidTorus(0.01,0.08,30,30);
                glPopMatrix();
            glPopMatrix();
    }
    void coinRouleteYellow()
    {
        color(1,1,1,1.0f,1,1,1,50.0f);
     
        glPushMatrix();
        glTranslated(-.45,0,0.3);
        glScaled(0.8,1,0.8);
            glPushMatrix();
                glTranslated(0,0.99,3);
                glScaled(1,0.15,1);
                glutSolidSphere(0.07,30,30);
            glPopMatrix();
     
            glPushMatrix();
                glTranslated(0,0.99,3);
                glRotated(90,1,0,0);
                color(1, 1, 0,1.0f,1,1,1,50.0f);
                glutSolidTorus(0.01,0.08,30,30);
            glPopMatrix();
        glPopMatrix();
     
     
            color(1,1,1,1.0f,1,1,1,50.0f);
     
            glPushMatrix();
            glTranslated(-.45,0.022,0.3);
            glScaled(0.8,1,0.8);
                glPushMatrix();
                    glTranslated(0,0.99,3);
                    glScaled(1,0.15,1);
                    glutSolidSphere(0.07,30,30);
                glPopMatrix();
     
                glPushMatrix();
                    glTranslated(0,0.99,3);
                    glRotated(90,1,0,0);
                    color(1, 1, 0,1.0f,1,1,1,50.0f);
                    glutSolidTorus(0.01,0.08,30,30);
                glPopMatrix();
            glPopMatrix();
     
            color(1,1,1,1.0f,1,1,1,50.0f);
     
            glPushMatrix();
            glTranslated(-.45,.044,0.3);
            glScaled(0.8,1,0.8);
                glPushMatrix();
                    glTranslated(0,0.99,3);
                    glScaled(1,0.15,1);
                    glutSolidSphere(0.07,30,30);
                glPopMatrix();
     
                glPushMatrix();
                    glTranslated(0,0.99,3);
                    glRotated(90,1,0,0);
                    color(1, 1, 0,1.0f,1,1,1,50.0f);
                    glutSolidTorus(0.01,0.08,30,30);
                glPopMatrix();
            glPopMatrix();
     
            color(1,1,1,1.0f,1,1,1,50.0f);
            glPushMatrix();
            glTranslated(-.45,.066,0.3);
            glScaled(0.8,1,0.8);
                glPushMatrix();
                    glTranslated(0,0.99,3);
                    glScaled(1,0.15,1);
                    glutSolidSphere(0.07,30,30);
                glPopMatrix();
     
                glPushMatrix();
                    glTranslated(0,0.99,3);
                    glRotated(90,1,0,0);
                    color(1, 1, 0,1.0f,1,1,1,50.0f);
                    glutSolidTorus(0.01,0.08,30,30);
                glPopMatrix();
            glPopMatrix();
     
            color(1,1,1,1.0f,1,1,1,50.0f);
            glPushMatrix();
            glTranslated(-.45,.088,0.3);
            glScaled(0.8,1,0.8);
                glPushMatrix();
                    glTranslated(0,0.99,3);
                    glScaled(1,0.15,1);
                    glutSolidSphere(0.07,30,30);
                glPopMatrix();
     
                glPushMatrix();
                    glTranslated(0,0.99,3);
                    glRotated(90,1,0,0);
                    color(1, 1, 0,1.0f,1,1,1,50.0f);
                    glutSolidTorus(0.01,0.08,30,30);
                glPopMatrix();
            glPopMatrix();
     
    }
    void coinRouleteBlack()
    {
        color(1,1,1,1.0f,1,1,1,50.0f);
     
        glPushMatrix();
        glTranslated(-.64,0,0.22);
        glScaled(0.8,1,0.8);
            glPushMatrix();
                glTranslated(0,0.99,3);
                glScaled(1,0.15,1);
                glutSolidSphere(0.07,30,30);
            glPopMatrix();
     
            glPushMatrix();
                glTranslated(0,0.99,3);
                glRotated(90,1,0,0);
                color(0,0, 0,1.0f,1,1,1,50.0f);
                glutSolidTorus(0.01,0.08,30,30);
            glPopMatrix();
        glPopMatrix();
     
     
            color(1,1,1,1.0f,1,1,1,50.0f);
     
            glPushMatrix();
            glTranslated(-.64,0.022,0.22);
            glScaled(0.8,1,0.8);
                glPushMatrix();
                    glTranslated(0,0.99,3);
                    glScaled(1,0.15,1);
                    glutSolidSphere(0.07,30,30);
                glPopMatrix();
     
                glPushMatrix();
                    glTranslated(0,0.99,3);
                    glRotated(90,1,0,0);
                    color(0,0, 0,1.0f,1,1,1,50.0f);
                    glutSolidTorus(0.01,0.08,30,30);
                glPopMatrix();
            glPopMatrix();
     
            color(1,1,1,1.0f,1,1,1,50.0f);
     
            glPushMatrix();
            glTranslated(-.64,.044,0.22);
            glScaled(0.8,1,0.8);
                glPushMatrix();
                    glTranslated(0,0.99,3);
                    glScaled(1,0.15,1);
                    glutSolidSphere(0.07,30,30);
                glPopMatrix();
     
                glPushMatrix();
                    glTranslated(0,0.99,3);
                    glRotated(90,1,0,0);
                    color(0,0, 0,1.0f,1,1,1,50.0f);
                    glutSolidTorus(0.01,0.08,30,30);
                glPopMatrix();
            glPopMatrix();
     
            color(1,1,1,1.0f,1,1,1,50.0f);
            glPushMatrix();
            glTranslated(-.64,.066,0.22);
            glScaled(0.8,1,0.8);
                glPushMatrix();
                    glTranslated(0,0.99,3);
                    glScaled(1,0.15,1);
                    glutSolidSphere(0.07,30,30);
                glPopMatrix();
     
                glPushMatrix();
                    glTranslated(0,0.99,3);
                    glRotated(90,1,0,0);
                    color(0,0, 0,1.0f,1,1,1,50.0f);
                    glutSolidTorus(0.01,0.08,30,30);
                glPopMatrix();
            glPopMatrix();
     
            color(1,1,1,1.0f,1,1,1,50.0f);
            glPushMatrix();
            glTranslated(-.64,.088,0.22);
            glScaled(0.8,1,0.8);
                glPushMatrix();
                    glTranslated(0,0.99,3);
                    glScaled(1,0.15,1);
                    glutSolidSphere(0.07,30,30);
                glPopMatrix();
     
                glPushMatrix();
                    glTranslated(0,0.99,3);
                    glRotated(90,1,0,0);
                    color(0,0, 0,1.0f,1,1,1,50.0f);
                    glutSolidTorus(0.01,0.08,30,30);
                glPopMatrix();
            glPopMatrix();
     
    }
    void roulette()
    {
        color(0.501, 0.250, 0,1.0f,1,1,1,50.0f);
        //table square
     
     
        //table
     
        glPushMatrix();
            glTranslatef(-.4,0.74,3);
            glScaled(.8,0.5,1.36);
            glutSolidCube(1);
        glPopMatrix();
     
        color(1,1,1,1.0f,1,1,1,50.0f);
        //pattern 1
        glPushMatrix();
        glTranslatef(-.02,0,0);
            glPushMatrix();
                glTranslatef(-.55,0.95,3.3);
                glScaled(.03,0.09,0.7);
                glutSolidCube(1);
            glPopMatrix();
     
            glPushMatrix();
                glTranslatef(-.45,0.95,3.3);
                glScaled(.03,0.09,0.7);
                glutSolidCube(1);
            glPopMatrix();
     
            glPushMatrix();
                glTranslatef(-.35,0.95,3.3);
                glScaled(.03,0.09,0.7);
                glutSolidCube(1);
            glPopMatrix();
     
            glPushMatrix();
                glTranslatef(-.25,0.95,3.3);
                glScaled(.03,0.09,0.7);
                glutSolidCube(1);
            glPopMatrix();
        glPopMatrix();
     
        //pattern 2
     
            glPushMatrix();
                glTranslatef(-.42,0.95,3.65);
                glScaled(.32,0.09,0.03);
                glutSolidCube(1);
            glPopMatrix();
     
            glPushMatrix();
                glTranslatef(-.42,0.95,3.55);
                glScaled(.32,0.09,0.03);
                glutSolidCube(1);
            glPopMatrix();
     
            glPushMatrix();
                glTranslatef(-.42,0.95,3.45);
                glScaled(.32,0.09,0.03);
                glutSolidCube(1);
            glPopMatrix();
     
            glPushMatrix();
                glTranslatef(-.42,0.95,3.35);
                glScaled(.32,0.09,0.03);
                glutSolidCube(1);
            glPopMatrix();
     
            glPushMatrix();
                glTranslatef(-.42,0.95,3.25);
                glScaled(.32,0.09,0.03);
                glutSolidCube(1);
            glPopMatrix();
     
            glPushMatrix();
                glTranslatef(-.42,0.95,3.15);
                glScaled(.32,0.09,0.03);
                glutSolidCube(1);
            glPopMatrix();
     
            glPushMatrix();
                glTranslatef(-.42,0.95,3.05);
                glScaled(.32,0.09,0.03);
                glutSolidCube(1);
            glPopMatrix();
     
            glPushMatrix();
                glTranslatef(-.42,0.95,2.95);
                glScaled(.32,0.09,0.03);
                glutSolidCube(1);
            glPopMatrix();
     
     
     
        color(0.501, 0.250, 0,1.0f,1,1,1,50.0f);
     
        glPushMatrix();
            glTranslatef(-0.2,0.18,.3);
                ////table round
                GLUquadricObj *theObj;
                theObj = gluNewQuadric();
                gluQuadricDrawStyle(theObj,GLU_FILL);
     
                glPushMatrix();
                    glTranslatef(-.2,.8,2);
                    glRotated(90,1,0,0);
                    gluCylinder(theObj,0.4,0.4,0.5,30,30);
                glPopMatrix();
     
                glPushMatrix();
                    glTranslatef(-.2,.8,3.4);
                    glRotated(90,1,0,0);
                    gluCylinder(theObj,0.4,0.4,0.5,30,30);
                glPopMatrix();
     
                //lid round two sides
     
                glPushMatrix();    
                    glTranslated(-.2,0.8,2);
                    glScaled(1,0.005,1);
                    glutSolidSphere(0.4,50,50);
                glPopMatrix();
     
     
     
                glPushMatrix();    
                    glTranslated(-.2,0.8,3.4);
                    glScaled(1,0.005,1);
                    glutSolidSphere(0.4,50,50);
                glPopMatrix();
     
                //lift up round
     
                color(0.501, 0, 0,1,1,1,1,200);
                glPushMatrix();
                    glTranslatef(-.2,1,2);
                    glRotated(90,1,0,0);
                    gluCylinder(theObj,0.25,0.25,0.5,30,30);
                glPopMatrix();
     
                //close round high
            /*    color(0.501, 0.250, 0,1,1,1,1,200);
                glPushMatrix();
     
                    glScaled(1,0.02,1);
                    glRotated(90,1,0,0);
                    glutSolidTorus(0.05,0.2,50,50);
                glPopMatrix();*/
     
     
     
            glPushMatrix();
            glTranslated(-.2,1,2);
            glRotated(-90,1,0,0);
            glScaled(0.5,0.5,0.5);
     
     
            theObj = gluNewQuadric();
            gluQuadricDrawStyle(theObj,GLU_FILL);
     
            color(0,0,0,1,1,1,1,10);
            gluPartialDisk(theObj,0,0.5,70,70,0,20);
            gluDeleteQuadric(theObj);
     
            color(1,1,1,1,1,1,1,10);
     
            theObj = gluNewQuadric();
            gluPartialDisk(theObj,0,0.5,70,70,21,20);
            gluDeleteQuadric(theObj);
     
            color(0,0,0,1,1,1,1,10);
     
            theObj = gluNewQuadric();
            gluPartialDisk(theObj,0,0.5,70,70,41,20);
            gluDeleteQuadric(theObj);
     
            color(1,1,1,1,1,1,1,10);
     
            theObj = gluNewQuadric();
            gluPartialDisk(theObj,0,0.5,70,70,61,20);
            gluDeleteQuadric(theObj);
     
            color(0,0,0,1,1,1,1,10);
     
            theObj = gluNewQuadric();
            gluPartialDisk(theObj,0,0.5,70,70,81,20);
            gluDeleteQuadric(theObj);
     
            color(1,1,1,1,1,1,1,10);
     
            theObj = gluNewQuadric();
            gluPartialDisk(theObj,0,0.5,70,70,101,20);
            gluDeleteQuadric(theObj);
            color(0,0,0,1,1,1,1,10);
     
     
            theObj = gluNewQuadric();
            gluPartialDisk(theObj,0,0.5,70,70,121,20);
            gluDeleteQuadric(theObj);
            color(1,1,1,1,1,1,1,10);
     
     
            theObj = gluNewQuadric();
            gluPartialDisk(theObj,0,0.5,70,70,141,20);
            gluDeleteQuadric(theObj);
            color(0,0,0,1,1,1,1,10);
     
     
            theObj = gluNewQuadric();
            gluPartialDisk(theObj,0,0.5,70,70,161,20);
            gluDeleteQuadric(theObj);
            color(1,1,1,1,1,1,1,10);
     
     
            theObj = gluNewQuadric();
            gluPartialDisk(theObj,0,0.5,70,70,181,20);
            gluDeleteQuadric(theObj);
            color(0,0,0,1,1,1,1,10);
     
     
            theObj = gluNewQuadric();
            gluPartialDisk(theObj,0,0.5,70,70,201,20);
            gluDeleteQuadric(theObj);
            color(1,1,1,1,1,1,1,10);
     
     
            theObj = gluNewQuadric();
            gluPartialDisk(theObj,0,0.5,70,70,221,20);
            gluDeleteQuadric(theObj);
            color(0,0,0,1,1,1,1,10);
     
     
            theObj = gluNewQuadric();
            gluPartialDisk(theObj,0,0.5,70,70,241,20);
            gluDeleteQuadric(theObj);
            color(1,1,1,1,1,1,1,10);
     
     
            theObj = gluNewQuadric();
            gluPartialDisk(theObj,0,0.5,70,70,261,20);
            gluDeleteQuadric(theObj);
            color(0,0,0,1,1,1,1,10);
     
     
            theObj = gluNewQuadric();
            gluPartialDisk(theObj,0,0.5,70,70,281,20);
            gluDeleteQuadric(theObj);
            color(1,1,1,1,1,1,1,10);
     
            theObj = gluNewQuadric();
            gluPartialDisk(theObj,0,0.5,70,70,301,20);
            gluDeleteQuadric(theObj);
            color(0,0,0,1,1,1,1,10);
     
     
            theObj = gluNewQuadric();
            gluPartialDisk(theObj,0,0.5,70,70,321,20);
            gluDeleteQuadric(theObj);
            color(1,1,1,1,1,1,1,10);
     
     
            theObj = gluNewQuadric();
            gluPartialDisk(theObj,0,0.5,70,70,341,20);
            gluDeleteQuadric(theObj);
     
     
     
            glPopMatrix();
     
                color(0,0,0,1.0f,1,1,1,50.0f);
                glPushMatrix();
                    glTranslated(-.2,1,2);
                    glRotated(90,1,0,0);
                    glutSolidTorus(0.02,0.25,50,50);
                glPopMatrix();
     
                color(0.854, 0.513, 0.047,1,1,1,1,200);
                //cone
                glPushMatrix();    
                    glTranslated(-.199,1.01,2.01);
                    glRotated(-90,1,0,0);
                    glutSolidCone(.1,.06,30,10);
                glPopMatrix();
     
                color(0,0,0,1,1,1,1,200);
                glPushMatrix();
                    glTranslated(-.199,1.05,2.01);
                    glutSolidSphere(0.05,10,10);
                glPopMatrix();
     
                glPushMatrix();    
                    glTranslated(-.199,1.1,2.01);
                    glRotated(-90,1,0,0);
                    glutSolidCone(.025,.15,30,10);
                glPopMatrix();
     
                //top of high round
     
     
     
                glPushMatrix();
                    glTranslated(-.199,1.23,2.01);
                    glutSolidSphere(0.04,10,10);
                glPopMatrix();
     
                glPushMatrix();
                    glTranslatef(-.274,1.23,2.01);
                    glRotated(90,0,1,0);
                    gluCylinder(theObj,0.02,0.02,0.15,30,30);
                glPopMatrix();
     
                glPushMatrix();
                    glTranslatef(-.2,1.23,1.95);
                    gluCylinder(theObj,0.02,0.02,0.15,30,30);
                glPopMatrix();
     
                color(1,1,1,1,1,1,1,200);
                //ball
                glPushMatrix();
                    glTranslated(-.235,1.05,2.1);
                    glutSolidSphere(0.03,10,10);
                glPopMatrix();
     
        glPopMatrix();
        //leg
     
        color(0, 0, 0,1.0f,1,1,1,50.0f);
        glPushMatrix();
            glTranslatef(-.4,0.25,3.8);
            glScaled(3,5,1);
            glutSolidCube(.1);
        glPopMatrix();
     
        glPushMatrix();
            glTranslatef(-.4,0.25,2.2);
            glScaled(3,5,1);
            glutSolidCube(.1);
        glPopMatrix();
     
        coinRouleteRed();
     
        coinRouleteBlue();
     
        coinRouleteYellow();
     
        coinRouleteBlack();
    }
    void floorAndWall()
    {
        //floor
        color(0.776, 0.023, 0.286,1.0f,1,1,1,50.0f);
     
     
        glPushMatrix();
        glTranslated(-0.3,0,0);
        glScaled(6,0.25,6);
        wall(0.02);
        glPopMatrix();
     
        //wall
     
        color(1, 1, 1,1.0f,1, 1, 1,50.0f);
     
        //glPushMatrix();
        //glScaled(1,.8,1);
        //glTranslated(-1.05,0.75,0);    
        //glRotated(90,0,0,1);
        //glScaled(3,0.25,3);
        //wall(0.02);
        //glPopMatrix();
     
        //glPushMatrix();
        //glScaled(1,.8,1);
        //glTranslated(3.45,0.75,0);    
        //glRotated(90,0,0,1);
        //glScaled(3,0.25,3);
        //wall(0.02);
        //glPopMatrix();
     
        glPushMatrix();
        glTranslated(-.3,0.52,-1.4);
        glScaled(1,2,1);
        glRotated(-90,1,0,0);
        glScaled(6,5,1);
        wall(0.02);
        glPopMatrix();
     
        /*glPushMatrix();
        glTranslated(-0.3,0,7.2);    
        glRotated(90,0,1,0);
        glScaled(1,.8,1);
        glTranslated(3.45,0.75,0);    
        glRotated(90,0,0,1);
        glScaled(3,0.25,3);
        wall(0.02);
        glPopMatrix();
    */
    }
     void dice()
     {
         //tao
        color(1,1,1,1,1,1,1,20);
        glPushMatrix();
     
            glTranslated(0,.5,5);
            glRotated(45,0,1,0);
            glutSolidCube(1);
     
            // 4 dots
     
            color(0,0,0,1,0,0,0,10);
            glPushMatrix();
                glTranslated(-.2,.51,-.2);
                glScaled(1,0.1,1);
                    glutSolidSphere(0.13,30,30);
            glPopMatrix();
     
            glPushMatrix();
                glTranslated(.2,.51,-.2);
                glScaled(1,0.1,1);
                    glutSolidSphere(0.13,30,30);
            glPopMatrix();
     
            glPushMatrix();
                glTranslated(-.2,.51,.2);
                glScaled(1,0.1,1);
                    glutSolidSphere(0.13,30,30);
            glPopMatrix();
     
            glPushMatrix();
                glTranslated(.2,.51,.2);
                glScaled(1,0.1,1);
                    glutSolidSphere(0.13,30,30);
            glPopMatrix();
     
            // 6 dots
            glPushMatrix();
            glRotated(90,1,0,0);
                glPushMatrix();
                    glTranslated(-.3,.51,-.2);
                    glScaled(1,0.1,1);
                        glutSolidSphere(0.12,30,30);
                glPopMatrix();
     
                glPushMatrix();
                    glTranslated(0,.51,-.2);
                    glScaled(1,0.1,1);
                        glutSolidSphere(0.12,30,30);
                glPopMatrix();
     
                glPushMatrix();
                    glTranslated(-.3,.51,.2);
                    glScaled(1,0.1,1);
                        glutSolidSphere(0.12,30,30);
                glPopMatrix();
     
                glPushMatrix();
                    glTranslated(0,.51,.2);
                    glScaled(1,0.1,1);
                        glutSolidSphere(0.12,30,30);
                glPopMatrix();
     
                glPushMatrix();
                    glTranslated(.3,.51,-.2);
                    glScaled(1,0.1,1);
                        glutSolidSphere(0.12,30,30);
                glPopMatrix();
     
                glPushMatrix();
                    glTranslated(.3,.51,.2);
                    glScaled(1,0.1,1);
                        glutSolidSphere(0.12,30,30);
                glPopMatrix();
            glPopMatrix();
     
            // 1 dot
     
            glPushMatrix();
                glTranslated(0,-.18,-.2);
                glRotated(90,0,0,1);
                glTranslated(.2,.51,.2);
                glScaled(1,0.1,1);
                    glutSolidSphere(0.15,30,30);
            glPopMatrix();
     
            // 2 dots
            glPushMatrix();
                glTranslated(0,.25,0);
                glRotated(-90,1,0,0);
                glPushMatrix();
                    glTranslated(-.2,.51,-.2);
                    glScaled(1,0.1,1);
                        glutSolidSphere(0.14,30,30);
                glPopMatrix();
     
                glPushMatrix();
                    glTranslated(.2,.51,-.2);
                    glScaled(1,0.1,1);
                        glutSolidSphere(0.14,30,30);
                glPopMatrix();
            glPopMatrix();
     
            //  3  dots
            glPushMatrix();
            glTranslated(0,-.2,0);
            glRotated(90,0,1,0);
            glRotated(90,1,0,0);
                glPushMatrix();
                    glTranslated(-.3,.51,-.2);
                    glScaled(1,0.1,1);
                        glutSolidSphere(0.12,30,30);
                glPopMatrix();
     
                glPushMatrix();
                    glTranslated(0,.51,-.2);
                    glScaled(1,0.1,1);
                        glutSolidSphere(0.12,30,30);
                glPopMatrix();
     
     
                glPushMatrix();
                    glTranslated(.3,.51,-.2);
                    glScaled(1,0.1,1);
                        glutSolidSphere(0.12,30,30);
                glPopMatrix();
     
            glPopMatrix();
     
            // 5 dots
            glPushMatrix();
            glRotated(180,0,0,1);
                glPushMatrix();
                    glTranslated(-.21,.51,-.21);
                    glScaled(1,0.1,1);
                        glutSolidSphere(0.12,30,30);
                glPopMatrix();
     
                glPushMatrix();
                    glTranslated(.21,.51,-.21);
                    glScaled(1,0.1,1);
                        glutSolidSphere(0.12,30,30);
                glPopMatrix();
     
                //center
     
                glPushMatrix();
                    glTranslated(0,.51,0);
                    glScaled(1,0.1,1);
                        glutSolidSphere(0.12,30,30);
                glPopMatrix();
     
                glPushMatrix();
                    glTranslated(-.21,.51,.21);
                    glScaled(1,0.1,1);
                        glutSolidSphere(0.12,30,30);
                glPopMatrix();
     
                glPushMatrix();
                    glTranslated(.21,.51,.21);
                    glScaled(1,0.1,1);
                        glutSolidSphere(0.12,30,30);
                glPopMatrix();
            glPopMatrix();
        glPopMatrix();
     
     }
     void mySpecialkey (int key,int x,int y)
     {
         switch (key)
         {
         case GLUT_KEY_LEFT:
             xx --;
             glutPostRedisplay();
             break;
         case GLUT_KEY_RIGHT:
             xx ++;
             glutPostRedisplay();
             break;
         case GLUT_KEY_UP:
             yy++;
             glutPostRedisplay();
             break;
         case GLUT_KEY_DOWN:
             yy--;
             glutPostRedisplay();
             break;
         case GLUT_KEY_HOME:
             zz--;
             glutPostRedisplay();
             break;
         case GLUT_KEY_INSERT:
             zz++;
             glutPostRedisplay();
             break;
         default:
             break;
         }
     }
     
    void displaySolid(void)
    {
     
     
        color(1,1,1,1.0f,1,1,1,50.0f);// gray
     
        // set the light source properties
        GLfloat lightIntensity[] = {0.996, 0.960, 0.729,1.0f};
        GLfloat light_position[] = {3, 3, 3,0.0f};
     
        glLightfv(GL_LIGHT0,GL_POSITION, light_position);
        glLightfv(GL_LIGHT0,GL_DIFFUSE, lightIntensity); // set the camera
     
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
     
        double winHt =5.0;
        glOrtho(-winHt*64/48.0,winHt*64/48.0,-winHt,winHt,0.1,100);
     
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
        //gluLookAt(0,.8,2,1,0.5,2,0,1,0); // side -x
        //gluLookAt(1,10,2,1,0.5,2,1,0,0); //bird eye view
        //gluLookAt(3,1,4,3,1,2,0,1,0);   //in front low
        gluLookAt(7,.5,2,1,0.5,2,0,1,0);        //side x
     
        //gluLookAt(xx,yy,zz,3,0,3,0,1,0);
        glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
     
        floorAndWall();
     
        //roulette
     
        glPushMatrix();
            glTranslated(6,0,-.5);
            glScaled(1.3,1.3,1.3);
            roulette();    
        glPopMatrix();
     
        glPushMatrix();
            glTranslated(4,0,-1);
            dart();
     
        glPopMatrix();
     
        dice();
     
        //slot machine x
        glPushMatrix();
            glTranslated(0,0,-1.2);
            slot(1,0,0,0,1,0);
        glPopMatrix();
     
        glPushMatrix();
            glTranslated(1.5,0,0);
     
            slot(1,0,0,0,1,0);
        glPopMatrix();
     
        glPushMatrix();
            glTranslated(1.8,0,0);
     
            slot(1,0,0,0,1,0);
        glPopMatrix();
     
     
        glutSwapBuffers();
    }
    void main (int argc,char** argv)
    {
        glutInit(&argc,argv);
        glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB|GLUT_DEPTH);
        glutInitWindowSize(1000,1000);
        glutInitWindowPosition(100,100);
        glutCreateWindow("3D project");
        glutDisplayFunc(displaySolid);
        glutSpecialFunc(mySpecialkey);
     
        glEnable(GL_LIGHTING);
        glEnable(GL_LIGHT0);
        glShadeModel(GL_SMOOTH);
        glEnable(GL_DEPTH_TEST);
        glEnable(GL_NORMALIZE);
     
        glClearColor(0.1f,0.1f,0.1f,0.0f);
        glViewport(0,0,1000,1000);
        glutMainLoop();
     
    }

    this is code
    Last edited by Dark Photon; 09-15-2013 at 10:48 AM.

  3. #3
    Junior Member Newbie
    Join Date
    Sep 2013
    Posts
    3
    when chang view point by press arrow keys you will see the problem

    my objects are moved and decomposed.

    tell me what should I do?

  4. #4
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    3,183
    Please put code in [code]...[/code] or [highlight=cpp]...[/highlight] blocks. Added that for you.

    Also, that's a ton of code. How about you whittle it down to the bare essence of the problem. This is not a debugging service. If you have a specific question though, we might be able to help you out.

  5. #5
    Member Regular Contributor
    Join Date
    Jun 2013
    Posts
    490
    Quote Originally Posted by Dark Photon View Post
    Also, that's a ton of code. How about you whittle it down to the bare essence of the problem.
    If you say that, people tend to leave out the bits which actually matter (which aren't necessarily the bits that they think matter). At least this was a complete single-file program with no dependencies other than OpenGL and GLUT.

    Quote Originally Posted by Dark Photon View Post
    This is not a debugging service.
    While that's true, if I'm going to end up "debugging" the program anyhow, I'd rather just have the code than do the usual "twenty questions", with the information that actually matters not showing up until you're on page 5.

  6. #6
    Member Regular Contributor
    Join Date
    Jun 2013
    Posts
    490
    Quote Originally Posted by cherry View Post
    this is code
    If you add glGetError() calls to the code, you'll find two things:

    1. GL_INVALID_VALUE from the last glMaterialfv() call in color().
    2. GL_STACK_OVERFLOW from glPushMatrix().


    The first one is mostly harmless, and is caused by shininess values in excess of 128. According to the manual page:

    GL_INVALID_VALUE is generated if a specular exponent outside the range [0,128] is specified.
    The second one is what's causing the objects to move. Your glPushMatrix() and glPopMatrix() calls aren't matched (the slot() function has one more push than pop). There are 351 calls in total, 176 for glPushMatrix() and 175 for glPopMatrix(). Which means that you'll end up with at least an extra matrix on the stack after each frame; eventually the stack will overflow and a glPushMatrix() call will be ignored (and subsequent glPopMatrix() calls will pop the wrong matrix).

    But there are quite a few places where the indentation doesn't match the push/pop calls. Given how extensively you use these calls, you might want to use blocks so that the text editor will indent automatically, e.g.:
    Code :
        glPushMatrix();
        {
    	glTranslated(0.3,0.45,0.2);
    	glScaled(1,0.1,1);
    	glutSolidSphere(0.21,30,30);
        }
        glPopMatrix();
    or:
    Code :
        glPushMatrix(); {
    	glTranslated(0.3,0.45,0.2);
    	glScaled(1,0.1,1);
    	glutSolidSphere(0.21,30,30);
        } glPopMatrix();

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •