Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set the correct program link parameters #3110

Merged
merged 24 commits into from
Sep 29, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
shadermanager.hpp setProgramTemplate
  • Loading branch information
bosvensson1 committed Sep 14, 2021
commit cb3694f19443da49c187241562156dbce200a1bb
30 changes: 6 additions & 24 deletions components/shader/shadermanager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,9 @@

#include <osg/Shader>

#include <osgViewer/Viewer>

#include <components/sceneutil/lightmanager.hpp>

namespace Resource
{
class SceneManager;
}

namespace SceneUtil
{
enum class LightingMethod;
}

namespace Shader
{

enum class UBOBinding
{
LightBuffer
};

/// @brief Reads shader template files and turns them into a concrete shader, based on a list of define's.
/// @par Shader templates can get the value of a define with the syntax @define.
class ShaderManager
Expand All @@ -41,8 +22,6 @@ namespace Shader

void setShaderPath(const std::string& path);

void setLightingMethod(SceneUtil::LightingMethod method);

typedef std::map<std::string, std::string> DefineMap;

/// Create or retrieve a shader instance.
Expand All @@ -53,7 +32,10 @@ namespace Shader
/// @note Thread safe.
osg::ref_ptr<osg::Shader> getShader(const std::string& templateName, const DefineMap& defines, osg::Shader::Type shaderType);

osg::ref_ptr<osg::Program> getProgram(osg::ref_ptr<osg::Shader> vertexShader, osg::ref_ptr<osg::Shader> fragmentShader);
osg::ref_ptr<osg::Program> getProgram(osg::ref_ptr<osg::Shader> vertexShader, osg::ref_ptr<osg::Shader> fragmentShader, const osg::Program* programTemplate=nullptr);

const osg::Program* getProgamTemplate() const { return mProgramTemplate; }
void setProgramTemplate(const osg::Program* program) { mProgramTemplate = program; }

/// Get (a copy of) the DefineMap used to construct all shaders
DefineMap getGlobalDefines();
Expand Down Expand Up @@ -81,9 +63,9 @@ namespace Shader
typedef std::map<std::pair<osg::ref_ptr<osg::Shader>, osg::ref_ptr<osg::Shader> >, osg::ref_ptr<osg::Program> > ProgramMap;
ProgramMap mPrograms;

SceneUtil::LightingMethod mLightingMethod;

std::mutex mMutex;

const osg::Program* mProgramTemplate;
};

bool parseFors(std::string& source, const std::string& templateName);
Expand Down