aboutsummaryrefslogtreecommitdiff
path: root/src/fb/pixfb.h
blob: cdfac187f4f680258f02af3de345ddcd93cf4032 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#ifndef FB_PIXFB_H
#define FB_PIXFB_H

#include <vector>
#include <cstdint>
#include "math/vector.h"
#include "o3d/tri_vertex.h"

namespace engine::fb {

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_triangle(engine::o3d::TriangleVertex4 triangle);

    private:
        unsigned int w, h;
        std::vector<uint32_t> pixels_vector;
        std::vector<float> depth_buf;
        int face_ind;

        void _draw_cropped_triangle(engine::o3d::TriangleVertex3 triangle);
        uint32_t face_color() const;
};

}

#endif // FB_PIXFB_H