-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathtri.cpp
More file actions
45 lines (35 loc) · 1.03 KB
/
Copy pathtri.cpp
File metadata and controls
45 lines (35 loc) · 1.03 KB
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
/*
* Visualize a triangle
*/
#include <iostream>
#include <memory>
import sm.vec;
import mplot.visual;
import mplot.trianglevisual;
int main()
{
int rtn = -1;
mplot::Visual v(1024, 768, "Visualization");
v.zNear = 0.001f;
v.coordArrowsInScene (true);
// For a white background:
v.backgroundWhite();
// Switch on a mix of diffuse/ambient lighting
v.lightingEffects(true);
try {
sm::vec<float, 3> offset = { 0.0f, 0.0f, 0.0f };
sm::vec<float, 3> c1 = { 0.0f, 0.0f, 0.0f };
sm::vec<float, 3> c2 = { 0.25f, 0.0f, 0.0f };
sm::vec<float, 3> c3 = { 0.0f, 0.3f, 0.0f };
sm::vec<float, 3> colour1 = { 1.0f, 0.0f, 0.0f };
auto tv = std::make_unique<mplot::TriangleVisual<>> (offset, c1, c2, c3, colour1);
tv->set_parent (v.get_id());
tv->finalize();
v.addVisualModel (tv);
v.keepOpen();
} catch (const std::exception& e) {
std::cerr << "Caught exception: " << e.what() << std::endl;
rtn = -1;
}
return rtn;
}