OpenGL – Understanding GLFW and Its Relation to OpenGL

graphicsopengl

Now this question might sound (/ is) stupid, but I'm just getting into OpenGL.
So I installed GLFW source and I'm looking at some easy examples. What I'm noticing is, that the code still contains "typical" OpenGL functions, like glColor or glVertex, but it also contains "glfw" functions like glfwSetErrorCallback.

I don't really understand how OpenGL and GLFW (or something like GLUT) relate to each other. Khronos owns OpenGL, but do they program a library for people to use, or do they just specify an API, like for example there are several C++ libraries (libc++ and libstdc++) which implement the same API specified by the C++ Consortium?

I'm going to make an assumption and going to ask if it is right:

Khronos programs the OpenGL library and specifies an API for it. GLUT, GLFW and freeglut wrap around (or better extend) that OpenGL library and offer additional behavior (I read that OpenGL doesn't offer much for support for sound or dealing with input).

Which means that you could use OpenGL on its own, but it would make several things quite difficult. But it also means that you wrote something with GLFW, you could "port" it to using, e.g., freeglut, and you would only have to replace the functionality provided by glfw(...) functions, but the gl(...) woul stay the same. Is that right?

Best Answer

Yes. you are right

The OpenGL is the base layer, and is an API.

But it's a difficult (or , may better, low level) API.

So, using any library build on top of it will make things easier for you.

Of course, there are things that don't need to be made "better" or easier, so you still use now and then the base function calls, or the base declarations.

And yes, changing to another library won't affect those low level (or direct) calls