Announcing juce-glbinding


Hi all,

I want to share my Juce patchset with you, which allows using the modern OpenGL APIs on all platforms:

It is a simple set of changes which for the most part omits system GL header inclusion, fixes some type consistency issues here and there, and uses the glbinding library also for the OpenGL calls made inside Juce. I will try to keep this updated as soon as new Juce releases come out, or maybe I won't even need to since upstream decides they want to integrate this.

If you want to give it a try:

  • Install the glbinding library:¬†
  • Add glbinding to your linked libraries
  • Set the JUCE_GLBINDING preprocessor define for your project / platform
  • Call glbinding::Binding::initialize() once before doing any OpenGL calls

Then, wherever you use OpenGL functions, you can import the glbinding symbols into the global namespace if you want:

using namespace gl;

If you want to make sure your software runs with a specific OpenGL version, glbinding provides respective headers which you can include. To only make use of OpenGL functionality up to 3.3 for example, you can include version-specific headers like this:

#include <glbinding/gl/functions33.h>
#include <glbinding/Binding.h>
using namespace gl33;

I will be glad if people give this some testing in order to make it more robust. For me it works fine for the time being. Just create issues on GitHub or send me pull requests, this is supposed to be very open for contribution.

Hope this will be of use to some of you!





This is certainly useful.  Did you look into whether it would be possible to integrate the glbinding library directly into the module?  


Sounds interesting!


I'm not sure I understand exactly. As said, Juce internally now makes use of glbinding for all GL calls. The side-effect is that everything (inside the Juce OpenGL module) is now nice and typesafe, since glbinding provides a typesafe API by e.g. using C++11 strongly-typed enums for all the constants instead of preprocessor defines. There were some minor fixes and casts which needed to be done, but nothing dramatic.

However it has saved myself quite a lot times from errors in my own code. One typical mistake I sometimes make is e.g. passing as the target parameter to glTexParameter not the actual target enum such as GL_TEXTURE_2D, but accidentally a texture id directly. While I had oftentimes find this mistake the hard way, glbinding will complain since GLenum != GLuint etc.

If you refer to the header inclusion, they *should* actually be included if you just include the Juce header, haven't tested this yet. Oh yes they are, so fine. Still if you want to make use of the version-restricted namespace (as I do in my code) you will have to do the include yourself obviously, before the Juce header inclusion.



[moved to appropriate forum section]


Regarding the necessity to include the headers. I erronously had a using namespace gl in juce_opengl.h. That one in now removed, so you don't need to include the glbinding headers yourself, however the symbols are defined in the gl namespace. You will have to add a using directive to client code if you want it in the global namespace. It is now actually possible to make use of the versioned glbinding includes.  Updated the initial post accordingly.