hachem.wtf
aboutsummaryrefslogtreecommitdiff
path: root/src/rendering/scene_renderer.h
blob: 1f16afcf55be496fc97139c2bbe2b4b9ac93db53 (plain)
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
46
47
48
#pragma once

#include "rhi.h"
#include "renderer_backend.h"
#include <glm/glm.hpp>
#include <vector>

namespace Donut
{
    struct CameraView
    {
        glm::mat4 view;
        glm::mat4 projection;
        glm::vec3 position;
        int       fb_width  = 1;
        int       fb_height = 1;
    };

    class SceneRenderer
    {
    public:
        auto init(RHI::Device& device) -> bool;

        auto render(RHI::CommandList& cmd, const CameraView& cam,
                    const std::vector<SceneObject>& objects, int selected,
                    RHI::Texture* cubemap) -> void;

    private:
        static constexpr int MAX_OBJECTS = 64;

        RHI::Device* m_device = nullptr;

        Ref<RHI::Pipeline> m_grid_pipeline;
        Ref<RHI::Buffer>   m_grid_vb;
        Ref<RHI::Buffer>   m_grid_ubo;
        int                m_grid_vertex_count = 0;

        Ref<RHI::Pipeline> m_sphere_pipeline;
        Ref<RHI::Buffer>   m_sphere_vb;
        Ref<RHI::Buffer>   m_sphere_ib;
        int                m_sphere_index_count = 0;
        std::vector<Ref<RHI::Buffer>> m_sphere_ubos;

        Ref<RHI::Pipeline> m_skybox_pipeline;
        Ref<RHI::Buffer>   m_skybox_vb;
        Ref<RHI::Buffer>   m_skybox_ubo;
    };
}