From 23603e409c04fd0238a45552ad7b07a175b528c6 Mon Sep 17 00:00:00 2001 From: David Snopek Date: Sat, 22 Oct 2022 20:29:15 -0500 Subject: Add support for OpenGL to OpenXR --- platform/linuxbsd/x11/display_server_x11.cpp | 5 +++++ platform/linuxbsd/x11/gl_manager_x11.cpp | 11 +++++++++++ platform/linuxbsd/x11/gl_manager_x11.h | 2 ++ 3 files changed, 18 insertions(+) (limited to 'platform/linuxbsd') diff --git a/platform/linuxbsd/x11/display_server_x11.cpp b/platform/linuxbsd/x11/display_server_x11.cpp index f477787771..c3a86c69e1 100644 --- a/platform/linuxbsd/x11/display_server_x11.cpp +++ b/platform/linuxbsd/x11/display_server_x11.cpp @@ -1309,6 +1309,11 @@ int64_t DisplayServerX11::window_get_native_handle(HandleType p_handle_type, Win case WINDOW_VIEW: { return 0; // Not supported. } +#ifdef GLES3_ENABLED + case OPENGL_CONTEXT: { + return (int64_t)gl_manager->get_glx_context(p_window); + } +#endif default: { return 0; } diff --git a/platform/linuxbsd/x11/gl_manager_x11.cpp b/platform/linuxbsd/x11/gl_manager_x11.cpp index f586c57dda..893a22e75e 100644 --- a/platform/linuxbsd/x11/gl_manager_x11.cpp +++ b/platform/linuxbsd/x11/gl_manager_x11.cpp @@ -376,6 +376,17 @@ bool GLManager_X11::is_using_vsync() const { return use_vsync; } +void *GLManager_X11::get_glx_context(DisplayServer::WindowID p_window_id) { + if (p_window_id == -1) { + return nullptr; + } + + const GLWindow &win = _windows[p_window_id]; + const GLDisplay &disp = get_display(win.gldisplay_id); + + return (void *)disp.context->glx_context; +} + GLManager_X11::GLManager_X11(const Vector2i &p_size, ContextType p_context_type) { context_type = p_context_type; diff --git a/platform/linuxbsd/x11/gl_manager_x11.h b/platform/linuxbsd/x11/gl_manager_x11.h index 4f78c45c88..1594c82801 100644 --- a/platform/linuxbsd/x11/gl_manager_x11.h +++ b/platform/linuxbsd/x11/gl_manager_x11.h @@ -116,6 +116,8 @@ public: void set_use_vsync(bool p_use); bool is_using_vsync() const; + void *get_glx_context(DisplayServer::WindowID p_window_id); + GLManager_X11(const Vector2i &p_size, ContextType p_context_type); ~GLManager_X11(); }; -- cgit v1.2.3