It has been a whilst since I had a personal improvement project grace these pages, so here's one I started over the weekend.... A graphics engine.
Sure this is something I play about with all day in the office, we're writing games! That's literally my job, but I've been a system engineer for such a very long time, and I've seen all these sparkly things coming from folks working on game play and wanted some sparklies of my own.
I therefore began two projects, both are graphics engines, but they're very different from one another... one is in Vulkan, which is not what we're talking about here, no we're talking about the other one... And this is a graphics engine I've written myself.
It's gone through three phases since Saturday, Sunday and then just tonight. The first phase was setting up the basic rendering, getting a triangle on the screen and making it flat (orthographic) projection.
The engine is written in C++, uses SDL2 for the window and renderer, but the engine itself does all the geometry transforms through linear matrix mathematics that I hand crafted, and it reaches into the third dimension in orthographic mode.
The shapes can be rotated, scaled, translated, the usual. But before I drove myself mad with writing shapes by hand on graph paper, I wrote a very simple importer for the very simple Milkshape 3D model editor, and started with a sphere:
Milkshape has appeared on these pages before and is really the only modelling package I'm familiar with, I really do need to learn Blender don't I?
So with models loading I got a little adventurous:
This mesh really stresses my single core linear mathematics, so I started to switch it out in favour of GLM tonight:
// Model
glm::mat4 model(1.0f);
model = glm::translate(model, trans);
model = glm::rotate(model, glm::radians(angleZ), { 0, 0, 1 });
model = glm::rotate(model, glm::radians(angleY), { 0, 1, 0 });
model = glm::rotate(model, glm::radians(angleX), { 1, 0, 0 });
model = glm::scale(model, glm::vec3(scale.x, scale.y, scale.z));
So, that's been my three days.. I'm interested where and what I will do with this engine.
However, Vulkan, that's the other thing I'm learning.
No comments:
Post a Comment