Skip to content

Commit

Permalink
Use glfw null platform auto selection
Browse files Browse the repository at this point in the history
  • Loading branch information
ssheorey committed Jan 6, 2025
1 parent 78f8e37 commit 9152bef
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 18 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ubuntu-sycl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
name: open3d-sycl-linux-wheel-and-binary
path: |
open3d-*.whl
open3d-*.tar.xz
open3d-devel-*.tar.xz
if-no-files-found: error
- name: Update devel release
if: ${{ github.ref == 'refs/heads/main' && matrix.BUILD_SHARED_LIBS == 'ON' }}
Expand All @@ -71,7 +71,7 @@ jobs:
run: |
if [ ${{ matrix.BUILD_SHARED_LIBS }} == 'ON' ] ; then
gh release upload main-devel open3d-*.whl --clobber
gh release upload main-devel open3d-*.tar.xz --clobber
gh release upload main-devel open3d-devel-*.tar.xz --clobber
fi
gh release view main-devel
Expand Down
6 changes: 0 additions & 6 deletions cpp/open3d/visualization/gui/GLFWWindowSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,9 @@ int KeymodsFromGLFW(int glfw_mods) {
}

float CallGLFWGetWindowContentScale(GLFWwindow* w) {
// Ubuntu 18.04 uses GLFW 3.1, which doesn't have this function
#if (GLFW_VERSION_MAJOR > 3 || \
(GLFW_VERSION_MAJOR == 3 && GLFW_VERSION_MINOR >= 3))
float xscale, yscale;
glfwGetWindowContentScale(w, &xscale, &yscale);
return std::min(xscale, yscale);
#else
return 1.0f;
#endif // GLFW version >= 3.3
}

} // namespace
Expand Down
31 changes: 21 additions & 10 deletions cpp/open3d/visualization/visualizer/Visualizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,22 @@ class GLFWContext {
// framework build version of Python.
glfwInitHint(GLFW_COCOA_CHDIR_RESOURCES, GLFW_FALSE);
#endif
init_status_ = glfwInit();
if (!(init_status_ = glfwInit())) {
glfwInitHint(GLFW_PLATFORM, GLFW_PLATFORM_NULL);
init_status_ = glfwInit();
if (init_status_ == GLFW_TRUE) {
init_status_ = GLFW_PLATFORM_NULL;
utility::LogWarning("GLFW initilized with NULL platform.");
}
}
}

GLFWContext(const GLFWContext &) = delete;
GLFWContext &operator=(const GLFWContext &) = delete;

public:
~GLFWContext() {
if (init_status_ == GLFW_TRUE) {
if (init_status_ != GLFW_FALSE) {
glfwTerminate();
utility::LogDebug("GLFW destruct.");
}
Expand Down Expand Up @@ -109,19 +116,23 @@ bool Visualizer::CreateVisualizerWindow(
utility::LogDebug("[Visualizer] Creating window.");
glfwSetErrorCallback(GLFWContext::GLFWErrorCallback);
glfw_context_ = GLFWContext::GetInstance();
if (glfw_context_->InitStatus() != GLFW_TRUE) {
if (glfw_context_->InitStatus() == GLFW_FALSE) {
utility::LogWarning("Failed to initialize GLFW");
return false;
}

glfwWindowHint(GLFW_SAMPLES, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
#ifndef HEADLESS_RENDERING
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
#endif
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_VISIBLE, visible ? 1 : 0);
int visible_hint = visible ? 1 : 0;
if (glfw_context_->InitStatus() == GLFW_PLATFORM_NULL) {
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_FALSE);
visible_hint = 0; // NULL platform does not support visible window
} else {
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
}
glfwWindowHint(GLFW_VISIBLE, visible_hint);

window_ = glfwCreateWindow(width, height, window_name_.c_str(), NULL, NULL);
if (!window_) {
Expand Down Expand Up @@ -279,9 +290,9 @@ void Visualizer::Run() {
if (animation_callback_func_in_loop_(this)) {
UpdateGeometry();
}
// Set render flag as dirty anyways, because when we use callback
// functions, we assume something has been changed in the callback
// and the redraw event should be triggered.
// Set render flag as dirty anyways, because when we use
// callback functions, we assume something has been changed in
// the callback and the redraw event should be triggered.
UpdateRender();
}
}
Expand Down

0 comments on commit 9152bef

Please sign in to comment.