MCPcopy Create free account
hub / github.com/RenderKit/ospray / GLFWDistribOSPRayWindow

Method GLFWDistribOSPRayWindow

modules/mpi/tutorials/GLFWDistribOSPRayWindow.cpp:31–157  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29{}
30
31GLFWDistribOSPRayWindow::GLFWDistribOSPRayWindow(const vec2i &windowSize,
32 const box3f &worldBounds,
33 cpp::World world,
34 cpp::Renderer renderer)
35 : windowSize(windowSize),
36 worldBounds(worldBounds),
37 world(world),
38 renderer(renderer)
39{
40 MPI_Comm_rank(MPI_COMM_WORLD, &mpiRank);
41 MPI_Comm_size(MPI_COMM_WORLD, &mpiWorldSize);
42
43 if (mpiRank == 0) {
44 if (activeWindow != nullptr) {
45 throw std::runtime_error(
46 "Cannot create more than one GLFWDistribOSPRayWindow!");
47 }
48
49 activeWindow = this;
50
51 // initialize GLFW
52 if (!glfwInit()) {
53 throw std::runtime_error("Failed to initialize GLFW!");
54 }
55
56 glfwWindowHint(GLFW_SRGB_CAPABLE, GLFW_TRUE);
57 glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
58#ifdef __APPLE_
59 glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
60 glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
61 const char *glslVersion = "#version 150";
62#else
63 glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
64 const char *glslVersion = "#version 130";
65#endif
66
67 glfwWindow = glfwCreateWindow(
68 windowSize.x, windowSize.y, "OSPRay Tutorial", NULL, NULL);
69
70 if (!glfwWindow) {
71 glfwTerminate();
72 throw std::runtime_error("Failed to create GLFW window!");
73 }
74
75 // make the window's context current
76 glfwMakeContextCurrent(glfwWindow);
77
78 // Setup Dear ImGui context
79 IMGUI_CHECKVERSION();
80 ImGui::CreateContext();
81 ImGuiIO &io = ImGui::GetIO();
82 io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;
83
84 ImGui_ImplGlfw_InitForOpenGL(glfwWindow, false);
85
86 // set GLFW callbacks
87 glfwSetFramebufferSizeCallback(
88 glfwWindow, [](GLFWwindow *, int newWidth, int newHeight) {

Callers

nothing calls this directly

Calls 8

eyePosMethod · 0.80
lookDirMethod · 0.80
upDirMethod · 0.80
CameraClass · 0.50
reshapeMethod · 0.45
motionMethod · 0.45
setParamMethod · 0.45
commitMethod · 0.45

Tested by

no test coverage detected