From e3491a37445014cc3527d6f2c1467063222b2dd8 Mon Sep 17 00:00:00 2001 From: lawnjelly Date: Wed, 18 Nov 2020 18:11:30 +0000 Subject: Add GLES2 2D renderer + Linux display manager First implementation with Linux display manager. - Add single-threaded mode for EditorResourcePreview (needed for OpenGL). Co-authored-by: clayjohn Co-authored-by: Fabio Alessandrelli --- servers/display_server.cpp | 4 ++++ servers/display_server.h | 3 +++ servers/rendering/renderer_scene_cull.cpp | 4 ++++ servers/rendering/renderer_viewport.cpp | 3 +++ 4 files changed, 14 insertions(+) (limited to 'servers') diff --git a/servers/display_server.cpp b/servers/display_server.cpp index 3fb47e8f05..7bf5673663 100644 --- a/servers/display_server.cpp +++ b/servers/display_server.cpp @@ -208,6 +208,10 @@ void DisplayServer::window_set_mouse_passthrough(const Vector &p_region ERR_FAIL_MSG("Mouse passthrough not supported by this display server."); } +void DisplayServer::gl_window_make_current(DisplayServer::WindowID p_window_id) { + // noop except in gles +} + void DisplayServer::window_set_ime_active(const bool p_active, WindowID p_window) { WARN_PRINT("IME not supported by this display server."); } diff --git a/servers/display_server.h b/servers/display_server.h index 2595cf2eb8..2d837dbef9 100644 --- a/servers/display_server.h +++ b/servers/display_server.h @@ -298,6 +298,9 @@ public: virtual void window_set_ime_active(const bool p_active, WindowID p_window = MAIN_WINDOW_ID); virtual void window_set_ime_position(const Point2i &p_pos, WindowID p_window = MAIN_WINDOW_ID); + // necessary for GL focus, may be able to use one of the existing functions for this, not sure yet + virtual void gl_window_make_current(DisplayServer::WindowID p_window_id); + virtual Point2i ime_get_selection() const; virtual String ime_get_text() const; diff --git a/servers/rendering/renderer_scene_cull.cpp b/servers/rendering/renderer_scene_cull.cpp index 8421938507..e338e526a0 100644 --- a/servers/rendering/renderer_scene_cull.cpp +++ b/servers/rendering/renderer_scene_cull.cpp @@ -3855,6 +3855,10 @@ void RendererSceneCull::update() { } bool RendererSceneCull::free(RID p_rid) { + if (p_rid.is_null()) { + return true; + } + if (scene_render->free(p_rid)) { return true; } diff --git a/servers/rendering/renderer_viewport.cpp b/servers/rendering/renderer_viewport.cpp index 347238cdaa..f312c2501f 100644 --- a/servers/rendering/renderer_viewport.cpp +++ b/servers/rendering/renderer_viewport.cpp @@ -129,6 +129,9 @@ void RendererViewport::_draw_viewport(Viewport *p_viewport) { timestamp_vp_map[rt_id] = p_viewport->self; } + // This is currently needed for GLES to keep the current window being rendered to up to date + DisplayServer::get_singleton()->gl_window_make_current(p_viewport->viewport_to_screen); + /* Camera should always be BEFORE any other 3D */ bool scenario_draw_canvas_bg = false; //draw canvas, or some layer of it, as BG for 3D instead of in front -- cgit v1.2.3