Rasterizer Project - Part 3: Geometry
dev.to·14h·
Discuss: DEV
Flag this post

So lets create a geomtry.h so we can actually calculate the 3d math we need for our rasterizer to work.

Lets start with this struct. This is ofcourse a vector 2, 2 coordinates. Default constructor is asserting 0, 0 on them, otherwise you can declare them.

The operator functions return asign so you can return a value of either the x of y via an integer. What helped me understand this is to think of like OpenGl VertexAttrib, or assigned textures in Opengl. You assign them to an int and via that reference you can access that component in the array.

The vec3 struct works the same but with 3 components instead of 2! Excitng. What is assert? Well it checks wether or not a condition is true and if it isnt lets crash the program and display a problem so we can see what went wrong.

N…

Similar Posts

Loading similar posts...