mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-12-22 11:56:49 +01:00
Initial DisplayServer method setup.
This commit is contained in:
parent
c11e564b4e
commit
a99e07563d
12
core/os/os.h
12
core/os/os.h
@ -96,11 +96,12 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
enum RenderThreadMode {
|
enum RenderThreadMode {
|
||||||
|
|
||||||
RENDER_THREAD_UNSAFE,
|
RENDER_THREAD_UNSAFE,
|
||||||
RENDER_THREAD_SAFE,
|
RENDER_THREAD_SAFE,
|
||||||
RENDER_SEPARATE_THREAD
|
RENDER_SEPARATE_THREAD
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//DisplayServer
|
||||||
struct VideoMode {
|
struct VideoMode {
|
||||||
int width, height;
|
int width, height;
|
||||||
bool fullscreen;
|
bool fullscreen;
|
||||||
@ -185,10 +186,12 @@ public:
|
|||||||
virtual String get_clipboard() const;
|
virtual String get_clipboard() const;
|
||||||
virtual bool has_clipboard() const;
|
virtual bool has_clipboard() const;
|
||||||
|
|
||||||
|
//DisplayServer
|
||||||
virtual void set_video_mode(const VideoMode &p_video_mode, int p_screen = 0) = 0;
|
virtual void set_video_mode(const VideoMode &p_video_mode, int p_screen = 0) = 0;
|
||||||
virtual VideoMode get_video_mode(int p_screen = 0) const = 0;
|
virtual VideoMode get_video_mode(int p_screen = 0) const = 0;
|
||||||
virtual void get_fullscreen_mode_list(List<VideoMode> *p_list, int p_screen = 0) const = 0;
|
virtual void get_fullscreen_mode_list(List<VideoMode> *p_list, int p_screen = 0) const = 0;
|
||||||
|
|
||||||
|
// This should be customizable
|
||||||
enum VideoDriver {
|
enum VideoDriver {
|
||||||
VIDEO_DRIVER_GLES2,
|
VIDEO_DRIVER_GLES2,
|
||||||
VIDEO_DRIVER_MAX,
|
VIDEO_DRIVER_MAX,
|
||||||
@ -216,6 +219,7 @@ public:
|
|||||||
// Returned by get_screen_refresh_rate if the method fails.
|
// Returned by get_screen_refresh_rate if the method fails.
|
||||||
const float SCREEN_REFRESH_RATE_FALLBACK = -1.0;
|
const float SCREEN_REFRESH_RATE_FALLBACK = -1.0;
|
||||||
|
|
||||||
|
//DisplayServer
|
||||||
virtual int get_screen_count() const { return 1; }
|
virtual int get_screen_count() const { return 1; }
|
||||||
virtual int get_current_screen() const { return 0; }
|
virtual int get_current_screen() const { return 0; }
|
||||||
virtual void set_current_screen(int p_screen) {}
|
virtual void set_current_screen(int p_screen) {}
|
||||||
@ -278,9 +282,11 @@ public:
|
|||||||
|
|
||||||
virtual Array get_display_cutouts() const { return Array(); }
|
virtual Array get_display_cutouts() const { return Array(); }
|
||||||
|
|
||||||
|
//DisplayServer
|
||||||
virtual void set_borderless_window(bool p_borderless) {}
|
virtual void set_borderless_window(bool p_borderless) {}
|
||||||
virtual bool get_borderless_window() { return false; }
|
virtual bool get_borderless_window() { return false; }
|
||||||
|
|
||||||
|
//DisplayServer
|
||||||
virtual bool get_window_per_pixel_transparency_enabled() const { return false; }
|
virtual bool get_window_per_pixel_transparency_enabled() const { return false; }
|
||||||
virtual void set_window_per_pixel_transparency_enabled(bool p_enabled) {}
|
virtual void set_window_per_pixel_transparency_enabled(bool p_enabled) {}
|
||||||
|
|
||||||
@ -538,6 +544,7 @@ public:
|
|||||||
return FAILED;
|
return FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//DisplayServer
|
||||||
virtual void set_no_window_mode(bool p_enable);
|
virtual void set_no_window_mode(bool p_enable);
|
||||||
virtual bool is_no_window_mode_enabled() const;
|
virtual bool is_no_window_mode_enabled() const;
|
||||||
|
|
||||||
@ -559,10 +566,13 @@ public:
|
|||||||
ScreenOrientation get_screen_orientation_from_string(const String &p_orientation) const;
|
ScreenOrientation get_screen_orientation_from_string(const String &p_orientation) const;
|
||||||
|
|
||||||
virtual void enable_for_stealing_focus(ProcessID pid) {}
|
virtual void enable_for_stealing_focus(ProcessID pid) {}
|
||||||
|
//DisplayServer
|
||||||
virtual void move_window_to_foreground() {}
|
virtual void move_window_to_foreground() {}
|
||||||
|
|
||||||
virtual void release_rendering_thread();
|
virtual void release_rendering_thread();
|
||||||
virtual void make_rendering_thread();
|
virtual void make_rendering_thread();
|
||||||
|
|
||||||
|
//DisplayServer
|
||||||
virtual void swap_buffers();
|
virtual void swap_buffers();
|
||||||
|
|
||||||
virtual void set_native_icon(const String &p_filename);
|
virtual void set_native_icon(const String &p_filename);
|
||||||
|
@ -33,6 +33,10 @@
|
|||||||
DisplayServer *DisplayServer::singleton = nullptr;
|
DisplayServer *DisplayServer::singleton = nullptr;
|
||||||
DisplayServer *(*DisplayServer::create_func)() = nullptr;
|
DisplayServer *(*DisplayServer::create_func)() = nullptr;
|
||||||
|
|
||||||
|
int64_t DisplayServer::get_native_handle_bind(HandleType p_handle_type) {
|
||||||
|
return (int64_t)get_native_handle(p_handle_type);
|
||||||
|
}
|
||||||
|
|
||||||
DisplayServer *DisplayServer::get_singleton() {
|
DisplayServer *DisplayServer::get_singleton() {
|
||||||
return singleton;
|
return singleton;
|
||||||
}
|
}
|
||||||
@ -48,6 +52,90 @@ DisplayServer *DisplayServer::create() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DisplayServer::_bind_methods() {
|
void DisplayServer::_bind_methods() {
|
||||||
|
ClassDB::bind_method(D_METHOD("get_screen_count"), &DisplayServer::get_screen_count);
|
||||||
|
ClassDB::bind_method(D_METHOD("get_current_screen"), &DisplayServer::get_current_screen);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_current_screen", "screen"), &DisplayServer::set_current_screen);
|
||||||
|
ClassDB::bind_method(D_METHOD("get_screen_position", "screen"), &DisplayServer::get_screen_position, DEFVAL(-1));
|
||||||
|
ClassDB::bind_method(D_METHOD("get_screen_size", "screen"), &DisplayServer::get_screen_size, DEFVAL(-1));
|
||||||
|
ClassDB::bind_method(D_METHOD("get_screen_dpi", "screen"), &DisplayServer::get_screen_dpi, DEFVAL(-1));
|
||||||
|
ClassDB::bind_method(D_METHOD("get_screen_scale", "screen"), &DisplayServer::get_screen_scale, DEFVAL(-1));
|
||||||
|
ClassDB::bind_method(D_METHOD("get_screen_max_scale"), &DisplayServer::get_screen_max_scale);
|
||||||
|
ClassDB::bind_method(D_METHOD("get_screen_refresh_rate", "screen"), &DisplayServer::get_screen_refresh_rate, DEFVAL(-1));
|
||||||
|
ClassDB::bind_method(D_METHOD("get_window_position"), &DisplayServer::get_window_position);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_window_position", "position"), &DisplayServer::set_window_position);
|
||||||
|
ClassDB::bind_method(D_METHOD("get_window_size"), &DisplayServer::get_window_size);
|
||||||
|
ClassDB::bind_method(D_METHOD("get_max_window_size"), &DisplayServer::get_max_window_size);
|
||||||
|
ClassDB::bind_method(D_METHOD("get_min_window_size"), &DisplayServer::get_min_window_size);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_max_window_size", "size"), &DisplayServer::set_max_window_size);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_min_window_size", "size"), &DisplayServer::set_min_window_size);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_window_size", "size"), &DisplayServer::set_window_size);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_window_fullscreen", "enabled"), &DisplayServer::set_window_fullscreen);
|
||||||
|
ClassDB::bind_method(D_METHOD("is_window_fullscreen"), &DisplayServer::is_window_fullscreen);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_window_resizable", "enabled"), &DisplayServer::set_window_resizable);
|
||||||
|
ClassDB::bind_method(D_METHOD("is_window_resizable"), &DisplayServer::is_window_resizable);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_window_minimized", "enabled"), &DisplayServer::set_window_minimized);
|
||||||
|
ClassDB::bind_method(D_METHOD("is_window_minimized"), &DisplayServer::is_window_minimized);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_window_maximized", "enabled"), &DisplayServer::set_window_maximized);
|
||||||
|
ClassDB::bind_method(D_METHOD("is_window_maximized"), &DisplayServer::is_window_maximized);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_window_always_on_top", "enabled"), &DisplayServer::set_window_always_on_top);
|
||||||
|
ClassDB::bind_method(D_METHOD("is_window_always_on_top"), &DisplayServer::is_window_always_on_top);
|
||||||
|
ClassDB::bind_method(D_METHOD("is_window_focused"), &DisplayServer::is_window_focused);
|
||||||
|
ClassDB::bind_method(D_METHOD("request_attention"), &DisplayServer::request_attention);
|
||||||
|
ClassDB::bind_method(D_METHOD("get_real_window_size"), &DisplayServer::get_real_window_size);
|
||||||
|
ClassDB::bind_method(D_METHOD("center_window"), &DisplayServer::center_window);
|
||||||
|
ClassDB::bind_method(D_METHOD("move_window_to_foreground"), &DisplayServer::move_window_to_foreground);
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("get_native_handle", "handle_type"), &DisplayServer::get_native_handle_bind);
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("set_borderless_window", "borderless"), &DisplayServer::set_borderless_window);
|
||||||
|
ClassDB::bind_method(D_METHOD("get_borderless_window"), &DisplayServer::get_borderless_window);
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("get_window_per_pixel_transparency_enabled"), &DisplayServer::get_window_per_pixel_transparency_enabled);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_window_per_pixel_transparency_enabled", "enabled"), &DisplayServer::set_window_per_pixel_transparency_enabled);
|
||||||
|
|
||||||
|
|
||||||
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "current_screen"), "set_current_screen", "get_current_screen");
|
||||||
|
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "min_window_size"), "set_min_window_size", "get_min_window_size");
|
||||||
|
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "max_window_size"), "set_max_window_size", "get_max_window_size");
|
||||||
|
//Main Window
|
||||||
|
ADD_GROUP("Window", "window_");
|
||||||
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "window_borderless"), "set_borderless_window", "get_borderless_window");
|
||||||
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "window_per_pixel_transparency_enabled"), "set_window_per_pixel_transparency_enabled", "get_window_per_pixel_transparency_enabled");
|
||||||
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "window_fullscreen"), "set_window_fullscreen", "is_window_fullscreen");
|
||||||
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "window_maximized"), "set_window_maximized", "is_window_maximized");
|
||||||
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "window_minimized"), "set_window_minimized", "is_window_minimized");
|
||||||
|
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "window_resizable"), "set_window_resizable", "is_window_resizable");
|
||||||
|
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "window_position"), "set_window_position", "get_window_position");
|
||||||
|
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "window_size"), "set_window_size", "get_window_size");
|
||||||
|
|
||||||
|
// Those default values need to be specified for the docs generator,
|
||||||
|
// to avoid using values from the documentation writer's own OS instance.
|
||||||
|
ADD_PROPERTY_DEFAULT("clipboard", "");
|
||||||
|
ADD_PROPERTY_DEFAULT("current_screen", 0);
|
||||||
|
ADD_PROPERTY_DEFAULT("tablet_driver", "");
|
||||||
|
ADD_PROPERTY_DEFAULT("exit_code", 0);
|
||||||
|
ADD_PROPERTY_DEFAULT("vsync_enabled", true);
|
||||||
|
ADD_PROPERTY_DEFAULT("vsync_via_compositor", false);
|
||||||
|
ADD_PROPERTY_DEFAULT("low_processor_usage_mode", false);
|
||||||
|
ADD_PROPERTY_DEFAULT("low_processor_usage_mode_sleep_usec", 6900);
|
||||||
|
ADD_PROPERTY_DEFAULT("keep_screen_on", true);
|
||||||
|
ADD_PROPERTY_DEFAULT("min_window_size", Vector2());
|
||||||
|
ADD_PROPERTY_DEFAULT("max_window_size", Vector2());
|
||||||
|
ADD_PROPERTY_DEFAULT("screen_orientation", 0);
|
||||||
|
ADD_PROPERTY_DEFAULT("window_borderless", false);
|
||||||
|
ADD_PROPERTY_DEFAULT("window_per_pixel_transparency_enabled", false);
|
||||||
|
ADD_PROPERTY_DEFAULT("window_fullscreen", false);
|
||||||
|
ADD_PROPERTY_DEFAULT("window_maximized", false);
|
||||||
|
ADD_PROPERTY_DEFAULT("window_minimized", false);
|
||||||
|
ADD_PROPERTY_DEFAULT("window_resizable", true);
|
||||||
|
ADD_PROPERTY_DEFAULT("window_position", Vector2());
|
||||||
|
ADD_PROPERTY_DEFAULT("window_size", Vector2());
|
||||||
|
|
||||||
|
BIND_ENUM_CONSTANT(DISPLAY_HANDLE);
|
||||||
|
BIND_ENUM_CONSTANT(WINDOW_HANDLE);
|
||||||
|
BIND_ENUM_CONSTANT(WINDOW_VIEW);
|
||||||
|
BIND_ENUM_CONSTANT(OPENGL_CONTEXT);
|
||||||
|
|
||||||
//ClassDB::bind_method(D_METHOD("force_sync"), &DisplayServer::sync);
|
//ClassDB::bind_method(D_METHOD("force_sync"), &DisplayServer::sync);
|
||||||
|
|
||||||
//ClassDB::bind_method(D_METHOD("is_render_loop_enabled"), &DisplayServer::is_render_loop_enabled);
|
//ClassDB::bind_method(D_METHOD("is_render_loop_enabled"), &DisplayServer::is_render_loop_enabled);
|
||||||
|
@ -39,6 +39,91 @@ class DisplayServer : public Object {
|
|||||||
|
|
||||||
static DisplayServer *singleton;
|
static DisplayServer *singleton;
|
||||||
|
|
||||||
|
public:
|
||||||
|
const float SCREEN_REFRESH_RATE_FALLBACK = -1.0;
|
||||||
|
struct VideoMode {
|
||||||
|
int width, height;
|
||||||
|
bool fullscreen;
|
||||||
|
bool resizable;
|
||||||
|
bool borderless_window;
|
||||||
|
bool maximized;
|
||||||
|
bool always_on_top;
|
||||||
|
bool use_vsync;
|
||||||
|
bool vsync_via_compositor;
|
||||||
|
bool layered;
|
||||||
|
|
||||||
|
float get_aspect() const { return (float)width / (float)height; }
|
||||||
|
|
||||||
|
VideoMode(int p_width = 1024, int p_height = 600, bool p_fullscreen = false, bool p_resizable = true, bool p_borderless_window = false, bool p_maximized = false, bool p_always_on_top = false, bool p_use_vsync = false, bool p_vsync_via_compositor = false) {
|
||||||
|
width = p_width;
|
||||||
|
height = p_height;
|
||||||
|
fullscreen = p_fullscreen;
|
||||||
|
resizable = p_resizable;
|
||||||
|
borderless_window = p_borderless_window;
|
||||||
|
maximized = p_maximized;
|
||||||
|
always_on_top = p_always_on_top;
|
||||||
|
use_vsync = p_use_vsync;
|
||||||
|
vsync_via_compositor = p_vsync_via_compositor;
|
||||||
|
layered = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
virtual int get_screen_count() const { return 1; }
|
||||||
|
virtual int get_current_screen() const { return 0; }
|
||||||
|
virtual void set_current_screen(int p_screen) {}
|
||||||
|
virtual Point2 get_screen_position(int p_screen = -1) const { return Point2(); }
|
||||||
|
virtual Size2 get_screen_size(int p_screen = -1) const { return get_window_size(); }
|
||||||
|
virtual int get_screen_dpi(int p_screen = -1) const { return 72; }
|
||||||
|
virtual float get_screen_scale(int p_screen = -1) const { return 1.0; }
|
||||||
|
virtual float get_screen_max_scale() const { return 1.0; };
|
||||||
|
virtual float get_screen_refresh_rate(int p_screen = -1) const { return SCREEN_REFRESH_RATE_FALLBACK; };
|
||||||
|
virtual Point2 get_window_position() const { return Vector2(); }
|
||||||
|
virtual void set_window_position(const Point2 &p_position) {}
|
||||||
|
virtual Size2 get_max_window_size() const { return Size2(); };
|
||||||
|
virtual Size2 get_min_window_size() const { return Size2(); };
|
||||||
|
virtual Size2 get_window_size() const { return Size2(); };
|
||||||
|
virtual Size2 get_real_window_size() const { return get_window_size(); }
|
||||||
|
virtual void set_min_window_size(const Size2 p_size) {}
|
||||||
|
virtual void set_max_window_size(const Size2 p_size) {}
|
||||||
|
virtual void set_window_size(const Size2 p_size) {}
|
||||||
|
virtual void set_window_fullscreen(bool p_enabled) {}
|
||||||
|
virtual bool is_window_fullscreen() const { return true; }
|
||||||
|
virtual void set_window_resizable(bool p_enabled) {}
|
||||||
|
virtual bool is_window_resizable() const { return false; }
|
||||||
|
virtual void set_window_minimized(bool p_enabled) {}
|
||||||
|
virtual bool is_window_minimized() const { return false; }
|
||||||
|
virtual void set_window_maximized(bool p_enabled) {}
|
||||||
|
virtual bool is_window_maximized() const { return true; }
|
||||||
|
virtual void set_window_always_on_top(bool p_enabled) {}
|
||||||
|
virtual bool is_window_always_on_top() const { return false; }
|
||||||
|
virtual bool is_window_focused() const { return true; }
|
||||||
|
virtual void request_attention() {}
|
||||||
|
virtual void center_window() {}
|
||||||
|
|
||||||
|
//DisplayServer
|
||||||
|
enum HandleType {
|
||||||
|
DISPLAY_HANDLE, // X11::Display* ...
|
||||||
|
WINDOW_HANDLE, // HWND, X11::Window*, NSWindow*, UIWindow*, Android activity ...
|
||||||
|
WINDOW_VIEW, // HDC, NSView*, UIView*, Android surface ...
|
||||||
|
OPENGL_CONTEXT, // HGLRC, X11::GLXContext, NSOpenGLContext*, EGLContext* ...
|
||||||
|
};
|
||||||
|
|
||||||
|
virtual void *get_native_handle(int p_handle_type) { return nullptr; };
|
||||||
|
virtual int64_t get_native_handle_bind(HandleType p_handle_type);
|
||||||
|
|
||||||
|
virtual void set_borderless_window(bool p_borderless) {}
|
||||||
|
virtual bool get_borderless_window() { return false; }
|
||||||
|
|
||||||
|
virtual bool get_window_per_pixel_transparency_enabled() const { return false; }
|
||||||
|
virtual void set_window_per_pixel_transparency_enabled(bool p_enabled) {}
|
||||||
|
|
||||||
|
virtual void set_no_window_mode(bool p_enable) {}
|
||||||
|
virtual bool is_no_window_mode_enabled() const { return false; }
|
||||||
|
|
||||||
|
virtual void move_window_to_foreground() {}
|
||||||
|
|
||||||
|
virtual void swap_buffers() {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static DisplayServer *(*create_func)();
|
static DisplayServer *(*create_func)();
|
||||||
|
|
||||||
@ -48,11 +133,10 @@ public:
|
|||||||
static DisplayServer *get_singleton();
|
static DisplayServer *get_singleton();
|
||||||
static DisplayServer *create();
|
static DisplayServer *create();
|
||||||
|
|
||||||
|
|
||||||
DisplayServer();
|
DisplayServer();
|
||||||
virtual ~DisplayServer();
|
virtual ~DisplayServer();
|
||||||
};
|
};
|
||||||
|
|
||||||
//VARIANT_ENUM_CAST(DisplayServer::);
|
VARIANT_ENUM_CAST(DisplayServer::HandleType);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user