示例#1
0
// Routine which actually does the drawing
void cbRenderScene( void )
{
    char buf[80]; // For our strings.

    // Enables, disables or otherwise adjusts as
    // appropriate for our current settings.

    if (Texture_On)
    {
        glEnable(GL_TEXTURE_RECTANGLE_ARB);
//      glEnable(GL_TEXTURE_RECTANGLE_NV);
    }
    else
    {
        glDisable(GL_TEXTURE_RECTANGLE_ARB);
//      glDisable(GL_TEXTURE_RECTANGLE_NV);
    }
    if (Light_On)
        glEnable(GL_LIGHTING);
    else
        glDisable(GL_LIGHTING);

    if (Alpha_Add)
        glBlendFunc(GL_SRC_ALPHA,GL_ONE);
    else
        glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);

    // If we're blending, we don't want z-buffering.
    if (Blend_On)
    {
        glDisable(GL_DEPTH_TEST);
        glEnable(GL_BLEND);
    }
    else
        glEnable(GL_DEPTH_TEST);

    if (Filtering_On) {
        glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,
                        GL_LINEAR_MIPMAP_LINEAR);
        glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
    } else {
        glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,
                        GL_NEAREST_MIPMAP_NEAREST);
        glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
    }


    // Need to manipulate the ModelView matrix to move our model around.
    glMatrixMode(GL_MODELVIEW);

    // Reset to 0,0,0; no rotation, no scaling.
    glLoadIdentity();

    // Clear the color and depth buffers.
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    if (state) //is false for the selection portion, then turns to true for the remainder of the program
    {
        // Move the object back from the screen.
        glTranslatef(X_Cam,Y_Cam,Z_Off);

        // Rotate the calculated amount.
        glRotatef(X_Rot,1.0f,0.0f,0.0f);
        glRotatef(Y_Rot,0.0f,1.0f,0.0f);
        glRotatef(Z_Rot,0.0f,0.0f,1.0f);

        int i;

        for(i=0; i < NUM_PIC; i++)
        {
            glPushMatrix();
            glBindTexture(GL_TEXTURE_RECTANGLE_ARB, texture[i]);
            switch(Render_mode)
            {
            case 0:
                glTranslatef(offset_on*(offset*i*offset_delta)+offset_off*(offset*i),0.0f,0.0f);
                strcpy(Render_string, "Additive");
                break;
            case 1:
                glTranslatef(offset*offset_delta*slide(i),0.0f,0.0f);
                strcpy(Render_string, "Slide");
                break;
            case 2:
                glTranslatef(0.0f,-offset*offset_delta*2*i,0.0f);
                strcpy(Render_string, "3D");
                break;
            case 3:
                glTranslatef(offset*offset_delta*i,-offset*offset_delta*2*i,0.0f);
                strcpy(Render_string, "3D & Additive");
                break;
            case 4:
                glTranslatef(offset*offset_delta*slide(i),-offset*offset_delta*2*i,0.0f);
                strcpy(Render_string, "3D & Slide");
                break;
            default:
                break;
            }
            glBegin(GL_QUADS);
            glColor4f(0.8f, 0.8f, 0.8f, (1.0f/(i+1)) );

            glTexCoord2f(0.0f, 0.0f);
            glVertex3f(0.0f-wid[i]/40.0f, i/10.0f,0.0f-hei[i]/40.0f);

            glTexCoord2f(wid[i], 0.0f);
            glVertex3f(wid[i]/40.0f, i/10.0f,0.0f-hei[i]/40.0f);

            glTexCoord2f(wid[i], hei[i]);
            glVertex3f(wid[i]/40.0f, i/10.0f,hei[i]/40.0f);

            glTexCoord2f(0.0f, hei[i]);
            glVertex3f(0.0f-wid[i]/40.0f, i/10.0f,hei[i]/40.0f);

            glEnd();
            glPopMatrix();
        }

    }
    // Lit or textured text looks awful.
    glDisable(GL_TEXTURE_RECTANGLE_ARB);
    glDisable(GL_LIGHTING);

    // We don't want depth-testing either.
    glDisable(GL_DEPTH_TEST);

    // Move back to the origin (for the text, below).
    glLoadIdentity();

    // We need to change the projection matrix for the text rendering.
    glMatrixMode(GL_PROJECTION);

    // But we like our current view too; so we save it here.
    glPushMatrix();

    // Now we set up a new projection for the text.
    glLoadIdentity();
    glOrtho(0,Window_Width,0,Window_Height,-1.0,1.0);

    if (Text_on)
    {
        // But, for fun, let's make the text partially transparent too.
        glColor4f(0.6,1.0,0.6,.85);

        // Render our various display mode settings.
//   sprintf(buf,"Mode: %s", TexModesStr[Curr_TexMode]);

        sprintf(buf,"Blend: %s", Blend_On ? "Yes" : "No" );
        glRasterPos2i(2,2);
        ourPrintString(GLUT_BITMAP_HELVETICA_12,buf);

        sprintf(buf,"Light: %s", Light_On ? "Yes" : "No");
        glRasterPos2i(2,14);
        ourPrintString(GLUT_BITMAP_HELVETICA_12,buf);

        sprintf(buf,"Mode: %d, %s", Render_mode, Render_string);
        glRasterPos2i(2,26);
        ourPrintString(GLUT_BITMAP_HELVETICA_12,buf);

        sprintf(buf,"X: %s", offset_on ? "Fast" : "Slow");
        glRasterPos2i(2,38);
        ourPrintString(GLUT_BITMAP_HELVETICA_12,buf);

        sprintf(buf,"O: Turn off text display");
        glRasterPos2i(2,50);
        ourPrintString(GLUT_BITMAP_HELVETICA_12,buf);

        sprintf(buf,"P: Print screen");
        glRasterPos2i(2,62);
        ourPrintString(GLUT_BITMAP_HELVETICA_12,buf);

        sprintf(buf,"I/U: Macro Print screen");
        glRasterPos2i(2,74);
        ourPrintString(GLUT_BITMAP_HELVETICA_12,buf);

        sprintf(buf,"Y/T: Macro Rotate/ Print screen");
        glRasterPos2i(2,86);
        ourPrintString(GLUT_BITMAP_HELVETICA_12,buf);

        sprintf(buf,"R: Reset View");
        glRasterPos2i(2,98);
        ourPrintString(GLUT_BITMAP_HELVETICA_12,buf);
        // Now we want to render the calulated FPS at the top.

        // To ease, simply translate up.  Note we're working in screen
        // pixels in this projection.

        glTranslatef(6.0f,Window_Height - 14,0.0f);

        // Make sure we can read the FPS section by first placing a
        // dark, mostly opaque backdrop rectangle.
        glColor4f(0.2,0.2,0.2,0.75);

        glBegin(GL_QUADS);
        glVertex3f(  0.0f, -16.0f, 0.0f);
        glVertex3f(  0.0f, -4.0f, 0.0f);
        glVertex3f(140.0f, -4.0f, 0.0f);
        glVertex3f(140.0f, -16.0f, 0.0f);
        glEnd();

        glColor4f(0.9,0.2,0.2,.75);
        sprintf(buf,"FPS: %f F: %2d", FrameRate, FrameCount);
        glRasterPos2i(6,-16);
        ourPrintString(GLUT_BITMAP_HELVETICA_12,buf);
        glLoadIdentity();
        glOrtho(0,Window_Width,0,Window_Height,-1.0,1.0);
    }

    glTranslatef(6.0f,Window_Height - 14,0.0f);

    glBegin(GL_QUADS);
    glColor4f(.75,.75,.75,1.0);
    glVertex3f(-6, -4, 0);
    glVertex3f(-6, 14, 0);
    glVertex3f(Window_Width, 14, 0);
    glVertex3f(Window_Width, -4, 0);
    glEnd();

    glBegin(GL_LINES);
    glColor4f(0,0,0,1.0);
    glVertex3f(Window_Width-7, -4, 0);
    glVertex3f(-6, -4, 0);
    glEnd();

    switch(menu_selected)
    {
    case 0:
        break;
    case 1: //File menu
        glBegin(GL_QUADS); //draw drop-down menu
        glColor4f(.04,.14,.39,.8);
        glVertex3f(  -2.0f, -4.0f, 0);
        glVertex3f(  -2.0f, 13.0f, 0);
        glVertex3f(  25.0f, 13.0f, 0);
        glVertex3f(  25.0f, -4.0f, 0);

        glColor4f(.75,.75,.75,1.0);
        glVertex3f(-2, -38, 0);
        glVertex3f(-2, -4, 0);
        glVertex3f(98, -4, 0);
        glVertex3f(98, -38, 0);
        glEnd();

        glColor4f(0,0,0,1);
        if(file[0])
        {
            glBegin(GL_QUADS); //draw blue selection box
            glColor4f(.04,.14,.39,.8);
            glVertex3f(  -1.0f, -5.0f, 0);
            glVertex3f(  -1.0f, -20.0f, 0);
            glVertex3f(  97.0f, -20.0f, 0);
            glVertex3f(  97.0f, -5.0f, 0);
            glEnd();
            glColor4f(1,1,1,1);
        }
        glRasterPos2i(2, -16);
        ourPrintString(GLUT_BITMAP_HELVETICA_12,"Open      Ctrl+O");
        glBegin(GL_LINES); //draw light grey divider
        glColor4f(.6,.6,.6,1);
        glVertex3f(-1,-22,0);
        glVertex3f(99,-22,0);
        glEnd();
        //begin next menu entry
        glColor4f(0,0,0,1);
        if(file[1])
        {
            glBegin(GL_QUADS);
            glColor4f(.04,.14,.39,.8);
            glVertex3f(  -1.0f, -23.0f, 0);
            glVertex3f(  -1.0f, -36.0f, 0);
            glVertex3f(  97.0f, -36.0f, 0);
            glVertex3f(  97.0f, -23.0f, 0);
            glEnd();
            glColor4f(1,1,1,1);
        }
        glRasterPos2i(2, -34);
        ourPrintString(GLUT_BITMAP_HELVETICA_12,"Exit               Q");
        break;
    case 2: //Edit
        glBegin(GL_QUADS);
        glColor4f(.04,.14,.39,.8);
        glVertex3f(  28.0f, -4.0f, 0);
        glVertex3f(  28.0f, 13.0f, 0);
        glVertex3f(  54.0f, 13.0f, 0);
        glVertex3f(  54.0f, -4.0f, 0);

        glColor4f(.75,.75,.75,1.0);
        glVertex3f(28, -8, 0);
        glVertex3f(28, -4, 0);
        glVertex3f(77, -4, 0);
        glVertex3f(77, -8, 0);
        glEnd();
        break;
    case 3: //View
        glBegin(GL_QUADS);
        glColor4f(.04,.14,.39,.8);
        glVertex3f(  58.0f, -4.0f, 0);
        glVertex3f(  58.0f, 13.0f, 0);
        glVertex3f(  92.0f, 13.0f, 0);
        glVertex3f(  92.0f, -4.0f, 0);

        glColor4f(.75,.75,.75,1.0);
        glVertex3f(58, -122, 0);
        glVertex3f(58, -4, 0);
        glVertex3f(164, -4, 0);
        glVertex3f(164, -122, 0);
        glEnd();

        glColor4f(0,0,0,1);
        if(view[0])
        {
            glBegin(GL_QUADS);
            glColor4f(.04,.14,.39,.8);
            glVertex3f(  59.0f, -5.0f, 0);
            glVertex3f(  59.0f, -19.0f, 0);
            glVertex3f(  163.0f, -19.0f, 0);
            glVertex3f(  163.0f, -5.0f, 0);
            glEnd();
            glColor4f(1,1,1,1);
        }
        glRasterPos2i(62, -16);
        ourPrintString(GLUT_BITMAP_HELVETICA_12,"Zoom in      PgUp");
        glColor4f(0,0,0,1);
        if(view[1])
        {
            glBegin(GL_QUADS);
            glColor4f(.04,.14,.39,.8);
            glVertex3f(  59.0f, -34.0f, 0);
            glVertex3f(  59.0f, -19.0f, 0);
            glVertex3f(  163.0f, -19.0f, 0);
            glVertex3f(  163.0f, -34.0f, 0);
            glEnd();
            glColor4f(1,1,1,1);
        }
        glRasterPos2i(62, -30);
        ourPrintString(GLUT_BITMAP_HELVETICA_12,"Zoom out    PgDn");
        glColor4f(0,0,0,1);
        if(view[2])
        {
            glBegin(GL_QUADS);
            glColor4f(.04,.14,.39,.8);
            glVertex3f(  59.0f, -34.0f, 0);
            glVertex3f(  59.0f, -49.0f, 0);
            glVertex3f(  163.0f, -49.0f, 0);
            glVertex3f(  163.0f, -34.0f, 0);
            glEnd();
            glColor4f(1,1,1,1);
        }
        glRasterPos2i(62, -44);
        ourPrintString(GLUT_BITMAP_HELVETICA_12,"Reset view       R");
        glBegin(GL_LINES);
        glColor4f(.6,.6,.6,1);
        glVertex3f(59,-50,0);
        glVertex3f(163,-50,0);
        glEnd();
        glColor4f(0,0,0,1);
        glRasterPos2i(62, -62);
        ourPrintString(GLUT_BITMAP_HELVETICA_12,"Set mode:");
        glColor4f(0,0,0,1);
        if(view[3])
        {
            glBegin(GL_QUADS);
            glColor4f(.04,.14,.39,.8);
            glVertex3f(  59.0f, -65.0f, 0);
            glVertex3f(  59.0f, -79.0f, 0);
            glVertex3f(  163.0f, -79.0f, 0);
            glVertex3f(  163.0f, -65.0f, 0);
            glEnd();
            glColor4f(1,1,1,1);
        }
        glRasterPos2i(110, -76);
        ourPrintString(GLUT_BITMAP_HELVETICA_12,"  Default");
        glColor4f(0,0,0,1);
        if(view[4])
        {
            glBegin(GL_QUADS);
            glColor4f(.04,.14,.39,.8);
            glVertex3f(  59.0f, -92.0f, 0);
            glVertex3f(  59.0f, -79.0f, 0);
            glVertex3f(  163.0f, -79.0f, 0);
            glVertex3f(  163.0f, -92.0f, 0);
            glEnd();
            glColor4f(1,1,1,1);
        }
        glRasterPos2i(110, -89);
        ourPrintString(GLUT_BITMAP_HELVETICA_12,"     Slide");
        glColor4f(0,0,0,1);
        if(view[5])
        {
            glBegin(GL_QUADS);
            glColor4f(.04,.14,.39,.8);
            glVertex3f(  59.0f, -92.0f, 0);
            glVertex3f(  59.0f, -107.0f, 0);
            glVertex3f(  163.0f, -107.0f, 0);
            glVertex3f(  163.0f, -92.0f, 0);
            glEnd();
            glColor4f(1,1,1,1);
        }
        glRasterPos2i(110, -104);
        ourPrintString(GLUT_BITMAP_HELVETICA_12,"        3D");
        glColor4f(0,0,0,1);
        if(view[6])
        {
            glBegin(GL_QUADS);
            glColor4f(.04,.14,.39,.8);
            glVertex3f(  59.0f, -120.0f, 0);
            glVertex3f(  59.0f, -107.0f, 0);
            glVertex3f(  163.0f, -107.0f, 0);
            glVertex3f(  163.0f, -120.0f, 0);
            glEnd();
            glColor4f(1,1,1,1);
        }
        glRasterPos2i(110, -117);
        ourPrintString(GLUT_BITMAP_HELVETICA_12,"3D Slide");

        break;
    case 4: //Help
        glBegin(GL_QUADS);
        glColor4f(.04,.14,.39,.8);
        glVertex3f(  94.0f, -4.0f, 0);
        glVertex3f(  94.0f, 13.0f, 0);
        glVertex3f(  128.0f, 13.0f, 0);
        glVertex3f(  128.0f, -4.0f, 0);

        glColor4f(.75,.75,.75,1.0);
        glVertex3f(94, -22, 0);
        glVertex3f(94, -4, 0);
        glVertex3f(174, -4, 0);
        glVertex3f(174, -22, 0);
        glEnd();

        glColor4f(0,0,0,1);
        if(help[0])
        {
            glBegin(GL_QUADS);
            glColor4f(.04,.14,.39,.8);
            glVertex3f(  95.0f, -5.0f, 0);
            glVertex3f(  95.0f, -20.0f, 0);
            glVertex3f(  173.0f, -20.0f, 0);
            glVertex3f(  173.0f, -5.0f, 0);
            glEnd();
            glColor4f(1,1,1,1);
        }
        glRasterPos2i(98, -16);
        ourPrintString(GLUT_BITMAP_HELVETICA_12,"About");
        break;
    default:
        menu_selected = 0;
        break;
    }

    glColor4f(0,0,0,1);
    glRasterPos2i(2, 1);
    ourPrintString(GLUT_BITMAP_HELVETICA_12,"File");
    if(menu_selected == 1) //write over it in white
    {
        glColor4f(1,1,1,1);
        glRasterPos2i(2, 1);
        ourPrintString(GLUT_BITMAP_HELVETICA_12,"File");
    }
    glRasterPos2i(2, 1);
    ourPrintString(GLUT_BITMAP_HELVETICA_12,"_");
    glColor4f(0,0,0,1);
    glRasterPos2i(31, 1);
    ourPrintString(GLUT_BITMAP_HELVETICA_12, "Edit");
    if(menu_selected == 2)
    {
        glColor4f(1,1,1,1);
        glRasterPos2i(31, 1);
        ourPrintString(GLUT_BITMAP_HELVETICA_12,"Edit");
    }
    glRasterPos2i(31, 1);
    ourPrintString(GLUT_BITMAP_HELVETICA_12,"_");
    glColor4f(0,0,0,1);
    glRasterPos2i(61, 1);
    ourPrintString(GLUT_BITMAP_HELVETICA_12, "View");
    if(menu_selected == 3)
    {
        glColor4f(1,1,1,1);
        glRasterPos2i(61, 1);
        ourPrintString(GLUT_BITMAP_HELVETICA_12,"View");
    }
    glRasterPos2i(61, 1);
    ourPrintString(GLUT_BITMAP_HELVETICA_12,"_");
    glColor4f(0,0,0,1);
    glRasterPos2i(97, 1);
    ourPrintString(GLUT_BITMAP_HELVETICA_12, "Help");
    if(menu_selected == 4)
    {
        glColor4f(1,1,1,1);
        glRasterPos2i(97, 1);
        ourPrintString(GLUT_BITMAP_HELVETICA_12,"Help");
    }
    glRasterPos2i(97, 1);
    ourPrintString(GLUT_BITMAP_HELVETICA_12,"_");



    // Done with this special projection matrix.  Throw it away.
    glPopMatrix();


    // All done drawing.  Let's show it.
    glutSwapBuffers();


    // And collect our statistics.
    ourDoFPS();
}
示例#2
0
/* Draw the physical icon object
 *
 * PARAMS
 *
 *
 */
