Introduction to Computer Graphics


Windows Setup



0. Install Visual Studio


The first action we want to perform is installing Visual Studio. This is Microsoft's primary environment for creating C++ programs.

  • "Google" Microsoft Visual Studio 2017 (Or any later version if it exists)
  • Download the installer, and when installing be sure to install the build tools for C++ (other things are optional)

1. Setup - Finding our OpenGL Version


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

  • In order to do this you will download the OpenGL Extension Viewer: GLView
  • GLView Download Link
  • glxinfo Notice in the OpenGL section I have version 4.4 on my machine.
  • If your machine is greater than 3.3 you are all set! If it is less than that, then let me know!

2. Identifying your graphics card


The GLView tool also provides information about your "Renderer" which is your graphics card.

  • View from the above screnshot your graphics card in the Systems Info area.
  • You will also see some useful information such as how much video memory (VRAM) you have available.
  • You can keep this in mind for later on in the semester.

3. Files - Downloading SDL


Now follow the directions to acquire SDL. I am assuming if you are on Windows, you have acquired Visual Studio 2017 with C++ installed. Please do that first. In addition, if you do not have success following my directions for whatever reason, you may try instead http://lazyfoo.net/tutorials/SDL/01_hello_SDL/index.php

Windows Users:
  • Download the latest version of SDL 2 from: https://www.libsdl.org/download-2.0.php
  • You will download the SDL2-devel-2.07-VC.zip for VC++
  • Move the files to somewhere useful, such as a "C://SDL2.0" directory rather than your downloads folder

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.

  1. Create a new Visual Studio C++ Solutionglxinfo
  2. Make sure that you have created a new C++ project and it is empty.glxinfo
  3. Change your configuration to x64 if you are on a 64 bit machine (very likely you are).glxinfo
  4. Right click on your project name in the Solution Explorer, then properites, then Navigate to VC++ Directoriesglxinfo
  5. Include the include directory from SDLglxinfo
  6. Also add the include directory from the source code we have downloaded. This includes the glad/glad.h file.glxinfo
  7. Include the lib directory from SDL under "Library Directories". Make sure to select the ones in x64.glxinfo
  8. Now navigate to the linker tab, and add 2 SDL libraries: SDL2.lib and SDL2main.lib under Input/Additional Dependencies.glxinfo
  9. These are the two libraries that live in your x64/lib file in SDl.glxinfo
  10. Under System make the SubSystem a "Console Based Project"glxinfo
  11. Move lab.cpp into your project source files (or otherwise create an empty .cpp file, name it lab.cpp, and copy the contents into it.)
  12. Move 'glad.c' into your project source files (or otherwise create an empty .c file, name it glad.c, and copy the contents into it.)
  13. glxinfo
  14. In your lab folder, make sure to drop in the SDL2.dll where you source files and project live. SDL2.dll lives in x64/lib
  15. glxinfo
  16. Now try to run your program!

6. Video Tutorial


If the instructions above did not work for whatever reason, you can try following this video tutorial I quickly made. Again, you can also try instead http://lazyfoo.net/tutorials/SDL/01_hello_SDL/index.php (But this does not cover installing GLAD)

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