r/GraphicsProgramming • u/jmacey • Oct 15 '25
Choose your first triangle.
Just updating my lectures for the new year. Have decided to allow any graphics api that works on our Linux lab machines. Just got python first triangles for OpenGL core profile. WebGPU and Vulkan.
Think Iβm going to recommend either OpenGL for ease or WebGPU for more modern. I find Vulkan hard work.
3
u/fgennari Oct 16 '25
They're all wrong. Everyone knows that red should be to the lower right and blue should be on the top!
Seriously though, do you really get different vertex colors with the three APIs?
3
u/jmacey Oct 16 '25 edited Oct 16 '25
good spot, I forgot that the projection differs between the API's I have now fixed this.
2
u/joaobapt Oct 16 '25
What about Metal? Youβre on macOS!
2
u/jmacey Oct 16 '25
I have metal version at home, however as this is for teaching I only use API's that work on my lab machines (RHEL 9.5 Linux).
2
1
u/Daneel_Trevize Oct 15 '25
Write it once and get all 3 via SDL3, including across OSs and hardware platforms that include consoles & handhelds.
1
u/jmacey Oct 16 '25
They are all using PySide6 (as this is part of the Vfx Reference platform we use in other things). For the OpenGL it uses the QOpenGLWindow for Vulkan and WebGPU I basically blit a numpy buffer to the screen via QImage.
1
u/sputwiler Oct 15 '25
I don't think SDL_GPU supports OpenGL or WebGPU since it aims to support modern native APIs (Vulkan, DX12, and Metal), and is itself an alternative to WebGPU.
1
u/Daneel_Trevize Oct 16 '25
You don't need SDL_GPU for a hardware-accelerated textured polygon though, the Render API has that covered & has drivers for all those backends AFAIK.
1
1
1
12
Oct 15 '25
[removed] β view removed comment
3
u/jmacey Oct 15 '25
Global State machine is also nice to have rather than having to create your own. This is why I quite like WebGPU as it's a nice half way.
4
u/sputwiler Oct 15 '25
What's different about 4.6? I was under the impression that once you hit OpenGL 3.3 Core that everything's pretty much the same just with more features each version until you get to the final 4.6. Since I don't need a lot, I was sticking to 3.3 in order to run on old hardware I have (and Macs). I thought the state machine was still present unless you went with Vulkan.
1
u/corysama Oct 15 '25
Direct State Access is very nice.
glVertexArrayVertexBuffers makes swapping out the buffers associated with a VAO cheap. So, VAO become vertex format specifiers without being so tied to specific buffers.
https://gl.uplinklabs.net/gl4/glMultiDrawElementsIndirectCount is the final boss of draw calls. It enables compute-shader-driven draws.
4
Oct 15 '25
[removed] β view removed comment
2
Oct 15 '25
[removed] β view removed comment
2
u/jmacey Oct 16 '25
unfortunately mac also peaked at OpenGL 4.1 (with the odd 4.2 bit in it). There are a few wrappers but too much hassle to use.
2
u/sputwiler Oct 15 '25
AFAIK my Intel HD 4000 maxes out at 4.1 and mesa can eke out some 4.2 features IIRC. However, mesa also implemented Vulkan 1.0 with missing features on top of an HD 4000 so maybe.
Hilariously, that means the vkd3d dx12 demos run on this GPU that never supported DX12.
16
u/Sosowski Oct 15 '25
My first triangle was Glide, but nobody remembers this anymore.