Skip to content

Commit

Permalink
#5532: Setters for clamp type and cull type.
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Mar 21, 2021
1 parent a3dfdf0 commit 1fb9fed
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
6 changes: 6 additions & 0 deletions include/ishaders.h
Expand Up @@ -225,9 +225,15 @@ class Material
/// Get the desired texture repeat behaviour.
virtual ClampType getClampType() const = 0;

// Set the clamp type for this material
virtual void setClampType(ClampType type) = 0;

/// Get the cull type (none, back, front)
virtual CullType getCullType() const = 0;

// Set the cull type
virtual void setCullType(CullType type) = 0;

/// Get the global material flags (translucent, noshadows, etc.)
virtual int getMaterialFlags() const = 0;

Expand Down
12 changes: 12 additions & 0 deletions radiantcore/shaders/CShader.cpp
Expand Up @@ -200,11 +200,23 @@ Material::CullType CShader::getCullType() const
return _template->getCullType();
}

void CShader::setCullType(CullType type)
{
ensureTemplateCopy();
_template->setCullType(type);
}

ClampType CShader::getClampType() const
{
return _template->getClampType();
}

void CShader::setClampType(ClampType type)
{
ensureTemplateCopy();
_template->setClampType(type);
}

int CShader::getSurfaceFlags() const
{
return _template->getSurfaceFlags();
Expand Down
2 changes: 2 additions & 0 deletions radiantcore/shaders/CShader.h
Expand Up @@ -72,7 +72,9 @@ class CShader final :
const char* getShaderFileName() const override;
const vfs::FileInfo& getShaderFileInfo() const override;
CullType getCullType() const override;
void setCullType(CullType type) override;
ClampType getClampType() const override;
void setClampType(ClampType type) override;
int getSurfaceFlags() const override;
void setSurfaceFlag(Material::SurfaceFlags flag) override;
void clearSurfaceFlag(Material::SurfaceFlags flag) override;
Expand Down
12 changes: 12 additions & 0 deletions radiantcore/shaders/ShaderTemplate.h
Expand Up @@ -190,12 +190,24 @@ class ShaderTemplate final
return _cullType;
}

void setCullType(Material::CullType type)
{
if (!_parsed) parseDefinition();
_cullType = type;
}

ClampType getClampType()
{
if (!_parsed) parseDefinition();
return _clampType;
}

void setClampType(ClampType type)
{
if (!_parsed) parseDefinition();
_clampType = type;
}

int getSurfaceFlags()
{
if (!_parsed) parseDefinition();
Expand Down

0 comments on commit 1fb9fed

Please sign in to comment.