summaryrefslogtreecommitdiffhomepage
path: root/src/platforms
diff options
context:
space:
mode:
authorgabriel-marques <[email protected]>2024-05-07 10:33:56 +0200
committerGitHub <[email protected]>2024-05-07 10:33:56 +0200
commitfa2b1c8f094db18466079fcd2f8e488bf89095c2 (patch)
tree8da6082d92de3681c992271c4bfda4ac7f8c6ac6 /src/platforms
parentf69ae583040060ece2e6e4f813e1408c8fd04900 (diff)
downloadraylib-fa2b1c8f094db18466079fcd2f8e488bf89095c2.tar.gz
raylib-fa2b1c8f094db18466079fcd2f8e488bf89095c2.zip
Implementing GetMonitorWidth/Height for DRM (#3956)
* Implementing GetMonitorWidth/Height and GetMonitorPhysicalWidth/Height for drm Added implementation for DRM for functions : - GetMonitorWidth() - GetMonitorHeight() - GetMonitorPhysicalWidth() - GetMonitorPhysicalHeight() - GetMonnitorName() These functions take an argument but only the value 0 is accepted. This is because the DRM platform implementation manages only one screen for now * Refactor "GetMonitor" properties for DRM Platform Refactored GetMonitorHeight, GetMonitorWidth, GetMonitorPhysicalHeight, GetMonitorPhysicalWidth and GetMonitorName to accept only argument "0" as more than one screen is not supported in DRM platform.
Diffstat (limited to 'src/platforms')
-rw-r--r--src/platforms/rcore_drm.c70
1 files changed, 60 insertions, 10 deletions
diff --git a/src/platforms/rcore_drm.c b/src/platforms/rcore_drm.c
index a07ba27f..ba607146 100644
--- a/src/platforms/rcore_drm.c
+++ b/src/platforms/rcore_drm.c
@@ -388,29 +388,69 @@ Vector2 GetMonitorPosition(int monitor)
// Get selected monitor width (currently used by monitor)
int GetMonitorWidth(int monitor)
{
- TRACELOG(LOG_WARNING, "GetMonitorWidth() not implemented on target platform");
- return 0;
+ int width = 0;
+
+ if (monitor != 0)
+ {
+ TRACELOG(LOG_WARNING, "GetMonitorWidth() implemented for first monitor only");
+ }
+ else if ((platform.connector) && (platform.modeIndex >= 0))
+ {
+ width = platform.connector->modes[platform.modeIndex].hdisplay;
+ }
+
+ return width;
}
// Get selected monitor height (currently used by monitor)
int GetMonitorHeight(int monitor)
{
- TRACELOG(LOG_WARNING, "GetMonitorHeight() not implemented on target platform");
- return 0;
+ int height = 0;
+
+ if (monitor != 0)
+ {
+ TRACELOG(LOG_WARNING, "GetMonitorHeight() implemented for first monitor only");
+ }
+ else if ((platform.connector) && (platform.modeIndex >= 0))
+ {
+ height = platform.connector->modes[platform.modeIndex].vdisplay;
+ }
+
+ return height;
}
// Get selected monitor physical width in millimetres
int GetMonitorPhysicalWidth(int monitor)
{
- TRACELOG(LOG_WARNING, "GetMonitorPhysicalWidth() not implemented on target platform");
- return 0;
+ int physicalWidth = 0;
+
+ if (monitor != 0)
+ {
+ TRACELOG(LOG_WARNING, "GetMonitorPhysicalWidth() implemented for first monitor only");
+ }
+ else if ((platform.connector) && (platform.modeIndex >= 0))
+ {
+ physicalWidth = platform.connector->mmWidth;
+ }
+
+ return physicalWidth;
}
// Get selected monitor physical height in millimetres
int GetMonitorPhysicalHeight(int monitor)
{
- TRACELOG(LOG_WARNING, "GetMonitorPhysicalHeight() not implemented on target platform");
- return 0;
+ int physicalHeight = 0;
+
+ if (monitor != 0)
+ {
+ TRACELOG(LOG_WARNING, "GetMonitorPhysicalHeight() implemented for first monitor only");
+ }
+ else if ((platform.connector) && (platform.modeIndex >= 0))
+ {
+ physicalHeight = platform.connector->mmHeight;
+ }
+
+ return physicalHeight;
}
// Get selected monitor refresh rate
@@ -429,8 +469,18 @@ int GetMonitorRefreshRate(int monitor)
// Get the human-readable, UTF-8 encoded name of the selected monitor
const char *GetMonitorName(int monitor)
{
- TRACELOG(LOG_WARNING, "GetMonitorName() not implemented on target platform");
- return "";
+ const char *name = "";
+
+ if (monitor != 0)
+ {
+ TRACELOG(LOG_WARNING, "GetMonitorName() implemented for first monitor only");
+ }
+ else if ((platform.connector) && (platform.modeIndex >= 0))
+ {
+ name = platform.connector->modes[platform.modeIndex].name;
+ }
+
+ return name;
}
// Get window position XY on monitor