odin run .Sample project for experimenting with Odin and OpenGL.
This code implements a simple 3D N-Body simulation, running on GPU and visualized with OpenGL.
Every body is a simple OpenGL point. Their coordinates and velocities are stored using SSBO (Shader Storage Buffer Objects), and we compute a basic densities for coloring purposes.
The resources/cs/update.glsl file implements the simulation in a compute shader.
There's 3 different initialization compute shaders :
resources/cs/uniform_spheres.glsl: 2 uniform spheres. The very beginning has quite a lot of artifacts, but it quickly becomes a beautiful galaxy danceresources/cs/uniform_sphere.glsl: 1 uniform sphere. Much less interestingresources/cs/plummer_sphere.glsl: A plummer sphere. I find the points are too scatered, hence a lot of the compute capacity is wasted on useless points.
The visualization is done with the Instancing paradigm, meaning we only have one draw call. Each draw call has it's id (which corresponds to a body id) that we'll use in the compute shader. In fact, there's even no meshes at all, since the bodies are simple OpenGL points. This does not affect the visualization, but saves computation power that we want to use to have as many bodies as we can.
The test folder is just a sample of how Odin manages it's unit tests. Testing OpenGL seems like a nightmare anyway.
- Odin compiler
- GLFW :
sudo apt install libglfw3-dev
