Post

Computer Graphics - OpenGL - Setup

OpenGL is not directly supported with Microsoft Windows. The OpenGL libraries have to be downloaded and loaded manually. GLAD manages function pointers for OpenGL. It is useful because OpenGL is only really a standard/specification it is up to the driver manufacturer to implement the specification to a driver that the specific graphics card supports. Since there are many different versions of OpenGL drivers, the location of most of its functions is not known at compile-time and needs to be queried at run-time.

Download OpenGL Library

  • Go to https://glad.dav1d.de/
  • Set gl to Version 4.6.
  • Click GENERATE at the bottom of the page.
Glad
  • This will generate a .zip file to download.
  • Right-click and select Save link as… to save glad.zip
Glad Download
  • Create a folder called “glad” in the ThirdParty folder and extract the glad.zip inside of it.
Glad Folder Extract

Add OpenGL Library

Add glad.c

The glad.c file is required because it contains the actual implementation that loads OpenGL function pointers at runtime. Modern OpenGL functions aren’t available directly from system headers, so GLAD retrieves their addresses from the graphics driver. Without including glad.c, the program will compile but fail to link since the function definitions are missing.

  • Right-click on the Engine Project and Add>Existing Item…
Glad C Add
  • Navigate to the directory with the glad file glad.c
    • Source\ThirdParty\glad\src
    • Select the glad.c file to add.
Glad C Add
  • Right-click on the glad.c file and select Properties.
    • Select C/C++>Precompiled Headers
    • Set Precompiled Header to Not Using Precompiled Headers.
Glad C PCH
  • Select C/C++>Advanced
  • Set Forced Include File to “” (nothing)
Force Include

Update Engine Properties

  • Right-click on the Engine Project and select Properties.
    • Select C/C++>General>Additional Include Directories.
Force Include
  • Add the glad include directory.
    1
    
    $(SolutionDir)Source\ThirdParty\glad\include
    
Force Include


Repeat the glad include directory steps with the Application Project.

This post is licensed under CC BY 4.0 by the author.