diff options
| author | vimene <vincent.menegaux@gmail.com> | 2026-01-13 02:04:52 +0100 |
|---|---|---|
| committer | vimene <vincent.menegaux@gmail.com> | 2026-01-13 02:04:52 +0100 |
| commit | db41d43345ea73cf7c1bbb29448e52ffb822e3e0 (patch) | |
| tree | 4635d654e301b3f31f8d2626f3bc2c6f2a6e50a8 /src/renderer.cpp | |
| parent | 7f08187a46e30925e4563585fab2c6f92400330a (diff) | |
| download | engine-db41d43345ea73cf7c1bbb29448e52ffb822e3e0.tar.gz | |
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()
Diffstat (limited to 'src/renderer.cpp')
| -rw-r--r-- | src/renderer.cpp | 13 |
1 files changed, 5 insertions, 8 deletions
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<typename FrameBuffer> -template<typename FBArg> -Renderer<FrameBuffer>::Renderer(FBArg&& fb) : fb{std::forward<FBArg>(fb)} { +Renderer<FrameBuffer>::Renderer(FrameBuffer&& fb) : fb { std::forward<FrameBuffer>(fb) } { depth_buf.resize(this->fb.width() * this->fb.height()); } @@ -145,8 +145,9 @@ void Renderer<FrameBuffer>::_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<FrameBuffer>::_draw_cropped_triangle(const Triangle& root, const T } template class Renderer<CharacterFrameBuffer>; -template Renderer<CharacterFrameBuffer>::Renderer(CharacterFrameBuffer&&); -template Renderer<CharacterFrameBuffer>::Renderer(const CharacterFrameBuffer&); template class Renderer<PixelFrameBuffer>; -template Renderer<PixelFrameBuffer>::Renderer(PixelFrameBuffer&&); -template Renderer<PixelFrameBuffer>::Renderer(const PixelFrameBuffer&); |
