summaryrefslogtreecommitdiff
path: root/core/bind
diff options
context:
space:
mode:
Diffstat (limited to 'core/bind')
-rw-r--r--core/bind/core_bind.cpp49
-rw-r--r--core/bind/core_bind.h4
2 files changed, 37 insertions, 16 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp
index 45d089599b..31c0c0e208 100644
--- a/core/bind/core_bind.cpp
+++ b/core/bind/core_bind.cpp
@@ -226,6 +226,11 @@ Size2 _OS::get_screen_size(int p_screen) const {
return OS::get_singleton()->get_screen_size(p_screen);
}
+int _OS::get_screen_dpi(int p_screen) const {
+
+ return OS::get_singleton()->get_screen_dpi(p_screen);
+}
+
Point2 _OS::get_window_position() const {
return OS::get_singleton()->get_window_position();
}
@@ -431,6 +436,15 @@ Error _OS::set_thread_name(const String& p_name) {
return Thread::set_name(p_name);
};
+void _OS::set_use_vsync(bool p_enable) {
+ OS::get_singleton()->set_use_vsync(p_enable);
+}
+
+bool _OS::is_vsnc_enabled() const {
+
+ return OS::get_singleton()->is_vsnc_enabled();
+}
+
/*
enum Weekday {
@@ -500,9 +514,9 @@ void _OS::set_icon(const Image& p_icon) {
}
/**
- * Get current datetime with consideration for utc and
+ * Get current datetime with consideration for utc and
* dst
- */
+ */
Dictionary _OS::get_datetime(bool utc) const {
Dictionary dated = get_date(utc);
@@ -564,17 +578,17 @@ uint64_t _OS::get_unix_time_from_datetime(Dictionary datetime) const {
// Get all time values from the dictionary, set to zero if it doesn't exist.
// Risk incorrect calculation over throwing errors
- unsigned int second = ((datetime.has(SECOND_KEY))?
+ unsigned int second = ((datetime.has(SECOND_KEY))?
static_cast<unsigned int>(datetime[SECOND_KEY]): 0);
- unsigned int minute = ((datetime.has(MINUTE_KEY))?
+ unsigned int minute = ((datetime.has(MINUTE_KEY))?
static_cast<unsigned int>(datetime[MINUTE_KEY]): 0);
- unsigned int hour = ((datetime.has(HOUR_KEY))?
+ unsigned int hour = ((datetime.has(HOUR_KEY))?
static_cast<unsigned int>(datetime[HOUR_KEY]): 0);
- unsigned int day = ((datetime.has(DAY_KEY))?
+ unsigned int day = ((datetime.has(DAY_KEY))?
static_cast<unsigned int>(datetime[DAY_KEY]): 0);
- unsigned int month = ((datetime.has(MONTH_KEY))?
+ unsigned int month = ((datetime.has(MONTH_KEY))?
static_cast<unsigned int>(datetime[MONTH_KEY]) -1: 0);
- unsigned int year = ((datetime.has(YEAR_KEY))?
+ unsigned int year = ((datetime.has(YEAR_KEY))?
static_cast<unsigned int>(datetime[YEAR_KEY]):0);
/// How many days come before each month (0-12)
@@ -604,7 +618,7 @@ uint64_t _OS::get_unix_time_from_datetime(Dictionary datetime) const {
ERR_FAIL_COND_V( day > MONTH_DAYS_TABLE[LEAPYEAR(year)][month], 0);
// Calculate all the seconds from months past in this year
- uint64_t SECONDS_FROM_MONTHS_PAST_THIS_YEAR =
+ uint64_t SECONDS_FROM_MONTHS_PAST_THIS_YEAR =
DAYS_PAST_THIS_YEAR_TABLE[LEAPYEAR(year)][month] * SECONDS_PER_DAY;
uint64_t SECONDS_FROM_YEARS_PAST = 0;
@@ -614,13 +628,13 @@ uint64_t _OS::get_unix_time_from_datetime(Dictionary datetime) const {
SECONDS_PER_DAY;
}
- uint64_t epoch =
- second +
- minute * SECONDS_PER_MINUTE +
+ uint64_t epoch =
+ second +
+ minute * SECONDS_PER_MINUTE +
hour * SECONDS_PER_HOUR +
// Subtract 1 from day, since the current day isn't over yet
// and we cannot count all 24 hours.
- (day-1) * SECONDS_PER_DAY +
+ (day-1) * SECONDS_PER_DAY +
SECONDS_FROM_MONTHS_PAST_THIS_YEAR +
SECONDS_FROM_YEARS_PAST;
return epoch;
@@ -631,7 +645,7 @@ uint64_t _OS::get_unix_time_from_datetime(Dictionary datetime) const {
* Get a dictionary of time values when given epoch time
*
* Dictionary Time values will be a union if values from #get_time
- * and #get_date dictionaries (with the exception of dst =
+ * and #get_date dictionaries (with the exception of dst =
* day light standard time, as it cannot be determined from epoch)
*
* @param unix_time_val epoch time to convert
@@ -660,14 +674,14 @@ Dictionary _OS::get_datetime_from_unix_time( uint64_t unix_time_val) const {
time.hour = dayclock / 3600;
/* day 0 was a thursday */
- date.weekday = static_cast<OS::Weekday>((dayno + 4) % 7);
+ date.weekday = static_cast<OS::Weekday>((dayno + 4) % 7);
while (dayno >= YEARSIZE(year)) {
dayno -= YEARSIZE(year);
year++;
}
- date.year = year;
+ date.year = year;
size_t imonth = 0;
@@ -984,6 +998,7 @@ void _OS::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_current_screen","screen"),&_OS::set_current_screen);
ObjectTypeDB::bind_method(_MD("get_screen_position","screen"),&_OS::get_screen_position,DEFVAL(0));
ObjectTypeDB::bind_method(_MD("get_screen_size","screen"),&_OS::get_screen_size,DEFVAL(0));
+ ObjectTypeDB::bind_method(_MD("get_screen_dpi","screen"),&_OS::get_screen_dpi,DEFVAL(0));
ObjectTypeDB::bind_method(_MD("get_window_position"),&_OS::get_window_position);
ObjectTypeDB::bind_method(_MD("set_window_position","position"),&_OS::set_window_position);
ObjectTypeDB::bind_method(_MD("get_window_size"),&_OS::get_window_size);
@@ -1104,6 +1119,8 @@ void _OS::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_thread_name","name"),&_OS::set_thread_name);
+ ObjectTypeDB::bind_method(_MD("set_use_vsync","enable"),&_OS::set_use_vsync);
+ ObjectTypeDB::bind_method(_MD("is_vsnc_enabled"),&_OS::is_vsnc_enabled);
BIND_CONSTANT( DAY_SUNDAY );
BIND_CONSTANT( DAY_MONDAY );
diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h
index 0c768651ff..441927940d 100644
--- a/core/bind/core_bind.h
+++ b/core/bind/core_bind.h
@@ -117,6 +117,7 @@ public:
virtual void set_current_screen(int p_screen);
virtual Point2 get_screen_position(int p_screen=0) const;
virtual Size2 get_screen_size(int p_screen=0) const;
+ virtual int get_screen_dpi(int p_screen=0) const;
virtual Point2 get_window_position() const;
virtual void set_window_position(const Point2& p_position);
virtual Size2 get_window_size() const;
@@ -281,6 +282,9 @@ public:
Error set_thread_name(const String& p_name);
+ void set_use_vsync(bool p_enable);
+ bool is_vsnc_enabled() const;
+
static _OS *get_singleton() { return singleton; }
_OS();