#include <GL/glaux.h>
#include <GL/glpfile.h>
#ifndef WIN32
# define CALLBACK
# define APIENTRY
#endif
GLfloat rotation = 0.0;
GLPfile *output;
void CALLBACK
reshape_scene(GLsizei width,
GLsizei height)
{
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(22.5, (float)width / (float)height, 0.1, 1000.0);
glMatrixMode(GL_MODELVIEW);
}
void CALLBACK
draw_scene(void)
{
static float red_light[4] = { 1.0, 0.0, 0.0, 1.0 };
static float red_pos[4] = { 1.0, 1.0, 1.0, 0.0 };
static float blue_light[4] = { 0.0, 0.0, 1.0, 1.0 };
static float blue_pos[4] = { -1.0, -1.0, -1.0, 0.0 };
static float fog_color[4] = { 0.0, 0.0, 0.0, 0.0 };
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_LIGHT1);
glShadeModel(GL_SMOOTH);
if (output != NULL)
output->StartPage();
glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLightfv(GL_LIGHT0, GL_DIFFUSE, red_light);
glLightfv(GL_LIGHT0, GL_POSITION, red_pos);
glLightfv(GL_LIGHT1, GL_DIFFUSE, blue_light);
glLightfv(GL_LIGHT1, GL_POSITION, blue_pos);
glEnable(GL_COLOR_MATERIAL);
glFogf(GL_FOG_DENSITY, 0.25);
glFogfv(GL_FOG_COLOR, fog_color);
glPushMatrix();
glTranslatef(-1.0, -0.5, -15.0);
glRotatef(-rotation, 0.0, 1.0, 0.0);
glRotatef(rotation, 1.0, 0.0, 0.0);
glColor3f(1.0, 1.0, 0.0);
auxSolidCylinder(1.0, 1.0);
glPopMatrix();
glPushMatrix();
glTranslatef(1.0, 0.0, -10.0);
glRotatef(rotation, 0.0, 1.0, 0.0);
glRotatef(rotation, 1.0, 0.0, 0.0);
glColor3f(0.0, 1.0, 1.0);
auxSolidTeapot(1.0);
glPopMatrix();
if (output != NULL)
{
if (output->EndPage() == 0)
{
delete output;
output = NULL;
};
};
auxSwapBuffers();
}
void CALLBACK
rotate_objects(void)
{
rotation += 2.0;
if (rotation >= 360.0)
rotation -= 360.0;
draw_scene();
}
void
main(void)
{
auxInitDisplayMode(AUX_RGB | AUX_DEPTH | AUX_DOUBLE);
auxInitPosition(256, 256, 768, 512);
auxInitWindow("Fogged Teapots");
auxReshapeFunc(reshape_scene);
auxIdleFunc(rotate_objects);
output = new GLPfile("test.ps");
auxMainLoop(draw_scene);
}