home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
egltk22.zip
/
sample.c
< prev
next >
Wrap
Text File
|
1998-02-21
|
5KB
|
120 lines
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Sample Escape GL Custom Screen Saver
// Copyright (c) 1997, Snow Storm Software
// All Rights Reserved
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include "custom.h"
#include <glut.h>
#include <tk.h>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// general instructions:
// - copy this file to another name eg. cool.c
// - modify all functions examples to provide the processing you desire
// - add your project to the 'TARGETS =' part of 'MAKEFILE.' eg. 'TARGETS = sample.egl wave.egl cool.egl'
// - make sure the 'TOP =' part of 'MAKEFILE' correctly identifies the location of your opengl base directory
// eg. 'TOP = \opengl'
// - build your project using 'nmake'
// - copy your new screen saver module 'cool.egl' to any Escape GL sub-directory
// - reload Escape GL
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// global variables
// define any variables you require
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
GLfloat rotation = 0;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// eglDesc
// defines the name of the module as it will appear in the drop down module list
// this name must be unique and not match any existing modules, nor custom modules
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
char * APIENTRY eglDesc()
{
return( "Cube Sample" );
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// eglInit
// initializes the opengl module you wish to display and is called once before the model is animated
// this function is called once to setup the module
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void APIENTRY eglInit( GLint quality )
{
glClearColor( 0.0, 0.0, 0.0, 0.0 );
glShadeModel( GL_FLAT );
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// eglIdle
// animates and displays the module
// the parameter 'step' simply defines the time in seconds between time steps, use this to control the animation speed
// the size of the step is based on the speed of the target system and the complexity of the module, slower modules
// will take larger steps
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void APIENTRY eglIdle( GLfloat step )
{
glClear( GL_COLOR_BUFFER_BIT );
glColor3f( 1.0, 1.0, 1.0 );
glLoadIdentity(); /* clear the matrix */
/* viewing transformation */
gluLookAt( 0.0, 0.0, 3.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0 );
/* rotate */
rotation += step * 270.; // rotate at 30 deg per second
if ( rotation > 360.0 )
rotation -= 360.;
glRotatef( rotation, 0, 1, 0 );
glutWireCube( 1.0 );
// NOTE: swapping of the buffers is done automatically by Escape GL and should not be added here.
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// eglReshape
// resizes the window
// use this function to define the viewport and projection transformations based on the window size
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void APIENTRY eglReshape( GLint w, GLint h )
{
glViewport( 0, 0, w, h );
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
glFrustum( -1.0, 1.0, -1.0, 1.0, 1.5, 20.0 );
glMatrixMode( GL_MODELVIEW );
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// eglDestroy
// destroy display lists, objects etc. when the module has ended
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void APIENTRY eglDestroy()
{
}