#include <GL/glut.h>
#include
// define the size of the window
#define window_width 640
#define window_height 480
// Main loop function
void main_loop_function()
{
// Clear color screen
// And depth , is used internally to block obstructed objects
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// If don't use the next source code OpenGL will show dizzy content of windows
glutSwapBuffers();
}
// Initialze OpenGL perspective matrix
void GL_Setup(int width, int height)
{
glViewport( 0, 0, width, height );
glMatrixMode( GL_PROJECTION );
glEnable( GL_DEPTH_TEST );
gluPerspective( 45, (float)width/height, .1, 100 );
glMatrixMode( GL_MODELVIEW );
}
// Initialize GLUT and start main loop function
int main(int argc, char** argv) {
glutInit(&argc, argv);
glutInitWindowSize(window_width, window_height);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
glutCreateWindow("www.free-tutorials.org - get? the GLSL version example.");
glutIdleFunc(main_loop_function);
GL_Setup(window_width, window_height);
//next source code will show on shell the OpenGL and GLSL version
printf("OpenGL %s, GLSL %s\n", glGetString(GL_VERSION),glGetString(GL_SHADING_LANGUAGE_VERSION));
glutMainLoop();
}