Juce OpenGL and Glew

I am sure many of you have seen these issues when you used OpenGL with Juce. I am trying to use a third party library that depends on OpenGL, but then Juce includes its own OpenGL headers, and Glew is complaining that the headers are already included from elsewhere. But if I include Glew.h first, then Juce complains that other OpenGL headers are already included. So what is the solution here? Has anyone ever been able to resolve this? Or really the only solution is to forget about Juce OpenGL completely when using third party libs? I’ve been looking for an answer high and low but even in this forum, people just respond that “thanks it works now”, but no one is explaining how they solved it. Is this some sort of secret, do I have to pay for Juce to get answers to these questions?

What do you need from GLEW that isn’t present in JUCE itself? I thought the main purpose of GLEW was to load the OpenGL functions for a particular OpenGL version, but JUCE already handles this. The loaded functions and symbols end up in juce::gl, so you can do using namespace juce::gl if you want to omit the namespace prefix.

It was not particularly Glew that I needed, I was trying to add the assimp library so that I could import 3D objects. Assimp and all the convenience extensions that come with it require Glew. I wanted to have a solution that not only loads the items but also displays them. But then I realised that I can’t replace juce::gl with something else, because I would also lose the juce openGLcontext that is used elsewhere by my 2D drawing functions.
So now I’m back to WavefrontObjParser, trying to figure out proper texture mapping, as the samples provided with Juce are only loading Obj files halfway, they skip the textures and other material properties. The parser loads all of them, but the demos don’t use them. I haven’t touched OpenGL since 1.4 so I’m having a lot of fun.

I was able to use Assimp without any issues with JUCE OpenGL. I used vckpkg to install it.

I tried to use examples provided by ogldev, that not just load the models, but also display them. To use those convenience libraries either I rewrite them to use juce::gl, or I don’t use juce::gl at all. Those load any models and sort out materials and textures too. I did not know at first how much it would have involved to rewrite their stuff for juce::gl, since it is not just a simple C++ refactoring exercise. OpenGL is a C-like state machine, I can’t start fiddling around with #defines, etc, because I could break something. So I decided to leave it.
Assimp by itself is not a problem for me either, I added it via CPM-Cmake.

I’ve got decent progress on a scene graph implementation that imports models with Assimp, and loads textures via JUCE images and a modified versions of JUCE’s OpenGLTexture class that adds functionality I needed. Almost a mini game engine of sorts, but that’s not really the intention, so nothing like physics etc. I’ve got a lot of features working: background thread asset loading, shadows, directional, point, and spot lights, skybox, post processing, input handling, etc. This is all inside a JUCE component for rendering and also able to overlay JUCE components on top for UI.

It’s not trivial to set all of that up, but certainly can be done.

What’s your end goal are you just trying to do basic model viewing?

Hi, my end goal is just to display a static 3D scene, something similar that MacOS shows us in the speaker layout dialog, but a nice one. I am also progressing with JUCE’s own classes, and I am sticking to the WavefrontObjParser for now, and rewriting OpenGLUtil.

(Ok, this last bit is not Juce or coding related…)
Currently I am experiencing issues that are not related to my code, I am unable to export .OBJ files from C4D that have their textures properly assigned. At first I tried some free models just to realise that they are missing textures, so I went into C4D to assign textures myself. But even after that, somehow the textures are not associated with the meshes the way they should be. My textures seems to be correct in the obj/mtl files, but they don’t show at all, neither in my app, nor in the F3D utility. Until I have a scene that I know that it has proper textures, I can’t progress with my code.