How difficult is OpenGL? How difficult can it be if you can build a basic renderer in 500 lines of code? That’s what [Dmitry] did as part of a series of tiny applications. The renderer is part of a course and the line limit is to allow students to build their own rendering software. [Dmitry] feels that you can’t write efficient code for things like OpenGL without understanding how they work first.
For educational purposes, the system uses few external dependencies. Students get a class that can work with TGA format files and a way to set the color of one pixel. The rest of the renderer is up to the student guided by nine lessons ranging from Bresenham’s algorithm to ambient occlusion. One of the last lessons switches gears to OpenGL so you can see how it all applies.
As you might expect, if all you have is a call to set a pixel color, you have a lot of work in front of you. This probably isn’t for everyone, but if you’ve ever wanted to understand vertex shading, back-face culling, and tangent space normal mapping, this is the ticket. There is even work towards benchmarking different algorithms for things like line drawing, which is invaluable if you want to write efficient code.
We noticed [Dmitry] also did a 500-line ray tracer and why not? We’ve even seen that trick pulled off mostly in Excel. While the graphics stack is made to be educational, it makes us think of the small hardware that might be able to use an OpenGL stack.