aboutsummaryrefslogtreecommitdiff
path: root/pixfb.h
blob: c54b5fb19b6eeb9abe0289240a76da215c7cf7db (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 PIXFB_H
#define PIXFB_H

#include <vector>
#include <cstdint>
#include "math_vector.h"
#include "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 // PIXFB_H