File: ThresholdShadertest.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 (108 lines) | stat: -rw-r--r-- 2,836 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
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
// This file may be redistributed and modified only under the terms of
// the GNU General Public License (See COPYING for details).
// Copyright (C) 2009 Alistair Riddoch

#include <Mercator/Terrain.h>
#include <Mercator/ThresholdShader.h>
#include <Mercator/Segment.h>

#include <cassert>

typedef WFMath::Point<2> Point2;

void testHighShader()
{
    Mercator::Terrain terrain(Mercator::Terrain::SHADED, 16);

    Mercator::Shader::Parameters params;
    params[Mercator::HighShader::key_threshold] = 5.f;
    
    Mercator::HighShader* dshade = new Mercator::HighShader();
    delete dshade;
    dshade = new Mercator::HighShader(params);
    terrain.addShader(dshade, 0);
    
    terrain.setBasePoint(0, 0, 20);
    terrain.setBasePoint(0, 1, 1);
    terrain.setBasePoint(1, 0, 2);
    terrain.setBasePoint(1, 1, 0.5);
    terrain.setBasePoint(2, 0, 2);
    terrain.setBasePoint(2, 1, 0.5);
    
    Mercator::Segment* seg = terrain.getSegment(0,0);
    
    seg->populateSurfaces();
    seg->populate();
    seg->populateSurfaces();

    seg = terrain.getSegment(1,0);
    dshade->checkIntersect(*seg);
}

void testLowShader()
{
    Mercator::Terrain terrain(Mercator::Terrain::SHADED, 16);

    Mercator::Shader::Parameters params;
    params[Mercator::LowShader::key_threshold] = 5.f;
    
    Mercator::LowShader* dshade = new Mercator::LowShader();
    delete dshade;
    dshade = new Mercator::LowShader(params);
    terrain.addShader(dshade, 0);
    
    terrain.setBasePoint(0, 0, 2);
    terrain.setBasePoint(0, 1, 1);
    terrain.setBasePoint(1, 0, 20);
    terrain.setBasePoint(1, 1, 10);
    terrain.setBasePoint(2, 0, 15);
    terrain.setBasePoint(2, 1, 19);
    
    Mercator::Segment* seg = terrain.getSegment(0,0);
    
    seg->populateSurfaces();
    seg->populate();
    seg->populateSurfaces();

    seg = terrain.getSegment(1,0);
    dshade->checkIntersect(*seg);
}

void testBandShader()
{
    Mercator::Terrain terrain(Mercator::Terrain::SHADED, 16);

    Mercator::Shader::Parameters params;
    params[Mercator::BandShader::key_lowThreshold] = 2.f;
    params[Mercator::BandShader::key_highThreshold] = 8.f;
    
    Mercator::BandShader* dshade = new Mercator::BandShader();
    delete dshade;
    dshade = new Mercator::BandShader(params);
    terrain.addShader(dshade, 0);
    
    terrain.setBasePoint(0, 0, 2);
    terrain.setBasePoint(0, 1, 1);
    terrain.setBasePoint(1, 0, 20);
    terrain.setBasePoint(1, 1, 10);
    terrain.setBasePoint(2, 0, 15);
    terrain.setBasePoint(2, 1, 19);
    
    Mercator::Segment* seg = terrain.getSegment(0,0);
    
    seg->populateSurfaces();
    seg->populate();
    seg->populateSurfaces();

    seg = terrain.getSegment(1,0);
    dshade->checkIntersect(*seg);
}

int main()
{
    testHighShader();
    testLowShader();
    testBandShader();

    return 0;
}