Skip to content

Commit

Permalink
#5532: A cube map decl expression is deriving from IMapExpression too…
Browse files Browse the repository at this point in the history
… now. It's different from the MapExpression intermediate type since it doesn't generate a single ImagePtr, but offers the cube map binding methods instead.
  • Loading branch information
codereader committed Feb 23, 2021
1 parent 37c9005 commit e56565f
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 11 deletions.
6 changes: 0 additions & 6 deletions include/ishaderexpression.h
Expand Up @@ -83,12 +83,6 @@ class IMapExpression

virtual ~IMapExpression() {}

/**
* \brief
* Construct and return the image created from this map expression.
*/
virtual ImagePtr getImage() const = 0;

/**
* \brief
* Return whether this map expression creates a cube map.
Expand Down
5 changes: 5 additions & 0 deletions radiantcore/shaders/CameraCubeMapDecl.cpp
Expand Up @@ -54,6 +54,11 @@ std::string CameraCubeMapDecl::getIdentifier() const
return "_cameraCubeMap_" + _prefix;
}

std::string CameraCubeMapDecl::getExpressionString()
{
return _prefix;
}

TexturePtr CameraCubeMapDecl::bindTexture(const std::string& name) const
{
// Load the six images from the prefix
Expand Down
18 changes: 13 additions & 5 deletions radiantcore/shaders/CameraCubeMapDecl.h
@@ -1,5 +1,6 @@
#pragma once

#include "MapExpression.h"
#include "NamedBindable.h"

namespace shaders
Expand All @@ -17,25 +18,32 @@ namespace shaders
* NamedBindable interface so that it can bind the cube map texture in GL and
* return it to the texture manager.
*/
class CameraCubeMapDecl
: public NamedBindable
class CameraCubeMapDecl :
public IMapExpression,
public NamedBindable
{
// The texture prefix
std::string _prefix;

private:

// Construct with a prefix
CameraCubeMapDecl(const std::string& prefix);

virtual bool isCubeMap() const override
{
return true;
}

// Load and bind the given image with the given cube-map direction
void bindDirection(const std::string& dir, GLuint glDir) const;

public:

/* NamedBindable implementation */
std::string getIdentifier() const;
TexturePtr bindTexture(const std::string& name) const;
std::string getIdentifier() const override;
TexturePtr bindTexture(const std::string& name) const override;

std::string getExpressionString() override;

/**
* \brief
Expand Down
3 changes: 3 additions & 0 deletions radiantcore/shaders/MapExpression.h
Expand Up @@ -45,6 +45,9 @@ class MapExpression :
return TexturePtr();
}

// Abstract method to be implemented
virtual ImagePtr getImage() const = 0;

public: /* STATIC CONSTRUCTION METHODS */

/** Creates the a MapExpression out of the given token. Nested mapexpressions
Expand Down

0 comments on commit e56565f

Please sign in to comment.