This example shows how to create a simple viewer using Easy3D.
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#include <easy3d/renderer/camera.h>
28#include <easy3d/viewer/viewer.h>
29#include <easy3d/util/resource.h>
30#include <easy3d/util/initializer.h>
31
36
38
39int main(int argc, char** argv) {
40
42
44 Viewer viewer(EXAMPLE_TITLE);
45 viewer.camera()->setViewDirection(
vec3(0, 0, -1));
46 viewer.camera()->setUpVector(
vec3(0, 1, 0));
47
48 if (!viewer.add_model(file_name)) {
49 LOG(ERROR) << "failed to load model. Please make sure the file exists and format is correct.";
50 return EXIT_FAILURE;
51 }
52
53 return viewer.run();
54}
The built-in Easy3D viewer.
Definition viewer.h:63
std::string directory()
Returns the resource directory (containing color maps, shaders, textures, fonts, etc....
Definition collider.cpp:182
Vec< 3, float > vec3
A 3D point/vector of float type.
Definition types.h:44
void initialize(bool info_to_stdout, bool use_log_file, bool use_setting_file, const std::string &resource_dir)
Initialization of Easy3D.
Definition initializer.cpp:39