diff options
author | quou <quou@disroot.org> | 2025-02-13 23:32:28 +1100 |
---|---|---|
committer | quou <quou@disroot.org> | 2025-02-13 23:33:54 +1100 |
commit | 2e4ecca19aadc09d5c3d927724f8004b6a0ff0b0 (patch) | |
tree | 156c747452788f5221158f6e2a9151eaeb61b672 /renderer.hpp | |
parent | 42cd6a572a35c354dc7d7fd390e86e7cff191617 (diff) |
refactoring; prep for shadows
Diffstat (limited to 'renderer.hpp')
-rw-r--r-- | renderer.hpp | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/renderer.hpp b/renderer.hpp new file mode 100644 index 0000000..29a9dd0 --- /dev/null +++ b/renderer.hpp @@ -0,0 +1,74 @@ +#ifndef renderer_hpp +#define renderer_hpp + +#include "camera.hpp" +#include "hashmap.hpp" +#include "lighting.hpp" +#include "video.hpp" + +enum { + FORWARD, + SHADOW_MAP_START, + SHADOW_MAP_END = SHADOW_MAP_START + Lighting::max_shadows, + drawlist_count = SHADOW_MAP_END }; + +struct Camera_Id : public Primitive_Id<uint32_t> { + using Primitive_Id<uint32_t>::Primitive_Id; +}; + +template<> +struct Hash_Function<Camera_Id> { + size_t operator()(Camera_Id id) const { + return id.index; + } +}; + +struct Model_Instance; +struct Renderer; + +struct Drawlist { + Model_Instance** models; + int count; + int cap; + Camera_Id camera; + Staged_Buffer vp; + + void render( + const Renderer& r, + Device* dev, + Arena* a, + const Lighting* l, + Render_Pass& pass + ); +}; + +struct Renderer { + static constexpr int max_cameras = 16; + Hash_Map<Camera_Id, Camera, max_cameras> cameras; + Drawlist drawlists[drawlist_count]; + int camera_count; + + Sampler_Id clamped_linear; + Texture_Id env_cubemap; + + void init(Arena* arena, Device* d); + void destroy(Device* d); + void set_camera(Camera_Id cam, int drawlist); + void render( + Device* dev, + Arena* a, + Texture_Id hdr_target, + const Lighting* l + ); + + void add_model(int drawlist, Model_Instance* m); + void rem_model(int drawlist, Model_Instance* m); + void default_model(Model_Instance* m); + + Camera_Id create_camera(); + Camera& get_camera(Camera_Id cam); + const Camera& get_camera(Camera_Id cam) const; + void destroy_camera(Camera_Id cam); +}; + +#endif |