From b66e1de97ca4afef18ac107079ad272b9f0d0ada Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Thu, 27 Dec 2012 18:37:55 +0100 Subject: [PATCH] Added saving of monitor mode count. --- src/internal.h | 1 + src/monitor.c | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/internal.h b/src/internal.h index 1ca3b111..fa272524 100644 --- a/src/internal.h +++ b/src/internal.h @@ -241,6 +241,7 @@ struct _GLFWmonitor int positionY; GLFWvidmode* modes; + int modeCount; // These are defined in the current port's platform.h _GLFW_PLATFORM_MONITOR_STATE; diff --git a/src/monitor.c b/src/monitor.c index 0ae667f1..876cf9a4 100644 --- a/src/monitor.c +++ b/src/monitor.c @@ -399,10 +399,16 @@ GLFWAPI const GLFWvidmode* glfwGetVideoModes(GLFWmonitor handle, int* count) free(monitor->modes); - monitor->modes = _glfwPlatformGetVideoModes(monitor, count); + monitor->modes = _glfwPlatformGetVideoModes(monitor, &monitor->modeCount); if (monitor->modes) - qsort(monitor->modes, *count, sizeof(GLFWvidmode), compareVideoModes); + { + qsort(monitor->modes, + monitor->modeCount, + sizeof(GLFWvidmode), + compareVideoModes); + } + *count = monitor->modeCount; return monitor->modes; }