/*
* GLUT Shapes Demo
*
* Written by Nigel Stewart November 2003
*
* This program is test harness for the sphere, cone
* and torus shapes in GLUT.
*
* Spinning wireframe and smooth shaded shapes are
* displayed until the ESC or q key is pressed. The
* number of geometry stacks and slices can be adjusted
* using the + and - keys.
*/
#include <windows.h>
#ifdef __APPLE__
#include <GLUT/glut.h>
#include <GL/glut.h>
#include <stdlib.h>
static int slices = 16;
static int stacks = 16;
/* GLUT callback Handlers */
//float x[4] = {0.9,-0.1,-0.1,0.9},y[4]={0.9,0.9,-0.1,-0.1};
class project
{
public:
float x[3]={0,0.5,0.5};
float y[3]={0,0.75,-0.25};
float ge = 1;
void print_test(void)
{
glColor3f(1,0,0);
glBegin(GL_POLYGON);
glVertex3f(x[0],y[0],0);
glVertex3f(x[1],y[1],ge);
glVertex3f(x[2],y[2],ge);
glEnd();
glBegin(GL_POLYGON);
glVertex3f(x[0]-0.1,y[0],0);
glVertex3f(x[1]-0.1,y[1],ge);
glVertex3f(x[2]-0.1,y[2],ge);
glEnd();
glColor3f(1,0.5,0.5);
glBegin(GL_POLYGON);
glVertex3f(x[0],y[0],0);
glVertex3f(x[0]-0.1,y[0],0);
glVertex3f(x[1]-0.1,y[1],0);
glVertex3f(x[1],y[1],ge);
glEnd();
glColor3f(0.8,0,0);
glBegin(GL_POLYGON);
glVertex3f(x[0],y[0],0);
glVertex3f(x[0]-0.1,y[0],0);
glVertex3f(x[2]-0.1,y[2],ge);
glVertex3f(x[2],y[2],0);
glEnd();
}
};
float n = 2.5;
project p;
static void display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
p.print_test();
/*
y[1] += 0.00001;
x[1] += 0.00001;
*/
glFlush();
glutSwapBuffers();
}
static void key(unsigned char key, int xl, int yl)
{
switch (key)
{
case 27 :
case 'q':
exit(0);
break;
break;
}
glutPostRedisplay();
}
static void idle(void)
{
glutPostRedisplay();
}
/* Program entry point */
int main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitWindowSize(480,480);
glutInitWindowPosition(10,10);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("GLUT Shapes");
glutDisplayFunc(display);
glutKeyboardFunc(key);
glutIdleFunc(idle);
glClearColor(1,1,1,1);
glEnable(GL_DEPTH_TEST);
glEnable(GL_DEPTH);
glEnable(GL_CW);
glEnable(GL_SMOOTH);
glutMainLoop();
return EXIT_SUCCESS;
}