I have some familiarity with C++, and concepts like compiling and linking static and dynamic libraries, which is what I understand as collections of code that simplify doing certain things.

But then I get confused in certain cases, for example, why is OpenGL considered an API? Why is it necessary to use other libraries like GLAD, freeGLUT or GLFW to interface with OpenGL?

And then other languages have this thing called package managers, like pip, node, cargo, and vcpkg for c/c++, where you install these packages that get used like libraries? What’s the difference?

Finally the ones I understand the least of are frameworks. I keep hearing the concept of frameworks like Angular for js and a lot of stuff that’s too alien for me because I’m still unfamiliar with web development.

So for example, I’m using the raylib library for a small game project I have. I link the .lib or .dll file to my executable file so I know I’m unambiguously using a library. How come there’s also Cocos2dx which is a framework? What’s the distinction?

  • borokov@lemmy.world
    link
    fedilink
    arrow-up
    1
    ·
    8 hours ago

    Small word about OpenGL, as it seems confusing for many peoples:

    OpenGL is a spec written by Kronos group. There is no such thing as OpenGL library, or OpenGL source code. You cannot “download” OpenGL. OpenGL is really just a buch of .txt files explaining how functions should be named and what they should do. This spec define an API.

    Then, this API can be implemented by anyone, by writing code and putting it in a library.

    GPU drivers implement this API. That means that Nvidia, AMD and Intel have their own implementation.

    To have access to this API from your program, you have to “getProcAdress” all function you want to use from GPU driver’s DLL. As this is quite painfull, libs exist, like glew, that do it for you. These libs are really just a long list of getProcAdress for all entry points.

    That’s also why you cannot “static link” with OpenGL. As function can only be retrieved at runtime.

    Another interesting things is MESA. It’s a CPU implementation of OpenGL spec. So MESA is a lib, with source code and so on. You can download it, link against it, etc… This is very useful when you want to do 3D without GPU (yes, this happen, especially in medical domain).