Search code examples
openglglfwglewfreeglut

Make a simple 2D library with OpenGL


I would like to create a 'simple' 2D library with OpenGL. I want to use OpenGL because I know I will learn lot of things that's why I don't want to use a higher level library (like SDL).

I know there is some library to make OpenGL a bit easier:

  • freeglut: I saw a recent release (freeglut 3.2.1 in 29 September 2019) but is it still used?
  • glfw: it seems more modern but seems too high level

I don't know if we can compare these libraries but what is the 'best' library (between glfw/freeglut) for learning?

There is also GLEW but I don't understand what is it.. Is it required? I just know it's unrelated with freeglut or glfw..


Solution

  • What is the 'best' library (between glfw/freeglut) for learning?

    The best library is not using any if you really want to learn all the details.

    You will need to learn how to load OpenGL functions on the fly based on the OpenGL version and extensions you want. You also will learn how to use your windowing system (e.g. Win32, X11, etc.) to create a window suitable for OpenGL rendering.

    Typically most developers avoid some or all of that by using a library that loads OpenGL functions (e.g. GLEW) and/or creates the native window (e.g. SDL, glfw, glut; which typically work for several platforms), but you can do it by yourself if you really want.

    A good option is to pick SDL and use it only for window initialization. That leaves you to load the OpenGL functions you use, which is fairly easy. Then, when you need input, you can use the SDL input subsystem too.