aboutsummaryrefslogtreecommitdiff
path: root/src/fb/pixfb.h
blob: f5f8bde4114a95c5fb5b48bd420ea59d6b90d280 (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
#ifndef FB_PIXFB_H
#define FB_PIXFB_H

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

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(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(TriangleVertex3 triangle);
        uint32_t face_color() const;
};

#endif // FB_PIXFB_H