Skip to content

Commit f3b7831

Browse files
Update monitor information every frame
1 parent 50d0da2 commit f3b7831

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

examples/core/core_monitor_change.c

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -56,22 +56,19 @@ int main(void)
5656
// Update
5757
//----------------------------------------------------------------------------------
5858

59-
// Rebuild monitors array with the new monitor count
60-
if (monitorCount != GetMonitorCount())
59+
// Rebuild monitors array every frame
60+
monitorCount = GetMonitorCount();
61+
for (int i = 0; i < monitorCount; i++)
6162
{
62-
monitorCount = GetMonitorCount();
63-
for (int i = 0; i < monitorCount; i++)
64-
{
65-
monitors[i] = (Monitor){
66-
GetMonitorPosition(i),
67-
GetMonitorName(i),
68-
GetMonitorWidth(i),
69-
GetMonitorHeight(i),
70-
GetMonitorPhysicalWidth(i),
71-
GetMonitorPhysicalHeight(i),
72-
GetMonitorRefreshRate(i)
73-
};
74-
}
63+
monitors[i] = (Monitor){
64+
GetMonitorPosition(i),
65+
GetMonitorName(i),
66+
GetMonitorWidth(i),
67+
GetMonitorHeight(i),
68+
GetMonitorPhysicalWidth(i),
69+
GetMonitorPhysicalHeight(i),
70+
GetMonitorRefreshRate(i)
71+
};
7572
}
7673

7774
if (IsKeyPressed(KEY_ENTER) && monitorCount > 1)

0 commit comments

Comments
 (0)