Installing OpenGL Development Environment in Ubuntu

1. Download OpenGl liberies

sudo apt-get install freeglut3 freeglut3-dev
sudo apt-get install binutils-goldc
sudo apt-get install libglew1.5

2. Create a test file (test.c):

#include 

//Drawing funciton
void draw(void)
{
  //Background color
  glClearColor(0,1,0,1);
  glClear(GL_COLOR_BUFFER_BIT );
  //Draw order
  glFlush();
}

//Main program
int main(int argc, char **argv)
{
  glutInit(&argc, argv);
  //Simple buffer
  glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB );
  glutInitWindowPosition(50,25);
  glutInitWindowSize(500,250);
  glutCreateWindow("Green window");
  //Call to the drawing function
  glutDisplayFunc(draw);
  glutMainLoop();
  return 0;
}

3.Compile the file linking the OpenGL/Glut libraries:

gcc -lGL -lglut -lGL -lGLEW test.c -o test 

or

g++ -I/usr/include -L/usr/lib -lglut -lGL -lGLU -lGLEW 

4. Configuring with eclipse

  1. Donwload and ADD CDT plugin for eclipse. Download Link
  2. After installing CDT, go to eclipse’s Menu, Projects->Properties
    From leftside bar, Expand C/C++ General->Path & Symbols
  3. Go to libraries add this four lib one by one ( glut, GL,GLU, GLEW ) .
  4. Now try to build and compile your code

One thought on “Installing OpenGL Development Environment in Ubuntu

  1. Or, you can use following Makefile (linux/mac):

    CC = g++
    CFLAGS = -Wall
    PROG = test

    SRCS = main.cpp

    LIBS = -lglut -lGLU

    all: $(PROG)

    $(PROG): $(SRCS)
    $(CC) $(CFLAGS) -o $(PROG) $(SRCS) $(LIBS)

    clean:
    rm -f $(PROG)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s