#include "fb/pixfb.h" #include #include #include "math/vector.h" #include "math/quat.h" #include "o3d/vertex_data.h" using namespace engine::fb; using engine::math::Vector3, engine::o3d::VertexData; PixelFrameBuffer::PixelFrameBuffer(unsigned int w, unsigned int h) { resize(w, h); } void PixelFrameBuffer::resize(unsigned int w, unsigned int h) { this->w = w; this->h = h; pixels_vector.resize(w * h); clear(); } void PixelFrameBuffer::clear() { std::fill(pixels_vector.begin(), pixels_vector.end(), 0x000000FF); } extern engine::math::Quaternion camera_quat; void PixelFrameBuffer::draw_point(int x, int y, const Vector3& loc, const VertexData& vd, const Vector3& normal) { (void) loc; (void) vd; // int ir = ((int) (((float) ((int) (vd.tx * 10.f))) * 25.5f)); // int ig = ((int) (((float) ((int) (vd.ty * 10.f))) * 25.5f)); // pixels_vector[x + y * w] = (ir << 24) | (ig << 16) | 0xFFFF; auto v = normal.rot(camera_quat.conjugate()); float light = .1f + (v.z < 0.f ? 0.f : v.z) * .9f; std::uint32_t c = (int) (light * 255.f); pixels_vector[x + y * w] = c << 24 | c << 16 | c << 8 | 0xff; }