Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementing GetMonitorWidth/Height for DRM #3956

Merged
merged 2 commits into from
May 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 60 additions & 10 deletions src/platforms/rcore_drm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down