-
Notifications
You must be signed in to change notification settings - Fork 233
Expand file tree
/
Copy pathinitialize_backend.cpp
More file actions
58 lines (45 loc) · 1.58 KB
/
initialize_backend.cpp
File metadata and controls
58 lines (45 loc) · 1.58 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
46
47
48
49
50
51
52
53
54
55
56
57
58
// Copyright 2017-2023, Nicholas Sharp and the Polyscope contributors. https://polyscope.run
#include "polyscope/messages.h"
#include "polyscope/render/engine.h"
namespace polyscope {
namespace render {
// Storage for the global engine pointer
Engine* engine = nullptr;
// Backend we initialized with; written once below
std::string engineBackendName = "";
// Forward-declaration of initialize routines
// we don't want to just include the appropriate headers, because they may define conflicting symbols
namespace backend_openGL3_glfw {
void initializeRenderEngine();
}
namespace backend_openGL_mock {
void initializeRenderEngine();
}
// void initializeRenderEngine_openGL_mock();
void initializeRenderEngine(std::string backend) {
// Handle default backends
// (the string is getting overwritten, so lower on the list means higher priority)
if (backend == "") {
#ifdef POLYSCOPE_BACKEND_OPENGL_MOCK_ENABLED
// Don't set it one by default, since it's probably a mistake; better to throw the exception below.
// backend = "mock_openGL";
#endif
#ifdef POLYSCOPE_BACKEND_OPENGL3_GLFW_ENABLED
backend = "openGL3_glfw";
#endif
if (backend == "") {
exception("no Polyscope backends available");
}
}
engineBackendName = backend;
// Initialize the appropriate backend
if (backend == "openGL3_glfw") {
backend_openGL3_glfw::initializeRenderEngine();
} else if (backend == "openGL_mock") {
backend_openGL_mock::initializeRenderEngine();
} else {
exception("unrecognized Polyscope backend " + backend);
}
}
} // namespace render
} // namespace polyscope