MCPcopy Create free account
hub / github.com/DanielChappuis/reactphysics3d / start

Method start

testbed/src/TestbedApplication.cpp:102–261  ·  view source on GitHub ↗

Initialize the viewer

Source from the content-addressed store, hash-verified

100
101// Initialize the viewer
102void TestbedApplication::start() {
103
104 glfwInit();
105 glfwSetTime(0);
106
107 // Get the primary monitor
108 GLFWmonitor* monitor = glfwGetPrimaryMonitor();
109 const GLFWvidmode* mode = glfwGetVideoMode(monitor);
110
111 // Window size
112 mWidth = mode->width;
113 mHeight = mode->height;
114
115#if defined(NANOGUI_USE_OPENGL)
116 glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_API);
117
118 glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
119 glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
120 glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
121 glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
122#elif defined(NANOGUI_USE_GLES)
123 glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_API);
124
125 glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_EGL_CONTEXT_API);
126#elif defined(NANOGUI_USE_METAL)
127 glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
128
129 metal_init();
130#endif
131
132 glfwWindowHint(GLFW_SAMPLES, 0);
133 glfwWindowHint(GLFW_RED_BITS, 8);
134 glfwWindowHint(GLFW_GREEN_BITS, 8);
135 glfwWindowHint(GLFW_BLUE_BITS, 8);
136 glfwWindowHint(GLFW_ALPHA_BITS, 8);
137 glfwWindowHint(GLFW_STENCIL_BITS, 8);
138 glfwWindowHint(GLFW_DEPTH_BITS, 24);
139 glfwWindowHint(GLFW_RESIZABLE, GL_TRUE);
140
141 // Create a the GLFW window object
142 std::string title = "Testbed - ReactPhysics3D v" + rp3d::RP3D_VERSION;
143 mWindow = glfwCreateWindow(mWidth, mHeight, title.c_str(), IS_FULLSCREEN ? monitor : nullptr, nullptr);
144 if (mWindow == nullptr) {
145 std::cout << "Failed to create GLFW window" << std::endl;
146 glfwTerminate();
147 }
148 glfwMakeContextCurrent(mWindow);
149
150#if defined(NANOGUI_GLAD)
151 if (!gladLoadGLLoader((GLADloadproc) glfwGetProcAddress))
152 throw std::runtime_error("Could not initialize GLAD!");
153 glGetError(); // pull and ignore unhandled errors like GL_INVALID_ENUM
154#endif
155
156 glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
157 glClear(GL_COLOR_BUFFER_BIT);
158
159 // Logger

Callers

nothing calls this directly

Calls 12

drawAllMethod · 0.80
mouse_motion_eventMethod · 0.80
mouse_button_eventMethod · 0.80
keyboard_eventMethod · 0.80
scroll_eventMethod · 0.80
onWindowResizedMethod · 0.80
reshapeMethod · 0.80
setWindowDimensionMethod · 0.80
drawMethod · 0.80
drawTearDownMethod · 0.80
initMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected