diff options
| author | Dan Goodliffe <dan@randomdan.homeip.net> | 2026-04-03 12:04:14 +0100 |
|---|---|---|
| committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2026-04-03 12:04:14 +0100 |
| commit | 4d04572e48950493ce85255d181be43967f362fd (patch) | |
| tree | f74d055f151472cda3fa3fc0f760eb6219dd9fad /gfx/renderable.h | |
| parent | Use std::chrono for worldTime (diff) | |
| parent | Fix direction of difference vector calculating railVehicle new position (diff) | |
| download | ilt-4d04572e48950493ce85255d181be43967f362fd.tar.bz2 ilt-4d04572e48950493ce85255d181be43967f362fd.tar.xz ilt-4d04572e48950493ce85255d181be43967f362fd.zip | |
Merge branch 'shared-locations'
Diffstat (limited to 'gfx/renderable.h')
| -rw-r--r-- | gfx/renderable.h | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/gfx/renderable.h b/gfx/renderable.h index d0870ad..7f4f52e 100644 --- a/gfx/renderable.h +++ b/gfx/renderable.h @@ -1,5 +1,10 @@ #pragma once +#include "gfx/gl/glVertexArray.h" +#include "gfx/gl/instanceVertices.h" +#include "gfx/models/lights.h" +#include "gl_traits.h" +#include <glm/mat3x3.hpp> #include <special_members.h> class SceneShader; @@ -7,18 +12,47 @@ class Frustum; class ShadowMapper; class ShadowStenciller; class BillboardPainter; +class Location; class Renderable { public: - Renderable() = default; + Renderable(); virtual ~Renderable() = default; DEFAULT_MOVE_COPY(Renderable); virtual void preFrame(const Frustum &, const Frustum &); virtual void render(const SceneShader & shader, const Frustum &) const = 0; - virtual void lights(const SceneShader & shader) const; + static void lights(const SceneShader & shader); virtual void shadows(const ShadowMapper & shadowMapper, const Frustum &) const; virtual void updateStencil(const ShadowStenciller & lightDir) const; virtual void updateBillboard(const BillboardPainter &) const; + + struct CommonLocation { + CommonLocation(const Location &); + CommonLocation & operator=(const Location &); + + glm::ivec4 position; + glm::vec4 rotation; + glm::mat3x4 rotationMatrix; + }; + + using CommonLocationData = InstanceVertices<CommonLocation>; + using CommonLocationInstance = CommonLocationData::InstanceProxy; + std::shared_ptr<CommonLocationData> locationData; + static std::weak_ptr<CommonLocationData> commonLocationData; + + using CommonSpotLights = InstanceVertices<SpotLightVertex>; + std::shared_ptr<CommonSpotLights> spotLights; + static std::weak_ptr<CommonSpotLights> commonSpotLights; + using CommonPointLights = InstanceVertices<PointLightVertex>; + std::shared_ptr<CommonPointLights> pointLights; + static std::weak_ptr<CommonPointLights> commonPointLights; + std::shared_ptr<glVertexArray> instancesSpotLightVAO, instancesPointLightVAO; + static std::weak_ptr<glVertexArray> commonInstancesSpotLightVAO, commonInstancesPointLightVAO; }; + +template<> struct gl_traits<InstanceVertices<Renderable::CommonLocation>::InstanceProxy> { + static GLuint vertexArrayAttribFormat(GLuint vao, GLuint index, GLuint offset); +}; + |
