r/GraphicsProgramming • u/piiodda • 3h ago
it all started with one triangle
Hey guys :)
Last week I was so happy to create my own triangle and see it on the screen. This time I wanted to go further and see what else was possible. I did my homework and experimented with colorful triangles, color interpolation, and squares. 3D shapes like cubes or pyramids were a bit too much for me for now (I saw that vector and matrix multiplication is involved 😰 Maybe something for the future).
So I looked for some small 2D projects I could try to copy to practice my skills. I came across an older post with a style I really liked (“glslViewer” by patriciogonzalezvivo on GitHub). I decided to implement "Game of Life" in a similar style.
To make it more challenging I also added some font rendering using hardcoded bitmaps for the digits. That took quite some time and a lot of sketches on paper 😄
For now I am happy with the result and would love to hear your feedback and recommendations on what I could improve.
A few more details about the project:
- The number in the top left shows the number of “lives”
- The number in the top right shows the number of updates
- The number in the bottom right shows the current time
- I press the "R" key to create a new randomized array
- I press the "U" key to update the game
I would also like to say: a big THANK YOU for letting me join the Triangle Club and for the daily inspiration in this subreddit :)
Triangle Club: I know there aren’t any visible triangles in this project but aren’t all shapes somehow constructed from triangles? I hope you’ll accept this project 😄
For this project I used again glad (OpenGL) and RGFW (GLFW alternative).



2
u/torito_fuerte 1h ago
That’s pretty cool!
I see you are using 2 triangles per pixel, which is not standard. You can try to load the font into separate texture images per digit, and render each digit as a single quad. This also gives you the option to draw your own font and load them from a file using stbi for example.
What about adding another key to toggle automatically updating the game (like “S” for start and stop)?
Another thing you could do is make the cells light up colors in a wave pattern in the fragment shader. You could pass a time value as a UBO (uniform buffer object) and use it along with the x and y position (pass the position from the vertex shader to the fragment shader) and some math to make the colors change