neeh
neeh

Reputation: 3025

Using OpenGL 4.3 in a C project

I need to use the function glDeleteProgram() but the compiler tells me that the function does not exist. I think my version of gl.h is too old but I can't find how to install OpenGL 4.3 in my project...

#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <gl/gl.h>

I tried to include glext.h but it didn't work.

Upvotes: 0

Views: 432

Answers (1)

Andon M. Coleman
Andon M. Coleman

Reputation: 43369

There seems to be a little bit of confusion exactly what purpose the gl.h header that ships with your platform serves. I will try to explain it better below, but be aware that this header and the platform's OpenGL library are very much related (and basically immutable). When you speak of "installing" OpenGL 4.3, you are actually supplementing (at run-time, rather than compile-time) the flimsy library that this header belongs to.


Platforms such as Microsoft Windows ship with a very primitive software implementation of OpenGL (1.1 in this case) but are designed in such a way that installed display drivers can extend/replace the software implementation at run-time. Microsoft refers to this system as Installable Client Drivers.

For all intents and purposes, GLEW interfaces with your display driver and loads all of the parts of OpenGL newer than 1.1. Without using GLEW you are limited to the capabilities of the software implementation, which on Microsoft Windows was written in ~1997 and has never been updated since. <GL/gl.h> is always going to be 1.1 on Windows, because drivers are responsible for extending GL and you never compile/link your software directly to a display driver.

GLEW is nothing special, you could read the extension specifications here and write your own header with all of the extended function prototypes, enums and constant values you need... however, over the years this task has become ridiculously tedious (there are currently over 120 ARB extensions). GLEW basically packages all of the major published extension specifications into one massive library, and will load every one of the extensions your driver claims to support. This is effectively how GL versioning works, by the way, each new version boils down to a collection of required extensions.


Back in the day, there were these bloody awful things called MiniGL drivers, and games like Quake 1 actually did link directly to extremely primitive and proprietary drivers from vendors like 3Dfx and PowerVR. Fortunately, we are way past those days.

Upvotes: 1

Related Questions