Mercator
Shader.h
1 // This file may be redistributed and modified only under the terms of
2 // the GNU General Public License (See COPYING for details).
3 // Copyright (C) 2003 Alistair Riddoch
4 
5 #ifndef MERCATOR_SHADER_H
6 #define MERCATOR_SHADER_H
7 
8 #include <string>
9 #include <map>
10 
11 namespace Mercator {
12 
13 class Surface;
14 class Segment;
15 
16 // FIXME - PLACEHOLDER
17 // This class itereates over the buffer in a segment using the data it contains
18 // to populate a RGBA colour buffer based on the terrain height data. ie it is
19 // used to define the texture blending for a given surface
20 
29 class Shader {
30  private:
32  const bool m_color;
34  const bool m_alpha;
35  protected:
36  explicit Shader(bool color = false, bool alpha = true);
37  public:
38  virtual ~Shader();
39 
41  bool getColor() const {
42  return m_color;
43  }
44 
46  bool getAlpha() const {
47  return m_alpha;
48  }
49 
50  Surface * newSurface(const Segment &) const;
51 
57  virtual bool checkIntersect(const Segment &) const = 0;
58 
60  virtual void shade(Surface &) const = 0;
61 
63  typedef std::map<std::string, float> Parameters;
64 };
65 
66 } // namespace Mercator
67 
68 #endif // MERCATOR_SHADER_H
const bool m_alpha
Flag to control whether this Shader produces alpha data.
Definition: Shader.h:34
Surface * newSurface(const Segment &) const
Create a new Surface which matches the requirements of this shader.
Definition: Shader.cpp:29
Definition: Area.cpp:20
Shader(bool color=false, bool alpha=true)
Protected constructor for classes which inherit from this one.
Definition: Shader.cpp:16
Data store for terrain surface data.
Definition: Surface.h:22
bool getAlpha() const
Accessor for alpha flag.
Definition: Shader.h:46
std::map< std::string, float > Parameters
STL map of parameter values for a shader constructor.
Definition: Shader.h:63
Class storing heightfield and other data for a single fixed size square area of terrain defined by fo...
Definition: Segment.h:36
Base class for Shader objects which create surface data for use when rendering terrain.
Definition: Shader.h:29
virtual bool checkIntersect(const Segment &) const =0
Check whether this Shader has any effect on the given Segment.
virtual void shade(Surface &) const =0
Populate a Surface with data.
bool getColor() const
Accessor for color flag.
Definition: Shader.h:41
const bool m_color
Flag to control whether this Shader produces color data.
Definition: Shader.h:32
virtual ~Shader()
Destructor does nothing interesting.
Definition: Shader.cpp:21