Getting glad
You can get glad
from https://glad.dav1d.de/, a web-based generator:
- Go to the site, select Version 3.3 from the gl dropdown, and select Core from the Profile dropdown:
- Scroll to the bottom and hit the Generate button. This should start downloading a ZIP file that contains all of the required code.
The code presented in this book is forward compatible with OpenGL version 3.3 or a more recent version. If you want to use a newer OpenGL version, such as 4.6, change the gl dropdown under API to the desired version. You will be adding the contents of this ZIP file to your main project in the next section.
Adding glad to the project
Once glad.zip
is downloaded, extract its contents. Add the following files from the ZIP file to your project. The directory structure does not need to be maintained; all of these files can be placed next to each other:
src/glad.c
include/glad/glad.h
include/KHR/khrplatform.h
These files will be included as normal project files—you don't have to set up include
paths—but that does mean that the contents of the files need to be edited:
- Open
glad.c
and find the following #include:#include <glad/glad.h>
- Replace the
include
path with the relative path ofglad.h
:#include "glad.h"
- Similarly, open
glad.h
and find the following #include:#include <KHR/khrplatform.h>
- Replace the
include
path with the relative path ofkhrplatform.h
:#include "khrplatform.h"
glad
should now be added to the project and there should be no compilation errors. In the next section, you will start implementing the Win32 window.