OpenGL Programming/Installation/GLUT

GLUT is the utility toolkit that provides Window management for OpenGL applications and their interface with the operating system.

GLUT alternativesEdit

GLUT started as a non-free library. Nowadays, free/open-source and portable alternatives such as FreeGLUT and OpenGLUT exist.

In this wikibook, we recommend FreeGLUT. See the platform-specific installation pages for details on how you can install it.

Using GLUT to discover OpenGL versionEdit

#include <stdio.h> /* printf */
#include <GL/glut.h> /* glut graphics library */
Linux c console program 
gcc f.c -lglut -lGL
int main(int argc, char **argv)
  glutInit(&argc, argv);
  glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
  glutCreateWindow("red 3D lighted cube");
  printf("GL_VERSION = %s\n",glGetString(GL_VERSION) ); /* GL_VERSION = 2.1.2 NVIDIA 195.36.24 */
  return 0; 

More informationEdit

This program shows info about glut.[1]

To compile :

gcc v.c -lglut -lGL

To run :

#include <stdio.h>

#if defined(HAVE_FREEGLUT)

#ifdef WIN32
#include "../include/GL/freeglut.h"
#include <GL/freeglut.h>


#include <GL/glut.h>


#define PROGRAM "glversion"

int main(int argc, char **argv)
  char *version = NULL;
  char *vendor = NULL;
  char *renderer = NULL;
  char *extensions = NULL;
  GLuint idWindow = 0;
  int	glutVersion;

  glutInit(&argc, argv);
  idWindow = glutCreateWindow(PROGRAM);

  glutVersion = glutGet(0x01FC);
  version =     (char*)glGetString(GL_VERSION);
  vendor =      (char*)glGetString(GL_VENDOR);
  renderer =    (char*)glGetString(GL_RENDERER);
  extensions =  (char*)glGetString(GL_EXTENSIONS);


  1. : glversion.c

< OpenGL Programming/Installation

Browse & download complete code