OpenGL on Linux

Hi guys,

I’ve known about JUCE for a while, but have shied away from it till now due to lack of Linux support. Needless to say, I was fairly well excited when I recently found out the library had gained both Linux and OpenGL support. However, I quickly discovered that OpenGL was unfortunately not available under Linux yet.

There were a few stumbling points, since I’ve never even used JUCE before, let alone worked on its internals, but after a couple nights of hacking around I got OpenGL support added for Linux. It’s still a little bit sloppy, but I’ve tried to model it as much after the other versions as possible. Since NativeDesktopWindow::getNativeHandle() doesn’t actually return a native X Window handle, but a pointer to an internal structure defined by the Linux layer of JUCE, I add a juce_linux_Windowing.h file, but other than that things were fairly smooth.

The patch for juce_1_10.zip is currently available from http://www.omphaloscoil.org/~noah/juce_linux_opengl.patch.bz2. To apply it, enter into your juce directory and execute bunzip2 -c /path/to/juce_linux_opengl.patch.bz2 | patch -p1 and then just run make from build/linux.

Hopefully I can stay motivated and work on more nice stuff for JUCE on Linux (Xinerama awareness, COMPOSITE extension support, etc.) It is a really nice library, but can still be even better :slight_smile:

Let me know if anyone finds this patch useful, has comments, suggestions, etc.

noah

Wow!

Welcome!

wow… I’ve just downloaded your stuff, haven’t looked at it yet (I need to reboot into linux for that).

What I was thinking of doing anyway was reorganising all my ogl code, so that the juce_OpenGLComponent.cpp doesn’t have any native calls in it, and pushing all that stuff into the 3 platform-specific juce_x_windowing.cpp files.

So if you don’t mind, I’ll probably have a look at how you’ve done it to see what the equivalent linux calls/includes are, and then try to get the whole thing looking a bit more tidy.

Nice work, though - oh, and welcome to the forum!

I just wanted to ping to see if there was any update on OpenGL support in Linux since this thread was originally posted. Has the patch above been ported to juce-1.18?

…hard to remember that far back, but I’m sure it’s all working now.

I looked in the sources and it looked like the code was there, but the juce_demo doesn’t include the OpenGL demo. I thought that was because the OpenGL code wasn’t working yet for Linux. I’ll see if I can get the juce_demo to include it. I guess its just been #defined out somewhere?

thanks,
Barry

The demo does include it, but you’d have to #define it in the juce_Config.h file.

Ah yes. I found the ‘#define JUCE_OPENGL 1’ to uncomment and everything worked fine. I feel a little stupid now, but I didn’t know I needed to do anything special to enable Opengl support.

Thanks for the tip!

Barry

I just leave it turned off by default because a lot of linux people won’t have the opengl libraries installed