mirror of
https://github.com/raysan5/raylib.git
synced 2025-12-06 06:13:10 +00:00
Update core_monitor_detector.c
This commit is contained in:
parent
e1d5adb326
commit
80e164fa04
@ -40,10 +40,9 @@ int main(void)
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
|
||||
MonitorInfo monitors[MAX_MONITORS] = { 0 };
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - monitor detector");
|
||||
|
||||
MonitorInfo monitors[MAX_MONITORS] = { 0 };
|
||||
int currentMonitorIndex = GetCurrentMonitor();
|
||||
int monitorCount = 0;
|
||||
|
||||
@ -55,7 +54,6 @@ int main(void)
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Variables to find the max x and Y to calculate the scale
|
||||
int maxWidth = 1;
|
||||
int maxHeight = 1;
|
||||
@ -76,7 +74,8 @@ int main(void)
|
||||
GetMonitorPhysicalHeight(i),
|
||||
GetMonitorRefreshRate(i)
|
||||
};
|
||||
if (monitors[i].position.x < monitorOffsetX) monitorOffsetX = (int)monitors[i].position.x*-1;
|
||||
|
||||
if (monitors[i].position.x < monitorOffsetX) monitorOffsetX = -(int)monitors[i].position.x;
|
||||
|
||||
const int width = (int)monitors[i].position.x + monitors[i].width;
|
||||
const int height = (int)monitors[i].position.y + monitors[i].height;
|
||||
@ -85,7 +84,7 @@ int main(void)
|
||||
if (maxHeight < height) maxHeight = height;
|
||||
}
|
||||
|
||||
if (IsKeyPressed(KEY_ENTER) && monitorCount > 1)
|
||||
if (IsKeyPressed(KEY_ENTER) && (monitorCount > 1))
|
||||
{
|
||||
currentMonitorIndex += 1;
|
||||
|
||||
@ -94,16 +93,13 @@ int main(void)
|
||||
|
||||
SetWindowMonitor(currentMonitorIndex); // Move window to currentMonitorIndex
|
||||
}
|
||||
else
|
||||
{
|
||||
// Get currentMonitorIndex if manually moved
|
||||
currentMonitorIndex = GetCurrentMonitor();
|
||||
}
|
||||
else currentMonitorIndex = GetCurrentMonitor(); // Get currentMonitorIndex if manually moved
|
||||
|
||||
float monitorScale = 0.6f;
|
||||
|
||||
if(maxHeight > maxWidth + monitorOffsetX) monitorScale *= ((float)screenHeight/(float)maxHeight);
|
||||
if (maxHeight > (maxWidth + monitorOffsetX)) monitorScale *= ((float)screenHeight/(float)maxHeight);
|
||||
else monitorScale *= ((float)screenWidth/(float)(maxWidth + monitorOffsetX));
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
@ -148,14 +144,9 @@ int main(void)
|
||||
// Draw window position based on monitors
|
||||
DrawRectangleV(windowPosition, (Vector2){screenWidth * monitorScale, screenHeight * monitorScale}, Fade(GREEN, 0.5));
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawRectangleLinesEx(rec, 5, GRAY);
|
||||
else DrawRectangleLinesEx(rec, 5, GRAY);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user