Beispiel #1
0
void drawHouse(void) {
	myBegin(GL_POLYGON); //roof
		myColor3f(1.0,0.0,0.0);
		myVertex2f(0.0,1.0);
		myVertex2f(0.5,1.5);
		myVertex2f(1.0,1.0);
	myEnd();

	myBegin(GL_POLYGON);
		// house
		myColor3f(0.0,1.0,0.0);
		myVertex2f(0.0,1.0);
		myVertex2f(1.0,1.0);
		myVertex2f(1.0,0.0);
		myVertex2f(0.0,0.0);
	myEnd();

	myBegin(GL_POLYGON);
		// door
		myColor3f(0.0,0.0,1.0);
		myVertex2f(0.2,0.0);
		myVertex2f(0.5,0.0);
		myVertex2f(0.5,0.65);
		myVertex2f(0.2,0.65);
	myEnd();
}
Beispiel #2
0
void redrawSlices3D(void)
{
    int i;

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glPushMatrix();
    glRotatef(objangle[X], 0.f, 1.f, 0.f);
    glRotatef(objangle[Y], 1.f, 0.f, 0.f);

    glMatrixMode(GL_TEXTURE);
    glPushMatrix(); /* identity */
    glTranslatef(.5f, .5f, .5f);
    glRotatef(objangle[X], 0.f, 1.f, 0.f);
    glRotatef(objangle[Y], 1.f, 0.f, 0.f);
    glTranslatef(-.5f, -.5f, -.5f);

    textureEnable();
    glColor3f(1.f, 1.f, 1.f); 
    for(i = 0; i < slices; i++)
    {
	myBegin(GL_QUADS);
	myVertex3f(-100.f, -100.f, -100.f + 200 * i/(slices - 1.f)); 
	myVertex3f( 100.f, -100.f, -100.f + 200 * i/(slices - 1.f)); 
	myVertex3f( 100.f,  100.f, -100.f + 200 * i/(slices - 1.f)); 
	myVertex3f(-100.f,  100.f, -100.f + 200 * i/(slices - 1.f)); 
	glEnd();
    }

    glDisable(GL_TEXTURE_3D_EXT);
    glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
    glColor3f(0.f, 0.f, 1.f); 
    for(i = 0; i < slices; i++)
    {
	glBegin(GL_QUADS);
	glVertex3f(-100.f, -100.f, -100.f + 200 * i/(slices - 1.f)); 
	glVertex3f( 100.f, -100.f, -100.f + 200 * i/(slices - 1.f)); 
	glVertex3f( 100.f,  100.f, -100.f + 200 * i/(slices - 1.f)); 
	glVertex3f(-100.f,  100.f, -100.f + 200 * i/(slices - 1.f)); 
	glEnd();
    }
    glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);

    glPopMatrix();
    glMatrixMode(GL_MODELVIEW);
    glPopMatrix();

    
    if(dblbuf)
	glutSwapBuffers(); 
    else
	glFlush(); 
    
}
Beispiel #3
0
void redrawVolume(void)
{
    int i;
    glClear(GL_COLOR_BUFFER_BIT);

    glMatrixMode(GL_TEXTURE);
    glPushMatrix(); /* identity */
    glTranslatef(.5f, .5f, .5f);
    glRotatef(objangle[X], 0.f, 1.f, 0.f);
    glRotatef(objangle[Y], 1.f, 0.f, 0.f);
    glTranslatef(-.5f, -.5f, -.5f);

    if(colors)
    {
	for(i = 0; i < slices/2; i++)
	{
	    myBegin(GL_QUADS);
	    myVertex3f(-100.f, -100.f, -100.f + 200 * i/(slices - 1.f)); 
	    myVertex3f(   0.f, -100.f, -100.f + 200 * i/(slices - 1.f)); 
	    myVertex3f(   0.f,    0.f, -100.f + 200 * i/(slices - 1.f)); 
	    myVertex3f(-100.f,    0.f, -100.f + 200 * i/(slices - 1.f)); 

	    glColor3f(0.f, 1.f, 0.f); 
	    myVertex3f(   0.f, -100.f, -100.f + 200 * i/(slices - 1.f)); 
	    myVertex3f( 100.f, -100.f, -100.f + 200 * i/(slices - 1.f)); 
	    myVertex3f( 100.f,    0.f, -100.f + 200 * i/(slices - 1.f)); 
	    myVertex3f(   0.f,    0.f, -100.f + 200 * i/(slices - 1.f)); 

	    glColor3f(0.f, 0.f, 1.f); 
	    myVertex3f(   0.f,    0.f, -100.f + 200 * i/(slices - 1.f)); 
	    myVertex3f( 100.f,    0.f, -100.f + 200 * i/(slices - 1.f)); 
	    myVertex3f( 100.f,  100.f, -100.f + 200 * i/(slices - 1.f)); 
	    myVertex3f(   0.f,  100.f, -100.f + 200 * i/(slices - 1.f)); 
	    
	    glColor3f(1.f, 1.f, 1.f); 
	    myVertex3f(-100.f,    0.f, -100.f + 200 * i/(slices - 1.f)); 
	    myVertex3f(   0.f,    0.f, -100.f + 200 * i/(slices - 1.f)); 
	    myVertex3f(   0.f,  100.f, -100.f + 200 * i/(slices - 1.f)); 
	    myVertex3f(-100.f,  100.f, -100.f + 200 * i/(slices - 1.f)); 
	    glEnd();
	}

	for(i = slices/2; i < slices; i++)
	{
	    myBegin(GL_QUADS);
	    glColor3f(1.f, .5f, .5f); 
	    myVertex3f(-100.f, -100.f, -100.f + 200 * i/(slices - 1.f)); 
	    myVertex3f(   0.f, -100.f, -100.f + 200 * i/(slices - 1.f)); 
	    myVertex3f(   0.f,    0.f, -100.f + 200 * i/(slices - 1.f)); 
	    myVertex3f(-100.f,    0.f, -100.f + 200 * i/(slices - 1.f)); 

	    glColor3f(1.f, 1.f, 0.f); 
	    myVertex3f(   0.f, -100.f, -100.f + 200 * i/(slices - 1.f)); 
	    myVertex3f( 100.f, -100.f, -100.f + 200 * i/(slices - 1.f)); 
	    myVertex3f( 100.f,    0.f, -100.f + 200 * i/(slices - 1.f)); 
	    myVertex3f(   0.f,    0.f, -100.f + 200 * i/(slices - 1.f)); 

	    glColor3f(1.f, 0.f, 1.f); 
	    myVertex3f(   0.f,    0.f, -100.f + 200 * i/(slices - 1.f)); 
	    myVertex3f( 100.f,    0.f, -100.f + 200 * i/(slices - 1.f)); 
	    myVertex3f( 100.f,  100.f, -100.f + 200 * i/(slices - 1.f)); 
	    myVertex3f(   0.f,  100.f, -100.f + 200 * i/(slices - 1.f)); 

	    glColor3f(0.f, 1.f, 1.f); 
	    myVertex3f(-100.f,    0.f, -100.f + 200 * i/(slices - 1.f)); 
	    myVertex3f(   0.f,    0.f, -100.f + 200 * i/(slices - 1.f)); 
	    myVertex3f(   0.f,  100.f, -100.f + 200 * i/(slices - 1.f)); 
	    myVertex3f(-100.f,  100.f, -100.f + 200 * i/(slices - 1.f)); 
	    glEnd();
	}
    }
    else
    {
	for(i = 0; i < slices; i++)
	{
	    glColor3f(1.f, 1.f, 1.f); 
	    myVertex3f(-100.f, -100.f, -100.f + 200 * i/(slices - 1.f)); 
	    myVertex3f( 100.f, -100.f, -100.f + 200 * i/(slices - 1.f)); 
	    myVertex3f( 100.f,  100.f, -100.f + 200 * i/(slices - 1.f)); 
	    myVertex3f(-100.f,  100.f, -100.f + 200 * i/(slices - 1.f)); 
	}
    }

    glPopMatrix();
    glMatrixMode(GL_MODELVIEW);

    if(dblbuf)
	glutSwapBuffers(); 
    else
	glFlush(); 
    
}