From cc6fb8c33637566a7b116d46440e6063f016deea Mon Sep 17 00:00:00 2001 From: vimene Date: Tue, 31 Dec 2024 03:40:14 +0100 Subject: various improvements - added quaternions and rewrote all rotations to use them - added transforms to put all object transforms in a single place - added Wavefront .obj file parser - removed frame buffer's abstract class - improved vectors, matrices, triangles, vertices and vertices data by putting all code in header file - added vector's operations - changed from NULL to nullptr - miscellaneous improvements --- src/fb/pixfb.h | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'src/fb/pixfb.h') diff --git a/src/fb/pixfb.h b/src/fb/pixfb.h index 84bce2c..81a7ac3 100644 --- a/src/fb/pixfb.h +++ b/src/fb/pixfb.h @@ -3,26 +3,36 @@ #include #include -#include "fb/fb.h" +#include "math/vector.h" +#include "o3d/vertex_data.h" namespace engine::fb { -class PixelFrameBuffer : public FrameBuffer { +using engine::math::Vector3, engine::o3d::VertexData; + +class PixelFrameBuffer { public: PixelFrameBuffer(unsigned int w, unsigned int h); void resize(unsigned int w, unsigned int h); - unsigned int width() const; - unsigned int height() const; - const uint32_t* pixels() const; void clear(); - void draw_point(int x, int y, engine::math::Vector3 loc, const engine::o3d::VertexData& vd); + void draw_point(int x, int y, const Vector3& loc, const VertexData& vd, const Vector3& normal); + + constexpr unsigned int width() const & { + return w; + } + + constexpr unsigned int height() const & { + return h; + } + + constexpr const uint32_t* pixels() const & { + return pixels_vector.data(); + } private: unsigned int w, h; std::vector pixels_vector; int face_ind; - - uint32_t face_color(int face_ind) const; }; } -- cgit v1.2.3