summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorraysan5 <[email protected]>2020-04-24 23:17:32 +0200
committerraysan5 <[email protected]>2020-04-24 23:17:32 +0200
commit8e59ecb50c0bbf2e46c7c6cf8deb09a3c31c42e7 (patch)
tree3a01856965b676563596f4c21c584573ce8f4d30
parentb73e7372d85af13f2f7cfba9cd1fe8bc72778082 (diff)
downloadraylib-8e59ecb50c0bbf2e46c7c6cf8deb09a3c31c42e7.tar.gz
raylib-8e59ecb50c0bbf2e46c7c6cf8deb09a3c31c42e7.zip
ADDED: GetWindowScaleDPI()
-rw-r--r--src/core.c18
-rw-r--r--src/raylib.h1
2 files changed, 18 insertions, 1 deletions
diff --git a/src/core.c b/src/core.c
index 58eedbcb..7c363214 100644
--- a/src/core.c
+++ b/src/core.c
@@ -1138,6 +1138,21 @@ Vector2 GetWindowPosition(void)
return (Vector2){ (float)x, (float)y };
}
+// Get window scale DPI factor
+Vector2 GetWindowScaleDPI(void)
+{
+ Vector2 scale = { 1.0f, 1.0f };
+
+#if defined(PLATFORM_DESKTOP)
+ GLFWmonitor *monitor = glfwGetPrimaryMonitor();
+
+ if (monitor != NULL) glfwGetMonitorContentScale(monitor, &scale.x, &scale.y);
+ else TRACELOG(LOG_WARNING, "GLFW: Failed to get primary monitor");
+#endif
+
+ return scale;
+}
+
// Get the human-readable, UTF-8 encoded name of the primary monitor
const char *GetMonitorName(int monitor)
{
@@ -4245,7 +4260,8 @@ static int32_t AndroidInputCallback(struct android_app *app, AInputEvent *event)
if (type == AINPUT_EVENT_TYPE_MOTION)
{
- if ((source & AINPUT_SOURCE_JOYSTICK) == AINPUT_SOURCE_JOYSTICK || (source & AINPUT_SOURCE_GAMEPAD) == AINPUT_SOURCE_GAMEPAD)
+ if (((source & AINPUT_SOURCE_JOYSTICK) == AINPUT_SOURCE_JOYSTICK) ||
+ ((source & AINPUT_SOURCE_GAMEPAD) == AINPUT_SOURCE_GAMEPAD))
{
// Get first touch position
CORE.Input.Touch.position[0].x = AMotionEvent_getX(event, 0);
diff --git a/src/raylib.h b/src/raylib.h
index 627fa1d6..81e1a3d1 100644
--- a/src/raylib.h
+++ b/src/raylib.h
@@ -895,6 +895,7 @@ RLAPI int GetMonitorHeight(int monitor); // Get primary
RLAPI int GetMonitorPhysicalWidth(int monitor); // Get primary monitor physical width in millimetres
RLAPI int GetMonitorPhysicalHeight(int monitor); // Get primary monitor physical height in millimetres
RLAPI Vector2 GetWindowPosition(void); // Get window position XY on monitor
+RLAPI Vector2 GetWindowScaleDPI(void); // Get window scale DPI factor
RLAPI const char *GetMonitorName(int monitor); // Get the human-readable, UTF-8 encoded name of the primary monitor
RLAPI const char *GetClipboardText(void); // Get clipboard text content
RLAPI void SetClipboardText(const char *text); // Set clipboard text content