Examples

February 18, 2026 ยท View on GitHub

Different collections of sample programs, some original, lots of ports. Also I shamelessly borrowed the table format and organization from the excellent raylib library I can only aspire to raylib's polish.

Building

They all require SDL2 to be installed to build.

On Debian/Ubuntu based distributions you can install SDL2 using the following command:

sudo apt install libsdl2-dev

On Mac you can download the DMG file from their releases page or install it through a package manager like Homebrew, MacPorts, or Fink. Note, I do not own a mac and have never tested PortableGL on one. Worst case, you can always just compile SDL2 from source but one of the above options should work.

On Windows you can grab the zip you want from the same releases page linked above.

I use premake generated makefiles that I include in the repo which I use on Linux. I have used these same Makefiles to build under MSYS2 on Windows. However, at least for now, even though PortableGL and all the examples and demos are cross platform, I don't officially support building them on other platforms. I've thought about removing the premake scripts from the repo entirely and just leaving the Makefiles to make that clearer but decided not to for the benefit of those who want to modify it for themselves to handle different platforms and build systems. For now the win32 backend examples will have to suffice.

Once you have SDL2 installed you should be able to cd into each subdirectory and run make or make config=release for optimized builds. make verbose=1 will let you see all the build steps. You can run make help to see all the individual targets.

Original Custom Examples

The exercises are a small collection demonstrating the basics in C and C++ and how to use the built in shader library. The C++ versions use own rsw_math rather than glm like most of the other C++ examples. The rest are just whatever makes its way over here from demos as I polish them up.

exampleimagelast version
updated
original
developer
ex1.cex10.100.0Robert Winkler
ex2.cex20.100.0Robert Winkler
ex3.cex30.100.0Robert Winkler
ex1.cppex1_cpp0.100.0Robert Winkler
ex2.cppex2_cpp0.100.0Robert Winkler
ex3.cppex3_cpp0.100.0Robert Winkler
ex1_std_shaders.cex1_std_shaders0.100.0Robert Winkler
ex2_std_shaders.cex2_std_shaders0.100.0Robert Winkler

Classic Ports

Ports of classic OpenGL programs/demos

exampleimagelast version
updated
original
developer
gearsgears0.100.0Robert Winkler

Learning WebGL ports

Ports of lessons from learningwebgl.com based off of my own ports to OpenGL 3.3 here.

exampleimagelast version
updated
original
developer
lesson1lesson10.100.0Robert Winkler
lesson2lesson20.100.0Robert Winkler
lesson3lesson30.100.0Robert Winkler
lesson4lesson40.100.0Robert Winkler
lesson5lesson50.100.0Robert Winkler
lesson6lesson60.100.0Robert Winkler
lesson7lesson70.100.0Robert Winkler
lesson8lesson80.100.0Robert Winkler
lesson9lesson90.100.0Robert Winkler
lesson10lesson100.100.0Robert Winkler
lesson11lesson110.100.0Robert Winkler
lesson12lesson120.100.0Robert Winkler
lesson13lesson130.100.0Robert Winkler
lesson14lesson140.100.0Robert Winkler
lesson15lesson150.100.0Robert Winkler
lesson16lesson160.100.0Robert Winkler

Learn OpenGL ports

Ports of learnopengl.com tutorial code here.

These are probably the cleanest and most polished examples because they were already OpenGL 3.3 so the porting process was relatively easy with minimal changes necessary.

The project is too large to include here and works best as a separate repo anyway. I've currently ported the first 4 chapters worth, or about 56 programs out out of a total of about 97 programs over 8 chapters. It's mostly stalled there until PGL officially adds certain features like more texture formats, FBOs, etc. I've included a few below as a sampling.

exampleimagelast version
updated
original
developer
spotlightspotlight0.100.0Robert Winkler
model_loadingbackpack_model0.100.0Robert Winkler
depth_testing_viewdepth_testing_view0.100.0Robert Winkler
stencil_testingstencil_testing0.100.0Robert Winkler
blending_discardblending_discard0.100.0Robert Winkler
blending_sortedblending_sorted0.100.0Robert Winkler