File: Shader.h

package info (click to toggle)
mercator 0.3.0-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 2,008 kB
  • sloc: sh: 10,433; cpp: 4,482; makefile: 115
file content (68 lines) | stat: -rw-r--r-- 2,193 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// This file may be redistributed and modified only under the terms of
// the GNU General Public License (See COPYING for details).
// Copyright (C) 2003 Alistair Riddoch

#ifndef MERCATOR_SHADER_H
#define MERCATOR_SHADER_H

#include <string>
#include <map>

namespace Mercator {

class Surface;
class Segment;

// FIXME - PLACEHOLDER
// This class itereates over the buffer in a segment using the data it contains
// to populate a RGBA colour buffer based on the terrain height data. ie it is
// used to define the texture blending for a given surface

/// \brief Base class for Shader objects which create surface data for use
/// when rendering terrain.
///
/// Shader objects take heightfield data for a terrain Segment, and use it
/// to populate a Surface with data that can then be used to define the
/// appearance of the terrain when rendering. The Shader is used both to
/// create the Surface object of the right type, and to populate the
/// Surface with data once the Segment heightfield has been generated.
class Shader {
  private:
    /// \brief Flag to control whether this Shader produces color data.
    const bool m_color;
    /// \brief Flag to control whether this Shader produces alpha data.
    const bool m_alpha;
  protected:
    explicit Shader(bool color = false, bool alpha = true);
  public:
    virtual ~Shader();

    /// \brief Accessor for color flag.
    bool getColor() const {
        return m_color;
    }

    /// \brief Accessor for alpha flag.
    bool getAlpha() const {
        return m_alpha;
    }

    Surface * newSurface(const Segment &) const;

    /// \brief Check whether this Shader has any effect on the given Segment.
    ///
    /// @return true if the given Segment height range is within the range
    /// that this Shader uses. e.g. A high altitude snow shader will have
    /// no effect on low level terrain.
    virtual bool checkIntersect(const Segment &) const = 0;

    /// \brief Populate a Surface with data.
    virtual void shade(Surface &) const = 0;

    /// STL map of parameter values for a shader constructor.
    typedef std::map<std::string, float> Parameters;
};

} // namespace Mercator

#endif // MERCATOR_SHADER_H