官术网_书友最值得收藏!

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. glad has a web-based interface; you can find it at https://glad.dav1d.de/.

Important note

When using an X Windows system, such as many popular Linux distributions, the function to load OpenGL functions is glXGetProcAddress. As with Windows, there are OpenGL loaders available for Linux as well. Not all OSes need an OpenGL loader; for example, macOS, iOS, and Android don't need a loader. Both iOS and Android run on OpenGL ES.

主站蜘蛛池模板: 屏山县| 石家庄市| 潢川县| 邹城市| 房山区| 宿迁市| 鸡西市| 彩票| 铁岭市| 漯河市| 合肥市| 南昌县| 舟曲县| 高台县| 成安县| 绥江县| 宁海县| 七台河市| 紫金县| 永春县| 绥芬河市| 固原市| 东平县| 桦南县| 察哈| 磐安县| 新化县| 清原| 鸡泽县| 扶余县| 贵港市| 山阴县| 祁阳县| 大邑县| 凤庆县| 临夏县| 土默特右旗| 呈贡县| 桃园市| 乌审旗| 宁河县|