Introduction to Computer Graphics


Linux Setup



1. Setup - Finding our OpenGL Version


The first thing we want to do on our linux systems, is check which version of OpenGL we have.

  • Run from a terminal the command: glxinfo
  • You will see a bunch of output, that is showing all of the 'features' supported by your graphics card.
  • Run next: glxinfo | grep "version"
  • glxinfo The observation here is the core profile. We see that it is 4.3 on my machine. We want this to be at least 2
  • Later on, you can run glxinfo -l to see more specific limits for your graphics.

2. Identifying your graphics card


Today most laptops have a fairly powerful graphics card on them. Some laptops even have two graphics cards in them! To find out, lets run some commands from the terminal to find out.

  • From a terminal run the command: "lspci -v"
  • Scan through and see what your Display controllers are. In my case, I have 2!

3. Files - Downloading SDL


Now follow the directions with your appropriate flavor of Linux (or the build manager) to acquire SDL. If you do not have success following my directions, you may try instead http://lazyfoo.net/tutorials/SDL/01_hello_SDL/index.php

Ubuntu Users (apt-get):
  • Next in the terminal run: apt-cache search libsdl2
  • Next: sudo apt-get install libsdl2-dev
CentOS Users (yum): (If you are running the same configuration as our servers)
  • Next in the terminal run: yum search SDL2-devel
  • Next: yum install SDL2-devel

At this point, you have now successfully aquired the SDL libraries. Now, move on to the next step.


4. GLAD - OpenGL Extensions


Note: I have done this setup for you in the repository.

GLAD is a tool that helps us use extensions in OpenGL. An OpenGL extension is some feature or functionality that a graphics card vendor provides. In other words, extensions are released over time, and they allow us to run a variety of commands on graphics cards to improve performance, or create neat visual effects.

Some information below.
  • A permanent link to the 3.3 profile I generated for this course is here. I have provided GLAD in the code repository already.
  • If you look at glad.h, you will see that it is essentially a giant list of function pointers.
  • (Optional just FYI: You can generate your own profile here: GLAD webservice
  • (Optional) If you are still having trouble, this link may be of use:GLAD and SDL2

5. Build - Linking SDL with source


Now that we have GLAD and SDL downloaded, we are ready to try and run our program. In this section I am going to describe how to link SDL to our executable.

  • Provide with the lab is a file called "linuxbuild.py". By running "python linuxbuild.py" on your system, your file will actually compile just fine. However, let me show a "raw" version of compiling so you understand what is going on.
  • clang++ -D LINUX -o lab -I ./include/ ./src/lab.cpp ./src/glad.c -lSDL2 -ldl
    • clang++ is the compiler being used
    • -D Sends a #define directive through the preprocessor to conditionally evaluate part of our code.
    • -o lab1 is a compiler flag outputting an object file named lab 1
    • -I followed by a directory tells where to look for header(.h) files.
    • ./src/lab1.cpp is an example of a C++ file we are compiling (./src/glad.c is a .c file also being compiled)
    • -lSDL2 tells to load in the SDL2 library.

6. Video Tutorial


If the instructions above did not work for whatever reason, you can try following this video tutorial I quickly made.

(Best viewed in HD if you want to read the text).