File: Surface.cpp

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 (39 lines) | stat: -rw-r--r-- 991 bytes parent folder | download | duplicates (4)
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
// 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

#include <Mercator/Surface.h>

#include <Mercator/Shader.h>
#include <cassert>

namespace Mercator {

/// \brief Constructor
///
/// @param seg the terrain height segment this surface maps on to.
/// @param sh the shader used to generate the surface data.
/// @param color true if this shader contains color data.
/// @param alpha true if this shader contains alpha data.
Surface::Surface(const Segment & seg, const Shader & sh, bool color, bool alpha)
  : Buffer<ColorT>(seg, (color ? 3 : 0) + (alpha ? 1 : 0)), m_shader(sh)
{
}

Surface::~Surface()
{
}

/// \brief Populate the data buffer using the correct shader.
///
/// Call the shader to full this surface buffer with surface data.
void Surface::populate()
{
    if (!isValid()) {
        allocate();
    }

    m_shader.shade(*this);
}

} // namespace Mercator