main.cpp source code Makefile.win Windows makefile usable from the command line. This will possibly require some customisation for your machine. Usage is:
nmake -f Makefile.winsq.dsp project file for Visual C++ sq.dsw workspace file for Visual C++. Double click this to load and compile the code within the Visual C++ environment. Debug subdirectory containing object and executable files Makefile.linux Makefile for Linux. This will possibly require some customisation for your machine.
make -f Makefile.linux#include <stdio.h>
#include <GL/glut.h>void display(void)
{
glClear( GL_COLOR_BUFFER_BIT);
glColor3f(0.0, 1.0, 0.0);
glBegin(GL_POLYGON);
glVertex3f(2.0, 4.0, 0.0);
glVertex3f(8.0, 4.0, 0.0);
glVertex3f(8.0, 6.0, 0.0);
glVertex3f(2.0, 6.0, 0.0);
glEnd();
glFlush();
}int main(int argc, char **argv)
{
printf("hello world\n");
glutInit(&argc, argv);
glutInitDisplayMode ( GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH);glutInitWindowPosition(100,100);
glutInitWindowSize(300,300);
glutCreateWindow ("square");glClearColor(0.0, 0.0, 0.0, 0.0); // black background
glMatrixMode(GL_PROJECTION); // setup viewing projection
glLoadIdentity(); // start with identity matrix
glOrtho(0.0, 10.0, 0.0, 10.0, -1.0, 1.0); // setup a 10x10x2 viewing worldglutDisplayFunc(display);
glutMainLoop();return 0;
}
RGB | red, green, and blue, typically 8 bits per pixel | GLUT_RGB |
A | alpha or accumulation buffer; used for compositing images | GLUT_RGBA |
Z | depth value, used for Z-buffer visibility tests | GLUT_DEPTH |
double buffer | extra copy of all buffers, used for smooth animation | GLUT_DOUBLE |
stencil buffer | several extra bits, useful in compositing images | GLUT_STENCIL |