Tips for programming easily-Portable OpenGL 3.3 code?

I’m writing shaders and cpu code in C++ and OpenGL, targetting version 3.3

I’m avoiding GLUT, using GLFW because I think it has better linux compatibility

I’m not targetting smartphones or embedded systems, but it’d be nice to be able to recompile my OpenGL programs and have them work on linux


GLUT and GLFW both work fine on Linux.

For building, use CMake, which supports Linux, Windows, and others without any mods needed on your part.

As far as GL, once you have a context/window created, it pretty much works the same on both.

Your platform differences are more likely to be in other areas like file I/O and threading. However, that’s easily avoided by using standard libraries that work well cross-platform.

Test frequently on multiple platforms.

I was mainly concerned about the GL stuff, heard rumors that ATI cards like to throw tantrums with opengl shader code and failing to unbind/disable everything that gets bound/enabled

Thank you again, Dark Photon!

I have always and will always appreciate your contribution!

That’s a good point. I should qualify my statement with the fact that my experience is almost completely with NVidia’s GPUs and proprietary GL drivers. I’ve been spoiled by their GL driver quality and consistency across Linux and Windows for over 16 years doing GL development 5 days a week.

If you’re going to be choosing a new GPU, I’d do some careful research to see which of the latest GL drivers meet your needs. I can only vouch for NVidia’s.

Hopefully someone else here with recent AMD GPU+GL driver experience on Linux will chime in with more info there. I do know that with AMD there are both AMD proprietary and open-source driver options (for instance, one post of many on that: AMD Catalyst vs. AMDGPU-PRO - Which one is better?).