/******************************************************
* MESA/OpenGL program simple1.c
* draws a filled rectangle in several shades of red
*******************************************************/
#include <GL/gl.h>
#include <stdlib.h>
#include "glaux.h"
int main (int argc, char** argv)
{
float i;
auxInitDisplayMode (AUX_SINGLE | AUX_RGB); /* kind of window */
auxInitPosition (0, 0, 500, 500); /* x,y,w,h of window on screen */
auxInitWindow (argv[0]); /* open the window */
glClearColor (0.0, 0.0, 0.0, 0.0); /* bkg color window is to have */
glClear(GL_COLOR_BUFFER_BIT); /* clear the window to that color */
glOrtho (-1,1,-1,1,-1,1); /* orthographic proj., viewing volume */
for (i=0.2; i<=1.0; i+=0.2) /* 5 shades of red */
{
glColor3f(i, 0.0, 0.0); /* drawing color */
glBegin(GL_POLYGON); /* define the rectangle */
glVertex2f(-0.5, -0.5);
glVertex2f(-0.5, 0.5);
glVertex2f(0.5, 0.5);
glVertex2f(0.5, -0.5);
glEnd();
glFlush(); /* force execution--send commands over network */
sleep (2); /* wait a while */
}
}
/***********************************************************************
COMPILING/LINKING the MESA/OpenGL application--
Enter the correct commands
Or Set up a script file containing the correct commands
csun_simple1 -- contains the command to compile/link the file simple1.c
on bingsuns at SUNY-B.
usage-- from UNIX prompt: source csun_simple
Contents of the file csun_simple1
gcc -I/opt/local/Mesa/v1.2.5/include -I/usr/openwin/include simple1.c \
-L/opt/local/Mesa/v1.2.5/lib -lMesaaux -lMesatk -lMesaGLU -lMesaGL -lm \
-lX11 -o simple1
DISPLAY environment variable must be set right for program to run.
*************************************************************************/