From db41d43345ea73cf7c1bbb29448e52ffb822e3e0 Mon Sep 17 00:00:00 2001 From: vimene Date: Tue, 13 Jan 2026 02:04:52 +0100 Subject: added textures for the hardware renderer - removed "using" directive in .hpp - reverse order of arguments for quaternion rotation, i.e. q.rot(v) instead of v.rot(q), where q is a quaterinon and v a vector - pass the inverse of the view matrix to render_and_present_frame, to allow light calculation in shaders (we used to just pass the matrix of the quaternion of the transformation, i.e. discard scaling and translations) - added another mesh and texture (viking_room) for testing purposes - added transparent background option - added Quaternion::look_towards(), which is the equivalent of Matrix4::look_at() but only for rotations - various improvement to .obj parsing - load texture coordinates from .obj file - merged duplicate vertices in Mesh::linearize_indices() --- src/renderer.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'src/renderer.cpp') diff --git a/src/renderer.cpp b/src/renderer.cpp index 73b31f7..cf97af8 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp @@ -10,6 +10,7 @@ using namespace engine; using engine::math::Vector2, + engine::math::Vector3, engine::math::Vector4, engine::o3d::Triangle, engine::o3d::TriangleDerived, @@ -19,8 +20,7 @@ using engine::fb::PixelFrameBuffer; template -template -Renderer::Renderer(FBArg&& fb) : fb{std::forward(fb)} { +Renderer::Renderer(FrameBuffer&& fb) : fb { std::forward(fb) } { depth_buf.resize(this->fb.width() * this->fb.height()); } @@ -145,8 +145,9 @@ void Renderer::_draw_cropped_triangle(const Triangle& root, const T loc_z }; fb.draw_point(x, y, loc, - VertexData::bilerp(root.vertex1.data, root.vertex2.data, root.vertex3.data, b0, b1), - Vector3::bilerp(root.vertex1.normal, root.vertex2.normal, root.vertex3.normal, b0, b1).normalize()); + Vector3 ::bilerp(root.vertex1.normal, root.vertex2.normal, root.vertex3.normal, b0, b1), + Vector2 ::bilerp(root.vertex1.uv, root.vertex2.uv, root.vertex3.uv, b0, b1), + VertexData::bilerp(root.vertex1.data, root.vertex2.data, root.vertex3.data, b0, b1)); } } }; @@ -155,8 +156,4 @@ void Renderer::_draw_cropped_triangle(const Triangle& root, const T } template class Renderer; -template Renderer::Renderer(CharacterFrameBuffer&&); -template Renderer::Renderer(const CharacterFrameBuffer&); template class Renderer; -template Renderer::Renderer(PixelFrameBuffer&&); -template Renderer::Renderer(const PixelFrameBuffer&); -- cgit v1.2.3