1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-09 12:42:11 +00:00
OpenMW/components/shader/shadervisitor.hpp
scrawl a9ad1b09e2 Introduce ShaderManager & ShaderVisitor
Actual shaders still to be written.
2016-02-18 19:37:56 +01:00

55 lines
1.3 KiB
C++

#ifndef OPENMW_COMPONENTS_SHADERVISITOR_H
#define OPENMW_COMPONENTS_SHADERVISITOR_H
#include <osg/NodeVisitor>
namespace Shader
{
class ShaderManager;
/// @brief Adjusts the given subgraph to render using shaders.
class ShaderVisitor : public osg::NodeVisitor
{
public:
ShaderVisitor(ShaderManager& shaderManager, const std::string& defaultVsTemplate, const std::string& defaultFsTemplate);
virtual void apply(osg::Node& node);
virtual void apply(osg::Drawable& drawable);
virtual void apply(osg::Geometry& geometry);
void applyStateSet(osg::StateSet* stateset);
void pushRequirements();
void popRequirements();
private:
ShaderManager& mShaderManager;
struct ShaderRequirements
{
ShaderRequirements();
// <texture stage, texture name>
std::map<int, std::string> mTextures;
bool mColorMaterial;
// osg::Material::ColorMode
int mVertexColorMode;
// -1 == no tangents required
int mTexStageRequiringTangents;
};
std::vector<ShaderRequirements> mRequirements;
std::string mDefaultVsTemplate;
std::string mDefaultFsTemplate;
void createProgram(const ShaderRequirements& reqs, osg::StateSet* stateset);
};
}
#endif