Adding an OpenGL loader
There is some external code that this chapter depends on, called glad
. When you create a new OpenGL context on Windows, it's created with a legacy OpenGL context. The extension mechanism of OpenGL will let you use this legacy context to create a new modern context.
Once the modern context is created, you will need to get function pointers to all OpenGL functions. The functions need to be loaded with wglGetProcAdress
, which returns a function pointer.
Loading every OpenGL function in this fashion would be very time-consuming. This is where having an OpenGL loader comes in; glad
will do all this work for you. An OpenGL loader is a library or some code that calls wglGetProcAdress
on the functions that the OpenGL API defines.
There are several OpenGL loaders available on Windows.; this book will use glad
. glad
is a small library that consists of only a few files. It has a simple API; you call one function and get access to all the OpenGL functions...