If I use Glad and not GLEW will I miss on something?
Asked Answered
D

1

18

I want to use OpenGL but I don't know how to set up GLEW. Would I lose something if I am going to use Glad? Could I learn from tutorials that use GLEW?

Dena answered 17/8, 2021 at 16:37 Comment(4)
With Glad you have a lot less code to compile compared to Glew when you do not need the latest OpenGL profile.Fulbert
@j6t, so are you suggesting using glad over glew?Transcaucasia
@BiMo The answer gives a good guideline how to assess which one you might use. I'm not suggesting one over the other.Fulbert
I have actually noticed most of the recent opengl developers are using glad over glew. I saw in some discussion also; developers are talking over some bugs in glew.Transcaucasia
A
27

If you're starting programming with OpenGL on a desktop platform then either one will work and the choice isn't that critical. Switching later is also still an option. The choice only becomes more important, and more objective, for advanced use cases.

Glad is typically used by selecting the necessary extensions in the web interface, downloading the generated source and header files and copying them into your project. GLEW is a library that needs to be installed and is usually added as an dependency in, e.g., CMake.

Advantages of Glad:

  • Being able to select only the extensions you use, leading to (slightly) faster compile times and initialization at runtime.
  • No additional dependency for your project.
  • Also supports the APIs OpenGL ES, EGL, GLX, and WGL.
  • Also supports the languages D, Volt, Nim and Pascal.

Advantages of GLEW:

  • Adding GLEW as a dependency to, e.g., your CMakeLists.txt is enough to make it work.
  • No large additional header and source files in your repository.
  • GLEW can detect which extensions are available at runtime.
    This allows your program to adapt to the available extensions. For example, it can select a fallback path if a certain extension is not available on older hardware.

Other OpenGL loading libraries exists as well. See here: https://www.khronos.org/opengl/wiki/OpenGL_Loading_Library

Disclaimer: The answer is based on my own (limited) experience with both libraries and reading the experiences of others.

Araucania answered 17/8, 2021 at 19:40 Comment(3)
You might want to add that glad is always for one specific version of GL, while with glew you can check what is supported and have fallback pathes for older hardware.Duet
thank you very much I learned a lot from youDena
Keep in mind that you can add GLAD as a dependency with CMake, too, so it's not an advantage specific to only GLEW. I guess it changed since the time of writing the answer.Jamima

© 2022 - 2024 — McMap. All rights reserved.