In 2018, I first came into contact with computer graphics. Until now, I still clearly remember the joy of drawing the first triangle with C++ for the first time. Times flies away.
I’ve been exposed to more graphics APIs like OpenGL, WebGL, DirectX, Vulkan. As more APIs are called, the adoption of a more profound understanding of computer graphics. Just taking advantage of this year’s holiday, I came up with a new idea. I intend to realize soft rendering from scratch, do not rely on the current graphics API, use pure C++, calculate on the CPU, and find the joy of drawing triangles again. Starting from the simplest mathematical class, I will imitate the rendering pipeline of OpenGL and implement it step by step.
At present, my plan is divided into two parts. The first part is 2D-related, and the second part is 3D-related. I want to focus on 2D first because there are many basic contents in 2D, such as the drawing of various 2D graphics, the filling of colors, the modification of line type and line width, and the geometric constraints of graphics (I intend to implement it with a population intelligence algorithm called harmony search algorithm to constrain the relationship of graphics)
Then there is the 3D part, which will introduce the MVP matrix to make the graphics move and add lighting, materials, shadows, etc. Finally, I also asked myself to implement a model class. Using this class, we can load various models made by others, For example, Utah teapot (the first model I try to import is Utah teapot, because the University of Utah is my graduate school, hahaha :) )
OK, let’s look at the final result—first, the 2D.
Then, the 3D.