top of page
Search
Writer's pictureFox Forge

2D Rasterizer | C++

Updated: Apr 25

One of my first pieces of work related to graphics was to build a small 2D rasterizer. This involved learning the algorithms behind how the pixels are draw on screen and how they are made efficient enough to draw and fill shapes covering the entire screen.


The specification given for the task was to demonstrate the ability to draw and fill circles and polygons (both convex and concave), with a variety of line patterns and thickness. All of which had to be made within some type of rasterizer. Additionally, the top marks were awarded for colour blending with both RGB values and Alpha values.



As in demo above, my solution for this project staged each part of the assignment into different sections which can be toggled through in the executable using the keys F1 - F8. I used the mouse position as a continuous line draw from the centre of the screen, alongside drawing and filling the rest of the shapes. In short, my implementation used a Bresenham line drawing algorithm and a Scanline algorithm to achieve the results - coupled with some mathematics for colour interpolation and line patterns.


Further improvements could be made to the project with dynamic clipping, depth buffer and Anti-aliasing, which is something I would like to look at in the future. For now, the source is on my github and is well commented if you are interested to see more! Alternatively the executable are also there, if you want to try it out for yourself!

55 views0 comments

Commentaires


bottom of page