I’ve just added an OpenGL C++ repository over at bitbucket, and the first C++ demo is an enhanced port of the attraction based compute shader system from my last post.
Sources : https://bitbucket.org/saschawillems/opengl-c
Compiled win32 binaries : https://bitbucket.org/saschawillems/opengl-c/downloads/computeShaderParticleSystem_win32_bin.zip
Compared to the Delphi version, the C++ version uses point sprites (instead of smoothed GL_POINTS), has a random color fade and allows for several user inputs :
Note : This demo requires at least OpenGL 4.3!
- r: reset particles at current cursor pos
- p: Toggle pause
- b: toggle viewport border for particle movement
- c: toggle random color fade
- +: increase speed
- -: decrease speed
- page up: increase particle count by 1024
- page down: decrease particle count by 1024
Next on my list of new OpenGL functionality are compute shaders. They’ve been introduced into the GL core with 4.3, and pretty much allow you to do GPGPU directly in OpenGL without having to resolve to other APIs like OpenCL.
So my first compute shader demo implements a (simple) attraction based particle system. It generates two shader storage buffer objects (SSBOs). One for particle positions and one for particle velocities, and the compute shader then accesses these SSBOs to calculate particle velocities depending on an attraction point (in this demo it’s the mouse cursor) and accordingly updates the particle positions. So the whole particle system gets caclulated on the GPU, which should be a lot faster than doing it on a GPU.
Some screenshots, though they don’t do it any justice as the particle system is so dynamic and looks much better in motion :
You can grab the complete (Delphi) source from my bitbucket repository.
I’ve just been playing around with GL_ARB_debug_output, a new extension introduced with OpenGL 4.3. This extension adds debugging capabilities to OpenGL, e.g. allowing you to have a callback fired by the OpenGL implementation that’ll inform you upon errors or even (heavily depending on the IHV) gives performance hints.
I wrote a small sample (in Delphi) that demonstrates this new functionality. It creates an OpenGL 4.3 forward compatible context (no more legacy stuff) with debugging capabilites and displays debug messages from your OpenGL driver.
It’s a pretty neat feature, and something that OpenGL has been missing for a long time. So from now on, instead of having to poll via glError, you can have the driver inform you when something is not correct and (even better) tell you about your performance caveats.
You can grab the source from the gldebug folder in my GIT repository over at bitbucket. I plan on adding OpenGL demos (with source) for some of the newer OpenGL features to that repository from time to time.