The title is a bit misleading, this is boilerplate code for a graphics programming course and it hasn't got much to do with OpenGL.
The articles describing the operation are much more interesting than the code itself.
It's just an inefficient triangle rasterizer. All it does is loop over the pixels in a rectangle covering a triangle, and for each pixel inside it calls a "shader" function. All the beef is in these 40 lines [0].
I don't know how they've done the texturing in all those pretty pictures (it's in the "shaders", not included here), but they don't calculate the partial derivatives required for correct, mipmapped texturing. Simple non-mipmapped perspective correct texture mapping can be computed in the shaders, with the usual caveats.
OpenGL is much more than a rasterizer, there's texturing, depth-stencil operations, blending, compute shaders and efficient memory management.
edit: Someone in reddit pointed out that this is a translation of a Russian language course. The original Russian version looks to be a bit longer than the English translation (but I don't read Russian, so I can't tell if it is better): https://habrahabr.ru/post/249467/
Yes, I did and that's much more interesting than the code itself. But the title is still misleading and emphasizes the code, which isn't terribly spectacular.
> It's just an inefficient triangle rasterizer. All it does is loop over the pixels in a rectangle covering a triangle, and for each pixel inside it calls a "shader" function.
99% of programmers without graphics training would not come up with the barycentric coordinates solution when asked how to draw triangles (including me, before I learned about it). Even if the code were nothing but that, it'd be extremely educational.
The point of this course is obviously not to teach graphics gurus how mipmapping or anisotropy or whatever works. That would be an interesting series of lessons (albeit one with a much narrower audience), but it's not what this tutorial is about.
Nobody complains that showing absolute beginners their first "hello world" program isn't valuable because they aren't teaching them about Unix file descriptors or the concept of a syscall.
Jeez. This repo clearly isn't for someone like you, it would be much more educational for someone who doesn't know much about how this stuff works under the hood.
Creating a dead-simple software rasterizer goes a long way toward improving one's understanding of how apis like OpenGL and DirectX work and how to use them.
The articles describing the operation are much more interesting than the code itself.
It's just an inefficient triangle rasterizer. All it does is loop over the pixels in a rectangle covering a triangle, and for each pixel inside it calls a "shader" function. All the beef is in these 40 lines [0].
I don't know how they've done the texturing in all those pretty pictures (it's in the "shaders", not included here), but they don't calculate the partial derivatives required for correct, mipmapped texturing. Simple non-mipmapped perspective correct texture mapping can be computed in the shaders, with the usual caveats.
OpenGL is much more than a rasterizer, there's texturing, depth-stencil operations, blending, compute shaders and efficient memory management.
[0] https://github.com/ssloy/tinyrenderer/blob/master/our_gl.cpp...
edit: Someone in reddit pointed out that this is a translation of a Russian language course. The original Russian version looks to be a bit longer than the English translation (but I don't read Russian, so I can't tell if it is better): https://habrahabr.ru/post/249467/