blob: 3880d04c9a6719220002f1d35523fda0e7af9e28 (
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
34
35
36
37
38
39
40
41
42
43
44
45
|
#ifndef RENDERER_HPP
#define RENDERER_HPP
#include <memory>
#include <type_traits>
#include "math/vector.hpp"
#include "o3d/tri.hpp"
#include "o3d/tri_deriv.hpp"
#include "o3d/mesh.hpp"
#include "fb/fb.hpp"
#include "shaders/shaders.hpp"
namespace engine {
template<fb::FrameBufferConcept FrameBuffer, shaders::ShadersConcept Shaders>
class Renderer
{
public:
FrameBuffer fb;
Shaders shaders;
Renderer(FrameBuffer&& fb, Shaders&& shaders);
void resize(unsigned int w, unsigned int h);
void clear();
void draw_triangle(const o3d::Triangle& triangle);
void draw_mesh(const o3d::Mesh& mesh);
constexpr unsigned int width() const & {
return fb.width();
}
constexpr unsigned int height() const & {
return fb.height();
}
private:
std::vector<float> depth_buf;
void _draw_cropped_triangle(const o3d::Triangle& root, const o3d::TriangleDerived<engine::math::Vector3>& triangle);
};
}
#endif // RENDERER_HPP
|