home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OpenGL Superbible
/
OpenGL_Superbible_Waite_Group_Press_1996.iso
/
book
/
chapt3
/
teapot
/
teapot.c
next >
Wrap
C/C++ Source or Header
|
1995-09-29
|
1KB
|
59 lines
// teapot.c
// 3D shape drawing with the aux library
#include <windows.h> // Standard windows header
#include <gl\gl.h> // Opengl library
#include <gl\glaux.h> // AUX library
// The window has changed size
void CALLBACK ChangeSize(GLsizei w, GLsizei h)
{
// Prevent a divide by zero
if(h == 0)
h = 1;
// Set viewport to match window size
glViewport(0, 0, w, h);
// Reset the coordinate system
glLoadIdentity();
// Setup clipping volume
if (w <= h)
glOrtho (-100.0f, 100.0f, -100.0f, 100.0f*h/w, -100.0, 100.0);
else
glOrtho (-100.0f, 100*w/h, -100.0f, 100.0f, -100.0, 1.00);
}
// Draw the teapot
void CALLBACK RenderScene(void)
{
// Set clear color to blue and clear the screen
glClearColor(0.0f, 0.0f, 1.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT);
// Set drawing color to red and draw teapot
glColor3f(1.0f, 0.0f, 0.0f);
auxWireTeapot(50.0f);
glFlush();
}
// Main program body
void main(void)
{
// AUX window setup
auxInitDisplayMode(AUX_SINGLE | AUX_RGBA);
auxInitPosition(100,100,250,250);
auxInitWindow("3D Wire-Frame Teapot");
// Set window resize function
auxReshapeFunc(ChangeSize);
// Start main loop
auxMainLoop(RenderScene);
}