Skip to content

Commit

Permalink
Expose OS::get_current_video_driver to scripting languages
Browse files Browse the repository at this point in the history
  • Loading branch information
akien-mga committed Feb 16, 2019
1 parent fd60724 commit 7a79eee
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 13 deletions.
13 changes: 11 additions & 2 deletions core/bind/core_bind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,12 @@ int _OS::get_video_driver_count() const {
return OS::get_singleton()->get_video_driver_count();
}

String _OS::get_video_driver_name(int p_driver) const {
return OS::get_singleton()->get_video_driver_name(p_driver);
String _OS::get_video_driver_name(VideoDriver p_driver) const {
return OS::get_singleton()->get_video_driver_name((int)p_driver);
}

_OS::VideoDriver _OS::get_current_video_driver() const {
return (VideoDriver)OS::get_singleton()->get_current_video_driver();
}

int _OS::get_audio_driver_count() const {
Expand Down Expand Up @@ -1108,6 +1112,8 @@ void _OS::_bind_methods() {

ClassDB::bind_method(D_METHOD("get_video_driver_count"), &_OS::get_video_driver_count);
ClassDB::bind_method(D_METHOD("get_video_driver_name", "driver"), &_OS::get_video_driver_name);
ClassDB::bind_method(D_METHOD("get_current_video_driver"), &_OS::get_current_video_driver);

ClassDB::bind_method(D_METHOD("get_audio_driver_count"), &_OS::get_audio_driver_count);
ClassDB::bind_method(D_METHOD("get_audio_driver_name", "driver"), &_OS::get_audio_driver_name);
ClassDB::bind_method(D_METHOD("get_connected_midi_inputs"), &_OS::get_connected_midi_inputs);
Expand Down Expand Up @@ -1276,6 +1282,9 @@ void _OS::_bind_methods() {
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");

BIND_ENUM_CONSTANT(VIDEO_DRIVER_GLES2);
BIND_ENUM_CONSTANT(VIDEO_DRIVER_GLES3);

BIND_ENUM_CONSTANT(DAY_SUNDAY);
BIND_ENUM_CONSTANT(DAY_MONDAY);
BIND_ENUM_CONSTANT(DAY_TUESDAY);
Expand Down
9 changes: 8 additions & 1 deletion core/bind/core_bind.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ class _OS : public Object {
static _OS *singleton;

public:
enum VideoDriver {
VIDEO_DRIVER_GLES3,
VIDEO_DRIVER_GLES2,
};

enum PowerState {
POWERSTATE_UNKNOWN, /**< cannot determine power status */
POWERSTATE_ON_BATTERY, /**< Not plugged in, running on the battery */
Expand Down Expand Up @@ -152,7 +157,8 @@ class _OS : public Object {
Array get_fullscreen_mode_list(int p_screen = 0) const;

virtual int get_video_driver_count() const;
virtual String get_video_driver_name(int p_driver) const;
virtual String get_video_driver_name(VideoDriver p_driver) const;
virtual VideoDriver get_current_video_driver() const;

virtual int get_audio_driver_count() const;
virtual String get_audio_driver_name(int p_driver) const;
Expand Down Expand Up @@ -355,6 +361,7 @@ class _OS : public Object {
_OS();
};

VARIANT_ENUM_CAST(_OS::VideoDriver);
VARIANT_ENUM_CAST(_OS::PowerState);
VARIANT_ENUM_CAST(_OS::Weekday);
VARIANT_ENUM_CAST(_OS::Month);
Expand Down
6 changes: 6 additions & 0 deletions doc/classes/Animation.xml
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,12 @@
The animation step value.
</member>
</members>
<signals>
<signal name="tracks_changed">
<description>
</description>
</signal>
</signals>
<constants>
<constant name="TYPE_VALUE" value="0" enum="TrackType">
Value tracks set values in node properties, but only those which can be Interpolated.
Expand Down
18 changes: 18 additions & 0 deletions doc/classes/MultiMesh.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@
Return the transform of a specific instance.
</description>
</method>
<method name="get_instance_transform_2d" qualifiers="const">
<return type="Transform2D">
</return>
<argument index="0" name="instance" type="int">
</argument>
<description>
</description>
</method>
<method name="set_instance_color">
<return type="void">
</return>
Expand Down Expand Up @@ -81,6 +89,16 @@
Set the transform for a specific instance.
</description>
</method>
<method name="set_instance_transform_2d">
<return type="void">
</return>
<argument index="0" name="instance" type="int">
</argument>
<argument index="1" name="transform" type="Transform2D">
</argument>
<description>
</description>
</method>
</methods>
<members>
<member name="color_format" type="int" setter="set_color_format" getter="get_color_format" enum="MultiMesh.ColorFormat">
Expand Down
17 changes: 16 additions & 1 deletion doc/classes/OS.xml
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,13 @@
<description>
</description>
</method>
<method name="get_current_video_driver" qualifiers="const">
<return type="int" enum="OS.VideoDriver">
</return>
<description>
Returns the currently used video driver, using one of the values from [enum OS.VideoDriver].
</description>
</method>
<method name="get_date" qualifiers="const">
<return type="Dictionary">
</return>
Expand Down Expand Up @@ -459,14 +466,16 @@
<return type="int">
</return>
<description>
Returns the number of video drivers supported on the current platform.
</description>
</method>
<method name="get_video_driver_name" qualifiers="const">
<return type="String">
</return>
<argument index="0" name="driver" type="int">
<argument index="0" name="driver" type="int" enum="OS.VideoDriver">
</argument>
<description>
Returns the name of the video driver matching the given [code]driver[/code] index. This index is a value from [enum OS.VideoDriver], and you can use [method get_current_video_driver] to get the current backend's index.
</description>
</method>
<method name="get_virtual_keyboard_height">
Expand Down Expand Up @@ -806,6 +815,12 @@
</member>
</members>
<constants>
<constant name="VIDEO_DRIVER_GLES2" value="1" enum="VideoDriver">
The GLES2 rendering backend. It uses OpenGL ES 2.0 on mobile devices, OpenGL 2.1 on desktop platforms and WebGL 1.0 on the web.
</constant>
<constant name="VIDEO_DRIVER_GLES3" value="0" enum="VideoDriver">
The GLES3 rendering backend. It uses OpenGL ES 3.0 on mobile devices, OpenGL 3.3 on desktop platforms and WebGL 2.0 on the web.
</constant>
<constant name="DAY_SUNDAY" value="0" enum="Weekday">
Sunday.
</constant>
Expand Down
18 changes: 9 additions & 9 deletions doc/classes/OptionButton.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@
Return the ID of the item at index [code]idx[/code].
</description>
</method>
<method name="get_item_index" qualifiers="const">
<return type="int">
</return>
<argument index="0" name="id" type="int">
</argument>
<description>
Return the index of the item with the given [code]id[/code].
</description>
</method>
<method name="get_item_index" qualifiers="const">
<return type="int">
</return>
<argument index="0" name="id" type="int">
</argument>
<description>
Return the index of the item with the given [code]id[/code].
</description>
</method>
<method name="get_item_metadata" qualifiers="const">
<return type="Variant">
</return>
Expand Down
2 changes: 2 additions & 0 deletions doc/classes/TabContainer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@
</theme_item>
<theme_item name="tab_bg" type="StyleBox">
</theme_item>
<theme_item name="tab_disabled" type="StyleBox">
</theme_item>
<theme_item name="tab_fg" type="StyleBox">
</theme_item>
<theme_item name="top_margin" type="int">
Expand Down
2 changes: 2 additions & 0 deletions doc/classes/Tabs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,8 @@
</theme_item>
<theme_item name="tab_bg" type="StyleBox">
</theme_item>
<theme_item name="tab_disabled" type="StyleBox">
</theme_item>
<theme_item name="tab_fg" type="StyleBox">
</theme_item>
<theme_item name="top_margin" type="int">
Expand Down

0 comments on commit 7a79eee

Please sign in to comment.