#pragma once #include "gfx/gl/glVertexArray.h" #include "gfx/gl/instanceVertices.h" #include "gfx/models/lights.h" #include "gl_traits.h" #include #include class SceneShader; class Frustum; class ShadowMapper; class ShadowStenciller; class BillboardPainter; class Location; class Renderable { public: 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; 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; using CommonLocationInstance = CommonLocationData::InstanceProxy; std::shared_ptr locationData; static std::weak_ptr commonLocationData; using CommonSpotLights = InstanceVertices; std::shared_ptr spotLights; static std::weak_ptr commonSpotLights; using CommonPointLights = InstanceVertices; std::shared_ptr pointLights; static std::weak_ptr commonPointLights; std::shared_ptr instancesSpotLightVAO, instancesPointLightVAO; static std::weak_ptr commonInstancesSpotLightVAO, commonInstancesPointLightVAO; }; template<> struct gl_traits::InstanceProxy> { static GLuint vertexArrayAttribFormat(GLuint vao, GLuint index, GLuint offset); };