OpenGL for Linux and MacOSX?

Started by
9 comments, last by Neosettler 11 years, 4 months ago
Hello OpenGL gurus,

I’ve been developing with OpenGL exclusively on Windows for several years now and I’m entering the cross-platform compiling world.

So far, I use skaslev-gl3w https://github.com/skaslev/gl3w to generate gl3w.h, gl3.h and gl3w.c. I found OpenGL32.lib within Visual Studio… it’s a wonderful world indeed… but when compiling with g++ on Linux, gl3w.c is requesting glx.h… and cough at glXGetProcAddress... Oups! There is no trace of this file on opengl.org and Googling on this topic is rather confusing so I decide to ask here.

1 - Why GLX? I thought pure GL was king on Linux... I'm confuse! (I surely dont want to rewrite my code)

2 - Where to find the official OpenGL package to develop on Linux and MacOSX?

Thx
Advertisement
I can't answer about MaC OS X, it's been too many years for me. Linux isn't an OS so there's no definitive answer there, but I can tell you about Debian-derived OSes (like Ubuntu), which are GNU-based OSes that can sometimes use the Linux kernel: try installing the libgl1-mesa-dev package. If you're asking about Android, another common OS that uses the Linux kernel, the GLES libraries should come with your devkit.

The answer to why your third-party software (skaslev-gl3w) uses GLX, well, you'd have to ask whoever developed it, but it's a handy and standard way to create a GL context on an X11 server.

Stephen M. Webb
Professional Free Software Developer

Thank you Bregma,

Your answer almost gave me a heart attack. For all the porting a need to do, I thought OpenGL would be a breeze.

I’m currently working with CentOS/Redhat and I tried yum install libgl1-mesa-dev but the package is not found. So I’m guessing there’s extra steps to be made.

I simply need a pure OpenGL context 4.x, no extra lib, no fancy stuff, only the core… I’d really appreciate if anyone could help clear this up.

Thx again
On MacOSX read this about how OpenGL development works there: http://www.geeks3d.com/20121109/overview-of-opengl-support-on-os-x/
On CentOS/RHEL, you're probably after the mesa-libGL-devel package. :)

http://rpm.pbone.net/index.php3/stat/4/idpl/17834939/dir/centos_5/com/mesa-libGL-devel-6.5.1-7.10.el5.i386.rpm.html
Tom Lee -- http://tomlee.co

I simply need a pure OpenGL context 4.x, no extra lib, no fancy stuff, only the core… I’d really appreciate if anyone could help clear this up.

Problems is there's not really such as thing as a pure OpenGL context. You're going to need something to draw to.

Even if you're going full screen, you're not directly programming the GPU and you're not driving the video output chips, you need to go through the OS kernel. A typical modern OS kernel is design to prevent you from getting at the hardware directly: you need to ask it nicely at the very least if it will do you the favour of accessing the hardware on your behalf. On a GNU/Linux system, that means getting the X11 server to share nicely. On Mac OS X that means getting the Quartz service to share nicely. Even on Microsoft Windows you need to share nicely with other applications calling into the embedded display service. On Android you use EGL to share the flinger nicely.

There are cross-platform libraries that will get you an OpenGL context. That's what they're for and why they're there. SDL, for example, works very well on all the above platforms. If you insist on doing without such a library, the source is free so you can see how it works and reimplement it yourself. Of course, it might turn out SDL uses glx/wgl/egl underneath, because to do otherwise would reimplement all those ioctl/X11/port/SYS calls. Might be worth checking, though, or even just using the library directly.

Stephen M. Webb
Professional Free Software Developer

The closest you can get to a "pure" OpenGL rendering context on X11 is by just using the X11 library itself.
Some of the older OpenGL books go into this but unfortunately it is becoming a bit of a lost art in the newer literature.

A good example is http://content.gpwiki.org/index.php/OpenGL:Tutorials:Setting_up_OpenGL_on_X11
As you can see, this uses GLX (which is what provides the rendering context).

Some more typical rendering contexts include...

glut
wxGLWidget (wxWidgets)
QtOpenGL (Qt)
Gtkglext (Gtk)
SDL

Personally, even though I am a C++ developer, I still highly recommend Glut. It is really portable and is already installed on most Linux distros. The 100% free implementation is called FreeGlut.
http://tinyurl.com/shewonyay - Thanks so much for those who voted on my GF's Competition Cosplay Entry for Cosplayzine. She won! I owe you all beers :)

Mutiny - Open-source C++ Unity re-implementation.
Defile of Eden 2 - FreeBSD and OpenBSD binaries of our latest game.
I use SDL and OpenGL for my game. I found porting my game from windows to Linux was a breeze I didn't even need to edit any code and the computer seemed to have all the files I needed. As far as I know there is no such thing as "pure" OpenGL you will always need some way to window it. I also find using Glew helps but to each his own.
If you want something portable that gives you only the OpenGL context, and nothing more, then I recommend glfw. Well, it gives you a little more, like interface to I/O (e.g. mouse, keyboard). In my opinion, glfw is a stronger and cleaner library than glut.
[size=2]Current project: Ephenation.
[size=2]Sharing OpenGL experiences: http://ephenationopengl.blogspot.com/

Thank you Bregma,

Your answer almost gave me a heart attack. For all the porting a need to do, I thought OpenGL would be a breeze.


Note though that all these libraries are only for setting up the GL context and getting a window to draw in, and some input (and possibly a few utility functions)

Those of course have to be OS specific.

All the actual rendering is the same standard OpenGL, as long as you use the same profile, so no need for heart attacks :)

(some drivers might have bugs, or allow some invalid behaviour that breaks on other drivers, but that is a separate story... )

This topic is closed to new replies.

Advertisement