void IPrefsIcon::execGL(void) {

    //Set the panecolor of the object to the active color
    paneColor.execGL();

    //If we are over the object make the sliders slide...
    if (Over)
    {
    	if (slidertopdir == 1)
	{
		slidertop += 0.05;
		if (slidertop >= 4.0)
		{
		slidertopdir = -1;
		}
	}
	if (slidertopdir == -1)
	{
		slidertop -= 0.05;
		if (slidertop <= 0.0)
		{
		slidertopdir = 1;
		}
	}
	if (sliderbotdir == 1)
	{
		sliderbottom += 0.05;
		if (sliderbottom >= 4.0)
		{
		sliderbotdir = -1;
		}
	}
	if (sliderbotdir == -1)
	{
		sliderbottom -= 0.05;
		if (sliderbottom <= 0.0)
		{
		sliderbotdir = 1;
		}
	}


    }

    //If we are captured then make the background white and transparent
    if (Capture)
    {
    glColor4f(1.0, 1.0, 1.0, 0.4);
    }
    //Creating the back pane
    glBegin(GL_QUADS);
    glVertex3f(location.getX(), location.getY(), ZDIR);
    glVertex3f(location.getX(), location.getY() - size.getY(), ZDIR);
    glVertex3f(location.getX() + size.getX(), location.getY() - size.getY(), ZDIR);
    glVertex3f(location.getX() + size.getX(), location.getY(), ZDIR);
    glEnd();

    //Draw top mini slider device
    glColor4f(0.2, 0.1, 1.0, 0.8);
    glBegin(GL_QUADS);
    glVertex3f(location.getX(), location.getY() - 1.0, ZDIR + 0.1);
    glVertex3f(location.getX(), location.getY() - 2.5, ZDIR + 0.1);
    glVertex3f(location.getX() + 5.0, location.getY() - 2.5, ZDIR + 0.1);
    glVertex3f(location.getX() + 5.0, location.getY() - 1.0, ZDIR + 0.1);
    glEnd();

    //Draw top mini slider
    glBegin(GL_QUADS);
    glVertex3f(location.getX() + slidertop, location.getY() - 0.5, ZDIR + 0.2);
    glVertex3f(location.getX() + slidertop, location.getY() - 3.0, ZDIR + 0.2);
    glVertex3f(location.getX() + slidertop + 1.0, location.getY() - 3.0, ZDIR + 0.2);
    glVertex3f(location.getX() + slidertop + 1.0, location.getY() - 0.5, ZDIR + 0.2);
    glEnd();

    glBegin(GL_TRIANGLES);
    glVertex3f(location.getX() + slidertop, location.getY() - 3.0, ZDIR + 0.2);
    glVertex3f(location.getX() + slidertop + 0.5, location.getY() - 3.5, ZDIR + 0.2);
    glVertex3f(location.getX() + slidertop + 1.0, location.getY() - 3.0, ZDIR + 0.2);
    glEnd();

    //Draw bottom mini slider device
    glColor4f(1.0, 0.1, 0.2, 0.8);
    glBegin(GL_QUADS);
    glVertex3f(location.getX(), location.getY() - 6.5, ZDIR + 0.1);
    glVertex3f(location.getX(), location.getY() - 8.0, ZDIR + 0.1);
    glVertex3f(location.getX() + 5.0, location.getY() - 8.0, ZDIR + 0.1);
    glVertex3f(location.getX() + 5.0, location.getY() - 6.5, ZDIR + 0.1);
    glEnd();

    //Draw bottom mini slider
    glBegin(GL_QUADS);
    glVertex3f(location.getX() + sliderbottom, location.getY() - 6.0, ZDIR + 0.2);
    glVertex3f(location.getX() + sliderbottom, location.getY() - 8.5, ZDIR + 0.2);
    glVertex3f(location.getX() + sliderbottom + 1.0, location.getY() - 8.5, ZDIR + 0.2);
    glVertex3f(location.getX() + sliderbottom + 1.0, location.getY() - 6.0, ZDIR + 0.2);
    glEnd();

    glBegin(GL_TRIANGLES);
    glVertex3f(location.getX() + sliderbottom, location.getY() - 8.5, ZDIR + 0.2);
    glVertex3f(location.getX() + sliderbottom + 0.5, location.getY() - 9.0, ZDIR + 0.2);
    glVertex3f(location.getX() + sliderbottom + 1.0, location.getY() - 8.5, ZDIR + 0.2);
    glEnd();

    //Draw screw driver thingy
    glColor4f(0.3, 1.0, 0.2, 0.6);
    glBegin(GL_QUADS);
    glVertex3f(location.getX() + 6.0, location.getY() - 0.5, ZDIR + 0.05);
    glVertex3f(location.getX() + 6.0, location.getY() - 5.0, ZDIR + 0.05);
    glVertex3f(location.getX() + 8.0, location.getY() - 5.0, ZDIR + 0.05);
    glVertex3f(location.getX() + 8.0, location.getY() - 0.5, ZDIR + 0.05);
    glEnd();

    glColor4f(0.0, 0.0, 0.0, 1.0);
    glBegin(GL_LINES);
    glVertex3f(location.getX() + 6.5, location.getY() - 0.5, ZDIR + 0.05);
    glVertex3f(location.getX() + 6.5, location.getY() - 5.0, ZDIR + 0.05);
    glEnd();

    glColor4f(0.0, 0.0, 0.0, 1.0);
    glBegin(GL_LINES);
    glVertex3f(location.getX() + 7.5, location.getY() - 0.5, ZDIR + 0.05);
    glVertex3f(location.getX() + 7.5, location.getY() - 5.0, ZDIR + 0.05);
    glEnd();

    glColor4f(0.486275, 0.533333, 0.533333, 0.8);
    glBegin(GL_QUADS);
    glVertex3f(location.getX() + 6.5, location.getY() - 5.0, ZDIR + 0.05);
    glVertex3f(location.getX() + 6.5, location.getY() - size.getY() + 1.5, ZDIR + 0.05);
    glVertex3f(location.getX() + 7.5, location.getY() - size.getY() + 1.5, ZDIR + 0.05);
    glVertex3f(location.getX() + 7.5, location.getY() - 5.0, ZDIR + 0.05);
    glEnd();

    glBegin(GL_TRIANGLES);
    glVertex3f(location.getX() + 6.5, location.getY() - size.getY() + 1.5, ZDIR + 0.2);
    glVertex3f(location.getX() + 7.0, location.getY() - size.getY() + 0.5, ZDIR + 0.2);
    glVertex3f(location.getX() + 7.5, location.getY() - size.getY() + 1.5, ZDIR + 0.2);
    glEnd();

    //Push matrix to draw text
    glPushMatrix();
    //Move the main coordinates to the top left corner or the box
    glTranslatef(location.getX(), location.getY(), ZDIR);

    //Create white text color
    glColor4f(1.0, 1.0, 1.0, 0.8);

    //Set text printing location and print the number
    glRasterPos3f(8.0, -9.0, 0.2);
    ourPrintString(GLUT_BITMAP_8_BY_13, "p");

    //Done drawing text, go back into normal coordinate system
    glPopMatrix();
}
示例#3
0
文件: IComboBox.cpp 项目: alaeri/3dfm
/* Draw the actual IComboBox-box object on the screen
 *
 * PARAMS
 *   none
 *
 */
