Skip to content

Commit fa2b1c8

Browse files
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.
1 parent f69ae58 commit fa2b1c8

File tree

1 file changed

+60
-10
lines changed

1 file changed

+60
-10
lines changed

src/platforms/rcore_drm.c

Lines changed: 60 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -388,29 +388,69 @@ Vector2 GetMonitorPosition(int monitor)
388388
// Get selected monitor width (currently used by monitor)
389389
int GetMonitorWidth(int monitor)
390390
{
391-
TRACELOG(LOG_WARNING, "GetMonitorWidth() not implemented on target platform");
392-
return 0;
391+
int width = 0;
392+
393+
if (monitor != 0)
394+
{
395+
TRACELOG(LOG_WARNING, "GetMonitorWidth() implemented for first monitor only");
396+
}
397+
else if ((platform.connector) && (platform.modeIndex >= 0))
398+
{
399+
width = platform.connector->modes[platform.modeIndex].hdisplay;
400+
}
401+
402+
return width;
393403
}
394404

395405
// Get selected monitor height (currently used by monitor)
396406
int GetMonitorHeight(int monitor)
397407
{
398-
TRACELOG(LOG_WARNING, "GetMonitorHeight() not implemented on target platform");
399-
return 0;
408+
int height = 0;
409+
410+
if (monitor != 0)
411+
{
412+
TRACELOG(LOG_WARNING, "GetMonitorHeight() implemented for first monitor only");
413+
}
414+
else if ((platform.connector) && (platform.modeIndex >= 0))
415+
{
416+
height = platform.connector->modes[platform.modeIndex].vdisplay;
417+
}
418+
419+
return height;
400420
}
401421

402422
// Get selected monitor physical width in millimetres
403423
int GetMonitorPhysicalWidth(int monitor)
404424
{
405-
TRACELOG(LOG_WARNING, "GetMonitorPhysicalWidth() not implemented on target platform");
406-
return 0;
425+
int physicalWidth = 0;
426+
427+
if (monitor != 0)
428+
{
429+
TRACELOG(LOG_WARNING, "GetMonitorPhysicalWidth() implemented for first monitor only");
430+
}
431+
else if ((platform.connector) && (platform.modeIndex >= 0))
432+
{
433+
physicalWidth = platform.connector->mmWidth;
434+
}
435+
436+
return physicalWidth;
407437
}
408438

409439
// Get selected monitor physical height in millimetres
410440
int GetMonitorPhysicalHeight(int monitor)
411441
{
412-
TRACELOG(LOG_WARNING, "GetMonitorPhysicalHeight() not implemented on target platform");
413-
return 0;
442+
int physicalHeight = 0;
443+
444+
if (monitor != 0)
445+
{
446+
TRACELOG(LOG_WARNING, "GetMonitorPhysicalHeight() implemented for first monitor only");
447+
}
448+
else if ((platform.connector) && (platform.modeIndex >= 0))
449+
{
450+
physicalHeight = platform.connector->mmHeight;
451+
}
452+
453+
return physicalHeight;
414454
}
415455

416456
// Get selected monitor refresh rate
@@ -429,8 +469,18 @@ int GetMonitorRefreshRate(int monitor)
429469
// Get the human-readable, UTF-8 encoded name of the selected monitor
430470
const char *GetMonitorName(int monitor)
431471
{
432-
TRACELOG(LOG_WARNING, "GetMonitorName() not implemented on target platform");
433-
return "";
472+
const char *name = "";
473+
474+
if (monitor != 0)
475+
{
476+
TRACELOG(LOG_WARNING, "GetMonitorName() implemented for first monitor only");
477+
}
478+
else if ((platform.connector) && (platform.modeIndex >= 0))
479+
{
480+
name = platform.connector->modes[platform.modeIndex].name;
481+
}
482+
483+
return name;
434484
}
435485

436486
// Get window position XY on monitor

0 commit comments

Comments
 (0)