Jump to content
  • Advertisement
Sign in to follow this  
Zespider

GLFW or GLEW? Which OpenGL library should I use

This topic is 1096 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

There are a lot of libraries out there, and I would imagine their functionality is basically the same. . .

 

Being as it is that I have no experience, which one would you suggest?

Share this post


Link to post
Share on other sites
Advertisement
I'm a directX guy but touched a but of ogl too.
Glew and glfw are not mutually exclusive as their purpose is different.

Excerpt from the following page:
http://stackoverflow.com/questions/15613978/difference-of-freeglut-vs-glew

The OpenGL Extension Wrangler (GLEW) is used to access the modern OpenGL API functions(version 3.2 up to latest version).If we use an ancient version of OpenGL then we can access the OpenGL functions simply including as #include <GL/gl.h>.But in modern OpenGL, the API functions are determined at run time, not compile time. GLEW will handle the run time loading of the OpenGL API.About GLEW see here

GLFW or freeglut will allow us to create a window, and receive mouse and keyboard input in a cross-platform way. OpenGL does not handle window creation or input, so we have to use these library for handling window, keyboard, mouse, joysticks, input and other purpose.

GLFW and freeglut are alternative for us according to our need we can choose any one but GLEW is different from them which is used for run time loading of the OpenGL API.

Share this post


Link to post
Share on other sites

Yeah, you basically need 1 library to abstract the ugly wgl/glx calls and collect input (GLFW, SDL, SFML, GLUT(ancient and unsupported), FreeGLUT(oldfashioned)), another to load the function pointers (glad, glloadgen, GL3W, GLEW, GLee, ...) where the newer ones allow you to generate their C code tuned to your needs (choose GL version, core/compatibility and which extensions to avoid always loading a thousand functions and extensions you never use).

http://www.glfw.org/faq.html#why-doesnt-your-glh-have-the-functions-i-need

Edited by wintertime

Share this post


Link to post
Share on other sites

See also this recent, similar question.

 

In summary, GLFW is what its name says ("GL Frame Work"), a framework. That is, it enforces a kind of structure on your program. Rather than deciding what to do when, you call some initialization functions and tell the framework more or less what you expect, and then the framework calls you back at the appropriate times (for example when the user presses a key or moves the mouse, resizes the window). All you need to do is write handlers for that, the logic behind it is already written. In addition, GLFW comes with a set of useful utility functions. You still write GL code to do the drawing, though.

 

GLEW on the other hand handles the loading of extensions ("GL Extension Wrangler"). What does that mean? Unlike another well-known graphics API from Microsoft, OpenGL does not come as a set of distinct, entirely different, incompatible versions with different libraries which on the other hand have exactly defined functionality and specs. Instead, OpenGL is a somewhat blurry "everything at the same time, and none" and built in an extendable and heavily extended manner, which is not at all obvious or intuitive to a beginner.

In addition to the base functionality, you can use extensions, if they are supported (there are well over 300 extensions, and the average graphics card driver supports well over a hundred). Additionally, all versions after 1.2 technically work as-if extensions. That is, you cannot just link with opengl32.dll and expect that everything will magically work for OpenGL 3.0 or OpenGL 4.4.

 

Instead, after creating a context (GLFW will do that for you!) you need to query your context for the supported version and for supported extensions that you may wish to use. Then you must set up a lot of function pointers and initialize them. This is a lot of nasty and error-prone work even for someone reasonably experienced, lest a beginner.

 

GLEW does all that.

 

So basically, with GLEW, you call one function to init everything, and then you can very comfortably check what you have available, and use it right away... without having to deal with that nasty stuff.

 

To answer the question "Which one should I use?" -- in any case you want to use GLEW (or an alternative, but GLEW works fine), but you most likely want to use both GLEW and GLFW since it makes your life easier.

Edited by samoth

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!