int IComboBox::execGL(void) {

    //Creates the clickable GRects
    CreateClickable();

    //Set the paneColor to the active color
    paneColor.execGL();

    //Draw the main pane
    glBegin(GL_QUADS);
    glVertex3f(location.getX(), location.getY(), location.getZ());
    glVertex3f(location.getX() + size.getX(),
	       location.getY(), ZDIR);
    glVertex3f(location.getX() + size.getX(),
	       location.getY() - size.getY(),
	       ZDIR);
    glVertex3f(location.getX(), location.getY() - size.getY(),
	       ZDIR);

    glEnd();


    glColor4f(0.0, 0.0, 0.0, 1.0);
    //Draw text pane
    glBegin(GL_QUADS);
    glVertex3f(location.getX() + 0.5, location.getY() - 0.5, location.getZ() + 0.1);
    glVertex3f(location.getX() + size.getX() - 0.5,
	       location.getY() - 0.5, location.getZ() + 0.1);
    glVertex3f(location.getX() + size.getX() - 0.5,
	       location.getY() - size.getY() + 0.5,
	       location.getZ() + 0.1);
    glVertex3f(location.getX() + 0.5, location.getY() - size.getY() + 0.5,
	       location.getZ() + 0.1);

    glEnd();

    //Perform the color contrasting algorithm so the button can be seen
    //on top of the main pane

    GColor previous = paneColor;
    (previous + (GLfloat) -0.4).execGL();

    glBegin(GL_QUADS);
    //Creating drop down list button
    glVertex3f(location.getX() + size.getX() - 3.5, location.getY() - 0.5,
	       location.getZ() + 0.1);
    glVertex3f(location.getX() + size.getX() - 3.5, location.getY() - size.getY() + 0.5,
	       location.getZ() + 0.1);
    glVertex3f(location.getX() + size.getX() - 0.5, location.getY() - size.getY() + 0.5,
	       location.getZ() + 0.1);
    glVertex3f(location.getX() + size.getX() - 0.5, location.getY() - 0.5,
	       location.getZ() + 0.1);
    glEnd();

    glColor4f(1.0, 1.0, 1.0, 0.6);
    //Creating down triangle even though the chevron looks better
    glBegin(GL_TRIANGLES);
    glVertex3f(location.getX() + size.getX() - 3.0, location.getY() - 1.0,
	       location.getZ() + 0.2);
    glVertex3f(location.getX() + size.getX() - 2.0, location.getY() - size.getY() + .75,
	       location.getZ() + 0.2);
    glVertex3f(location.getX() + size.getX() - 1.0 , location.getY() - 1.0,
	       location.getZ() + 0.2);
    glEnd();


    //Create the semi-transparent white text color
    glColor4f(1.0, 1.0, 1.0, 0.7);

    //Need to pust matrix to draw text
    glPushMatrix();
    //Move the main coordinates to the top left corner or the box
    glTranslatef(location.getX(), location.getY(), 0.1);

    //Initialize settings for the first line

    glRasterPos3f(1.0, -4.0, 0.2);
    ourPrintString(GLUT_BITMAP_8_BY_13, Text);

    //Done drawing text, go back into normal coordinate system
    glPopMatrix();

    if (OpenList)
    {

    paneColor.execGL();

    //Run animation
    if (Animate)
    {
    	Animate = AnimatePane();
	return Animate;
    }

    glBegin(GL_QUADS);
    //Creating ListBox pane
    glVertex3f(ListBoxLocation.getX(), ListBoxLocation.getY(), ListBoxLocation.getZ() + 0.1);
    glVertex3f(ListBoxLocation.getX(), ListBoxLocation.getY() - ListBoxSize.getY(),
	       ListBoxLocation.getZ() + 0.1);
    glVertex3f(ListBoxLocation.getX() + ListBoxSize.getX(), ListBoxLocation.getY() - ListBoxSize.getY(),
	       ListBoxLocation.getZ() + 0.1);
    glVertex3f(ListBoxLocation.getX() + ListBoxSize.getX(), ListBoxLocation.getY(),
	       ListBoxLocation.getZ() + 0.1);
    glEnd();

    //Perform the color contrasting algorithm so the buttons can be see
    //on top of the main pane
    GColor previous = paneColor;
    (paneColor + (GLfloat) -0.4).execGL();


    glBegin(GL_QUADS);
    //Creating scroll down button
    glVertex3f(ListBoxLocation.getX() + ListBoxSize.getX() - 3, ListBoxLocation.getY() - ListBoxSize.getY() + 4,
	       ListBoxLocation.getZ() + 0.1);
    glVertex3f(ListBoxLocation.getX() + ListBoxSize.getX() - 3, ListBoxLocation.getY() - ListBoxSize.getY(),
	       ListBoxLocation.getZ() + 0.1);
    glVertex3f(ListBoxLocation.getX() + ListBoxSize.getX(), ListBoxLocation.getY() - ListBoxSize.getY(),
	       ListBoxLocation.getZ() + 0.1);
    glVertex3f(ListBoxLocation.getX() + ListBoxSize.getX(), ListBoxLocation.getY() - ListBoxSize.getY() + 4,
	       ListBoxLocation.getZ() + 0.1);
    glEnd();

    glBegin(GL_QUADS);
    //Creating scroll up button
    glVertex3f(ListBoxLocation.getX() + ListBoxSize.getX() - 3, ListBoxLocation.getY(),
	       ListBoxLocation.getZ() + 0.1);
    glVertex3f(ListBoxLocation.getX() + ListBoxSize.getX() - 3, ListBoxLocation.getY() - 4,
	       ListBoxLocation.getZ() + 0.1);
    glVertex3f(ListBoxLocation.getX() + ListBoxSize.getX(), ListBoxLocation.getY()  - 4,
	       ListBoxLocation.getZ() + 0.1);
    glVertex3f(ListBoxLocation.getX() + ListBoxSize.getX(), ListBoxLocation.getY(),
	       ListBoxLocation.getZ() + 0.1);
    glEnd();

    glBegin(GL_QUADS);
    //Creating page down button
    glVertex3f(ListBoxLocation.getX() + ListBoxSize.getX() - 3, ListBoxLocation.getY() - ListBoxSize.getY() + 8,
	       ListBoxLocation.getZ() + 0.1);
    glVertex3f(ListBoxLocation.getX() + ListBoxSize.getX() - 3, ListBoxLocation.getY() - ListBoxSize.getY() + 4,
	       ListBoxLocation.getZ() + 0.1);
    glVertex3f(ListBoxLocation.getX() + ListBoxSize.getX(), ListBoxLocation.getY() - ListBoxSize.getY() + 4,
	       ListBoxLocation.getZ() + 0.1);
    glVertex3f(ListBoxLocation.getX() + ListBoxSize.getX(), ListBoxLocation.getY() - ListBoxSize.getY() + 8,
	       ListBoxLocation.getZ() + 0.1);
    glEnd();

    glBegin(GL_QUADS);
    //Creating page up button
    glVertex3f(ListBoxLocation.getX() + ListBoxSize.getX() - 3, ListBoxLocation.getY() - 4,
	       ListBoxLocation.getZ() + 0.1);
    glVertex3f(ListBoxLocation.getX() + ListBoxSize.getX() - 3, ListBoxLocation.getY() - 8,
	       ListBoxLocation.getZ() + 0.1);
    glVertex3f(ListBoxLocation.getX() + ListBoxSize.getX(), ListBoxLocation.getY()  - 8,
	       ListBoxLocation.getZ() + 0.1);
    glVertex3f(ListBoxLocation.getX() + ListBoxSize.getX(), ListBoxLocation.getY() - 4,
	       ListBoxLocation.getZ() + 0.1);
    glEnd();

    glColor4f(1.0, 1.0, 1.0, 0.6);
    //Creating scroll down triangle even though the chevron looks better
    glBegin(GL_TRIANGLES);
    glVertex3f(ListBoxLocation.getX() + ListBoxSize.getX() - 2.75, ListBoxLocation.getY() - ListBoxSize.getY() + 3.5,
	       ListBoxLocation.getZ() + 0.2);
    glVertex3f(ListBoxLocation.getX() + ListBoxSize.getX() - 1.5, ListBoxLocation.getY() - ListBoxSize.getY() + .5,
	       ListBoxLocation.getZ() + 0.2);
    glVertex3f(ListBoxLocation.getX() + ListBoxSize.getX() - 0.25 , ListBoxLocation.getY() - ListBoxSize.getY() + 3.5,
	       ListBoxLocation.getZ() + 0.2);
    glEnd();

    //Creating scroll up triangle
    glBegin(GL_TRIANGLES);
    glVertex3f(ListBoxLocation.getX() + ListBoxSize.getX() - 2.75, ListBoxLocation.getY() - 3.5,
	       ListBoxLocation.getZ() + 0.2);
    glVertex3f(ListBoxLocation.getX() + ListBoxSize.getX() - 1.5, ListBoxLocation.getY() - .5,
	       ListBoxLocation.getZ() + 0.2);
    glVertex3f(ListBoxLocation.getX() + ListBoxSize.getX() - 0.25 , ListBoxLocation.getY() - 3.5,
	       ListBoxLocation.getZ() + 0.2);
    glEnd();

    //Creating page down double chevron
    glBegin(GL_LINE_STRIP);
    glVertex3f(ListBoxLocation.getX() + ListBoxSize.getX() - 2.75, ListBoxLocation.getY() - ListBoxSize.getY() + 5.75,
	       ListBoxLocation.getZ() + 0.2);
    glVertex3f(ListBoxLocation.getX() + ListBoxSize.getX() - 1.5, ListBoxLocation.getY() - ListBoxSize.getY() + 4.25,
	       ListBoxLocation.getZ() + 0.2);
    glVertex3f(ListBoxLocation.getX() + ListBoxSize.getX() - 0.25 , ListBoxLocation.getY() - ListBoxSize.getY() + 5.75,
	       ListBoxLocation.getZ() + 0.2);
    glEnd();

    glBegin(GL_LINE_STRIP);
    glVertex3f(ListBoxLocation.getX() + ListBoxSize.getX() - 2.75, ListBoxLocation.getY() - ListBoxSize.getY() + 7.75,
	       ListBoxLocation.getZ() + 0.2);
    glVertex3f(ListBoxLocation.getX() + ListBoxSize.getX() - 1.5, ListBoxLocation.getY() - ListBoxSize.getY() + 6.25,
	       ListBoxLocation.getZ() + 0.2);
    glVertex3f(ListBoxLocation.getX() + ListBoxSize.getX() - 0.25 , ListBoxLocation.getY() - ListBoxSize.getY() + 7.75,
	       ListBoxLocation.getZ() + 0.2);
    glEnd();

    //Creating page up double chevron
    glBegin(GL_LINE_STRIP);
    glVertex3f(ListBoxLocation.getX() + ListBoxSize.getX() - 2.75, ListBoxLocation.getY() - 5.75,
	       ListBoxLocation.getZ() + 0.2);
    glVertex3f(ListBoxLocation.getX() + ListBoxSize.getX() - 1.5, ListBoxLocation.getY() - 4.25,
	       ListBoxLocation.getZ() + 0.2);
    glVertex3f(ListBoxLocation.getX() + ListBoxSize.getX() - 0.25 , ListBoxLocation.getY() - 5.75,
	       ListBoxLocation.getZ() + 0.2);
    glEnd();

    glBegin(GL_LINE_STRIP);
    glVertex3f(ListBoxLocation.getX() + ListBoxSize.getX() - 2.75, ListBoxLocation.getY() - 7.75,
	       ListBoxLocation.getZ() + 0.2);
    glVertex3f(ListBoxLocation.getX() + ListBoxSize.getX() - 1.5, ListBoxLocation.getY() - 6.25,
	       ListBoxLocation.getZ() + 0.2);
    glVertex3f(ListBoxLocation.getX() + ListBoxSize.getX() - 0.25 , ListBoxLocation.getY() - 7.75,
	       ListBoxLocation.getZ() + 0.2);
    glEnd();

    //Set the color back to the pane color
    paneColor = previous;

    //Create the semi-transparent white text color
    glColor4f(1.0, 1.0, 1.0, 0.5);

    //Need to pust matrix to draw text
    glPushMatrix();
    //Move the main coordinates to the top left corner or the box
    glTranslatef(ListBoxLocation.getX(), ListBoxLocation.getY(), ZDIR);

    //Initialize settings for the first line
    int y = -3;
    int line = line_max;
    IListItem *cur = top;
    int count = 1;

    //Create the text and the check-boxes from the top down
    while ((cur != NULL) && (line > 0)) {

	if ((count == highlight) && (dohighlight))
	{
		glColor4f(1.0, 1.0, 1.0, 1.0);
	}
	else
	{
		glColor4f(1.0, 1.0, 1.0, 0.5);
	}

	glRasterPos3f(0.5, y, 0.1);
	ourPrintString(GLUT_BITMAP_8_BY_13, cur->getName());


	//Creating checked check box

	//Go to next line and next item in the list
	y -= 4;
	cur = cur->getNext();
	--line;
	++count;
    }

    //Done drawing text, go back into normal coordinate system
    glPopMatrix();
    }

    return 0;
}
示例#4
0
void cbRenderScene(
                   void
                   )
{
    char buf[80]; // For our strings.
    
    // Enables, disables or otherwise adjusts as 
    // appropriate for our current settings.
    
    if (Texture_On)
        glEnable(GL_TEXTURE_2D);
    else
        glDisable(GL_TEXTURE_2D);
    
    if (Light_On) 
        glEnable(GL_LIGHTING);
    else 
        glDisable(GL_LIGHTING);
    
    if (Alpha_Add)
        glBlendFunc(GL_SRC_ALPHA,GL_ONE); 
    else
        glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
    
    // If we're blending, we don't want z-buffering.
    if (Blend_On)
        glDisable(GL_DEPTH_TEST); 
    else
        glEnable(GL_DEPTH_TEST); 
    
    if (Filtering_On) {
        glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,
                        GL_LINEAR_MIPMAP_LINEAR);
        glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
    } else {
        glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,
                        GL_NEAREST_MIPMAP_NEAREST);
        glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
    }
   
    
    // Need to manipulate the ModelView matrix to move our model around.
    glMatrixMode(GL_MODELVIEW);
    
    // Reset to 0,0,0; no rotation, no scaling.
    glLoadIdentity(); 
    
    // Move the object back from the screen.
    glTranslatef(0.0f,0.0f,Z_Off);
    
    // Rotate the calculated amount.
    glRotatef(X_Rot,1.0f,0.0f,0.0f);
    glRotatef(Y_Rot,0.0f,1.0f,0.0f);
    
    
    // Clear the color and depth buffers.
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    
    
    // OK, let's start drawing our planer quads.
    glBegin(GL_QUADS); 
    
    
    // Bottom Face.  Red, 75% opaque, magnified texture
    
    glNormal3f( 0.0f, -1.0f, 0.0f); // Needed for lighting
    glColor4f(0.9,0.2,0.2,.75); // Basic polygon color
    
    glTexCoord2f(0.800f, 0.800f); glVertex3f(-1.0f, -1.0f, -1.0f); 
    glTexCoord2f(0.200f, 0.800f); glVertex3f( 1.0f, -1.0f, -1.0f);
    glTexCoord2f(0.200f, 0.200f); glVertex3f( 1.0f, -1.0f,  1.0f);
    glTexCoord2f(0.800f, 0.200f); glVertex3f(-1.0f, -1.0f,  1.0f);
    
    
    // Top face; offset.  White, 50% opaque.
    
    glNormal3f( 0.0f, 1.0f, 0.0f);  glColor4f(0.5,0.5,0.5,.5);
    
    glTexCoord2f(0.005f, 1.995f); glVertex3f(-1.0f,  1.3f, -1.0f);
    glTexCoord2f(0.005f, 0.005f); glVertex3f(-1.0f,  1.3f,  1.0f);
    glTexCoord2f(1.995f, 0.005f); glVertex3f( 1.0f,  1.3f,  1.0f);
    glTexCoord2f(1.995f, 1.995f); glVertex3f( 1.0f,  1.3f, -1.0f);
    
    
    // Far face.  Green, 50% opaque, non-uniform texture cooridinates.
    
    glNormal3f( 0.0f, 0.0f,-1.0f);  glColor4f(0.2,0.9,0.2,.5); 
    
    glTexCoord2f(0.995f, 0.005f); glVertex3f(-1.0f, -1.0f, -1.3f);
    glTexCoord2f(2.995f, 2.995f); glVertex3f(-1.0f,  1.0f, -1.3f);
    glTexCoord2f(0.005f, 0.995f); glVertex3f( 1.0f,  1.0f, -1.3f);
    glTexCoord2f(0.005f, 0.005f); glVertex3f( 1.0f, -1.0f, -1.3f);
    
    
    // Right face.  Blue; 25% opaque
    
    glNormal3f( 1.0f, 0.0f, 0.0f);  glColor4f(0.2,0.2,0.9,.25);
    
    glTexCoord2f(0.995f, 0.005f); glVertex3f( 1.0f, -1.0f, -1.0f); 
    glTexCoord2f(0.995f, 0.995f); glVertex3f( 1.0f,  1.0f, -1.0f);
    glTexCoord2f(0.005f, 0.995f); glVertex3f( 1.0f,  1.0f,  1.0f);
    glTexCoord2f(0.005f, 0.005f); glVertex3f( 1.0f, -1.0f,  1.0f);
    
    
    // Front face; offset.  Multi-colored, 50% opaque.
    
    glNormal3f( 0.0f, 0.0f, 1.0f); 
    
    glColor4f( 0.9f, 0.2f, 0.2f, 0.5f);
    glTexCoord2f( 0.005f, 0.005f); glVertex3f(-1.0f, -1.0f,  1.3f);
    glColor4f( 0.2f, 0.9f, 0.2f, 0.5f);
    glTexCoord2f( 0.995f, 0.005f); glVertex3f( 1.0f, -1.0f,  1.3f);
    glColor4f( 0.2f, 0.2f, 0.9f, 0.5f);
    glTexCoord2f( 0.995f, 0.995f); glVertex3f( 1.0f,  1.0f,  1.3f); 
    glColor4f( 0.1f, 0.1f, 0.1f, 0.5f);
    glTexCoord2f( 0.005f, 0.995f); glVertex3f(-1.0f,  1.0f,  1.3f);
    
    
    // Left Face; offset.  Yellow, varying levels of opaque.
    
    glNormal3f(-1.0f, 0.0f, 0.0f);  
    
    glColor4f(0.9,0.9,0.2,0.0);
    glTexCoord2f(0.005f, 0.005f); glVertex3f(-1.3f, -1.0f, -1.0f); 
    glColor4f(0.9,0.9,0.2,0.66);
    glTexCoord2f(0.995f, 0.005f); glVertex3f(-1.3f, -1.0f,  1.0f);
    glColor4f(0.9,0.9,0.2,1.0);
    glTexCoord2f(0.995f, 0.995f); glVertex3f(-1.3f,  1.0f,  1.0f);
    glColor4f(0.9,0.9,0.2,0.33);
    glTexCoord2f(0.005f, 0.995f); glVertex3f(-1.3f,  1.0f, -1.0f);
    
    
    // All polygons have been drawn.
    glEnd();
    
    // Move back to the origin (for the text, below).
    glLoadIdentity();
    
    // We need to change the projection matrix for the text rendering.  
    glMatrixMode(GL_PROJECTION);
    
    // But we like our current view too; so we save it here.
    glPushMatrix();
    
    // Now we set up a new projection for the text.
    glLoadIdentity();
    glOrtho(0,Window_Width,0,Window_Height,-1.0,1.0);
    
    // Lit or textured text looks awful.
    glDisable(GL_TEXTURE_2D);
    glDisable(GL_LIGHTING);
    
    // We don't want depth-testing either.
    glDisable(GL_DEPTH_TEST); 
    
    // But, for fun, let's make the text partially transparent too.
    glColor4f(0.6,1.0,0.6,.75);
    
    // Render our various display mode settings.
    sprintf(buf,"Mode: %s", TexModesStr[Curr_TexMode]);
    glRasterPos2i(2,2); ourPrintString(GLUT_BITMAP_HELVETICA_12,buf);
    
    sprintf(buf,"AAdd: %d", Alpha_Add);
    glRasterPos2i(2,14); ourPrintString(GLUT_BITMAP_HELVETICA_12,buf);
    
    sprintf(buf,"Blend: %d", Blend_On);
    glRasterPos2i(2,26); ourPrintString(GLUT_BITMAP_HELVETICA_12,buf);
    
    sprintf(buf,"Light: %d", Light_On);
    glRasterPos2i(2,38); ourPrintString(GLUT_BITMAP_HELVETICA_12,buf);
    
    sprintf(buf,"Tex: %d", Texture_On);
    glRasterPos2i(2,50); ourPrintString(GLUT_BITMAP_HELVETICA_12,buf);
    
    sprintf(buf,"Filt: %d", Filtering_On);
    glRasterPos2i(2,62); ourPrintString(GLUT_BITMAP_HELVETICA_12,buf);
    
    
    // Now we want to render the calulated FPS at the top.
    
    // To ease, simply translate up.  Note we're working in screen
    // pixels in this projection.
    
    glTranslatef(6.0f,Window_Height - 14,0.0f);
    
    // Make sure we can read the FPS section by first placing a 
    // dark, mostly opaque backdrop rectangle.
    glColor4f(0.2,0.2,0.2,0.75);
    
    glBegin(GL_QUADS);
    glVertex3f(  0.0f, -2.0f, 0.0f);
    glVertex3f(  0.0f, 12.0f, 0.0f);
    glVertex3f(140.0f, 12.0f, 0.0f);
    glVertex3f(140.0f, -2.0f, 0.0f);
    glEnd();
    
    glColor4f(0.9,0.2,0.2,.75);
    sprintf(buf,"FPS: %f F: %2d", FrameRate, FrameCount);
    glRasterPos2i(6,0);
    ourPrintString(GLUT_BITMAP_HELVETICA_12,buf);
    
    // Done with this special projection matrix.  Throw it away.
    glPopMatrix();
    
    // All done drawing.  Let's show it.
    glutSwapBuffers();
    
    // Now let's do the motion calculations.
    X_Rot+=X_Speed; 
    Y_Rot+=Y_Speed; 
    
    // And collect our statistics.
    ourDoFPS();
}