I wrote a software implementation of OpenGL with the only goal of being able to play Quake3 using it. I can vouch that it is an amazing learning experience. The tutorial here doesnt seem to aproach the issues of performance however, which really are another learning experience entirely.
How OpenGL works: software renderer in 500 lines of code
11–20 of 37 posts
Re: How OpenGL works: software renderer in 500 lines of code
#12Re: How OpenGL works: software renderer in 500 lines of code
#13The 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/
Re: How OpenGL works: software renderer in 500 lines of code
#14Another good example of this is Trenki's software renderer for the GPX2[1], which implements a shader architecture if memory serves. I haven't looked at it for many years, but I remember it being a useful resource when learning this stuff.
Other useful resources are, of course, Michael Abrash's Graphics Programming Black Book[2] (despite it's age, is still a great read filled with useful information), and for a really deep dive into the graphic's pipeline, ryg's (of Farbrausch fame) A Trip Through the Graphics Pipeline[3].
[1] http://www.trenki.net/content/view/18/38/
[2] https://github.com/jagregory/abrash-black-book
[3] https://fgiesen.wordpress.com/2011/07/09/a-trip-through-the-...
Re: How OpenGL works: software renderer in 500 lines of code
#15Thank you for posting this online.
Re: How OpenGL works: software renderer in 500 lines of code
#16The 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…
Re: How OpenGL works: software renderer in 500 lines of code
#17I wrote a software implementation of OpenGL with the only goal of being able to play Quake3 using it. I can vouch that it is an amazing learning experience. The tutorial here doesnt seem to aproach the issues of performance however, which really are another learning experience entirely.
Holy crap. If you could reimplement OpenGL you should be able to buy a video card. I think I had a tnt2 Ultra back then.
Re: How OpenGL works: software renderer in 500 lines of code
#18https://fgiesen.wordpress.com/2013/02/17/optimizing-sw-occlu...
Re: How OpenGL works: software renderer in 500 lines of code
#19The 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…
You need to look through the short course notes in the wiki of the page to understand the full quality of this repository.