Skip to content

Commit

Permalink
[engine] TextureSemantic, remove one level of namespace.
Browse files Browse the repository at this point in the history
  • Loading branch information
dlyr committed Jul 12, 2023
1 parent 38d118b commit 111d2d8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 20 deletions.
16 changes: 6 additions & 10 deletions src/Engine/Data/BlinnPhongMaterial.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ namespace Data {
class ShaderProgram;

namespace TextureSemantics {
namespace BlinnPhongMaterial {
enum class TextureSemantic { TEX_DIFFUSE, TEX_SPECULAR, TEX_NORMAL, TEX_SHININESS, TEX_ALPHA };
}
enum class BlinnPhongMaterial { TEX_DIFFUSE, TEX_SPECULAR, TEX_NORMAL, TEX_SHININESS, TEX_ALPHA };
} // namespace TextureSemantics

/**
Expand All @@ -38,12 +36,12 @@ enum class TextureSemantic { TEX_DIFFUSE, TEX_SPECULAR, TEX_NORMAL, TEX_SHININES
class RA_ENGINE_API BlinnPhongMaterial final
: public Material,
public ParameterSetEditingInterface,
public MaterialTextureSet<TextureSemantics::BlinnPhongMaterial::TextureSemantic>
public MaterialTextureSet<TextureSemantics::BlinnPhongMaterial>
{
friend class BlinnPhongMaterialConverter;

public:
using TextureSemantic = TextureSemantics::BlinnPhongMaterial::TextureSemantic;
using TextureSemantic = TextureSemantics::BlinnPhongMaterial;

public:
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
Expand All @@ -59,7 +57,7 @@ class RA_ENGINE_API BlinnPhongMaterial final
* associated textures.
*/
~BlinnPhongMaterial() override;
using MaterialTextureSet<TextureSemantics::BlinnPhongMaterial::TextureSemantic>::addTexture;
using MaterialTextureSet<TextureSemantic>::addTexture;

/// \todo Fix this specialiration. Maybe assume that named texture have to be added to manager
/// before hand, and that texture on the fly addition is a fix, hence no special care for normal
Expand All @@ -69,8 +67,7 @@ class RA_ENGINE_API BlinnPhongMaterial final
auto texManager = RadiumEngine::getInstance()->getTextureManager();
auto texHandle = texManager->getTextureHandle( texture );
if ( texHandle.isValid() ) {
MaterialTextureSet<TextureSemantics::BlinnPhongMaterial::TextureSemantic>::addTexture(
semantic, texHandle );
MaterialTextureSet<TextureSemantic>::addTexture( semantic, texHandle );
}
else {
TextureParameters data;
Expand All @@ -79,8 +76,7 @@ class RA_ENGINE_API BlinnPhongMaterial final
data.sampler.wrapT = GL_REPEAT;
if ( semantic != TextureSemantic::TEX_NORMAL )
data.sampler.minFilter = GL_LINEAR_MIPMAP_LINEAR;
MaterialTextureSet<TextureSemantics::BlinnPhongMaterial::TextureSemantic>::addTexture(
semantic, data );
MaterialTextureSet<TextureSemantic>::addTexture( semantic, data );
}
}

Expand Down
16 changes: 6 additions & 10 deletions src/Engine/Data/SimpleMaterial.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,23 @@ namespace Data {

/** @brief Namespace to define materials' texture semantics.
*
* Convention: add you're material's MyMaterial TextureSemantic Enum inside it's MyMaterial nested
* namespace.
* Convention: add you're material's MyMaterial Enum inside TextureSemantics namespace.
*/
namespace TextureSemantics {
namespace SimpleMaterial {
/// Semantic of the texture : define which BSDF parameter is controled by the texture
enum class TextureSemantic { TEX_COLOR, TEX_MASK };
} // namespace SimpleMaterial
enum class SimpleMaterial { TEX_COLOR, TEX_MASK };
} // namespace TextureSemantics

/**
* Base implementation for simple, monocolored, materials.
* This material could not be used as is. Only derived class could be used by a renderer.
*/
class RA_ENGINE_API SimpleMaterial
: public Material,
public ParameterSetEditingInterface,
public MaterialTextureSet<TextureSemantics::SimpleMaterial::TextureSemantic>
class RA_ENGINE_API SimpleMaterial : public Material,
public ParameterSetEditingInterface,
public MaterialTextureSet<TextureSemantics::SimpleMaterial>
{
public:
using TextureSemantic = TextureSemantics::SimpleMaterial::TextureSemantic;
using TextureSemantic = TextureSemantics::SimpleMaterial;
/**
* Construct a named materialhmb
* @param name The name of the material
Expand Down

0 comments on commit 111d2d8

Please sign in to comment.