Computer Graphics. CS 385 February 7, 2005. Fundamentals of OpenGl and Glut. Today we will go through the basics of a minimal OpenGl Glut project, explaining the role of each piece of the code. #include <GL/glut.h>. Includes gl.h and glu.h. Contains all the Glut constant definitions
Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.
February 7, 2005
Today we will go through the basics of a minimal OpenGl Glut project, explaining the role of each piece of the code.
The main function takes two (optional) parameters
argc is the number of parameters passed to the main function
argv is an array of strings containing those parameters
glutInit initializes the GLUT library. It takes two parameters from the main function.
The declaration of glutInit is
void glutInit(int *argcp, char **argv);
In addition to initializing the GLUT library, glutInit will negociate a session with the window system.
int glutCreateWindow(char *name);
void glutDisplayFunc(void (*func)(void));
using namespace std;
void call(int (*func)(int i), int i)
cout << func(i) << endl;
int square(int i)
The init() function is not a GLUT or GL function. It is our own customed made function which contains the code to set up the OpenGL environment.
Typically, in this function we pu these lines like these
void glPointSize( GLfloat size )
void glLineWidth( GLfloat width )
glBegin( PARAMETER GOES HERE );
Try the above code with GL_POINTS, GL_LINES, GL_LINE_STRIP, GL_LINE_LOOP AND GL_POLYGON
GL_QUADS takes points four at a time and makes quadrilaterals out of them.
GL_TRIANGLES takes points three at a time and makes triangles out of them out of them.
Look in the book at