diff --git a/include/GL/glfw3.h b/include/GL/glfw3.h index 6072d211..58d2e118 100644 --- a/include/GL/glfw3.h +++ b/include/GL/glfw3.h @@ -1043,7 +1043,7 @@ GLFWAPI const GLFWvidmode* glfwGetVideoModes(GLFWmonitor* monitor, int* count); * @param[out] mode The current mode of the monitor. * @ingroup monitor */ -GLFWAPI void glfwGetVideoMode(GLFWmonitor* monitor, GLFWvidmode* mode); +GLFWAPI GLFWvidmode glfwGetVideoMode(GLFWmonitor* monitor); /*! @brief Sets the system gamma ramp to one generated from the specified * exponent. diff --git a/src/monitor.c b/src/monitor.c index 762d5032..0fae07a3 100644 --- a/src/monitor.c +++ b/src/monitor.c @@ -476,22 +476,18 @@ GLFWAPI const GLFWvidmode* glfwGetVideoModes(GLFWmonitor* handle, int* count) // Get the current video mode for the specified monitor //======================================================================== -GLFWAPI void glfwGetVideoMode(GLFWmonitor* handle, GLFWvidmode* mode) +GLFWAPI GLFWvidmode glfwGetVideoMode(GLFWmonitor* handle) { _GLFWmonitor* monitor = (_GLFWmonitor*) handle; + GLFWvidmode mode = { 0, 0, 0, 0, 0 }; if (!_glfwInitialized) { _glfwInputError(GLFW_NOT_INITIALIZED, NULL); - return; + return mode; } - if (mode == NULL) - { - _glfwInputError(GLFW_INVALID_VALUE, NULL); - return; - } - - _glfwPlatformGetVideoMode(monitor, mode); + _glfwPlatformGetVideoMode(monitor, &mode); + return mode; } diff --git a/tests/events.c b/tests/events.c index 041456d3..1b99f037 100644 --- a/tests/events.c +++ b/tests/events.c @@ -346,8 +346,7 @@ void monitor_callback(GLFWmonitor* monitor, int event) { if (event == GLFW_CONNECTED) { - GLFWvidmode mode; - glfwGetVideoMode(monitor, &mode); + GLFWvidmode mode = glfwGetVideoMode(monitor); printf("%08x at %0.3f: Monitor %s (%ix%i at %ix%i, %ix%i mm) was connected\n", counter++, diff --git a/tests/gamma.c b/tests/gamma.c index 4b74da8d..4919d2cf 100644 --- a/tests/gamma.c +++ b/tests/gamma.c @@ -130,8 +130,7 @@ int main(int argc, char** argv) if (monitor) { - GLFWvidmode mode; - glfwGetVideoMode(monitor, &mode); + GLFWvidmode mode = glfwGetVideoMode(monitor); width = mode.width; height = mode.height; } diff --git a/tests/iconify.c b/tests/iconify.c index ac7cc694..796339f2 100644 --- a/tests/iconify.c +++ b/tests/iconify.c @@ -125,8 +125,7 @@ int main(int argc, char** argv) if (monitor) { - GLFWvidmode mode; - glfwGetVideoMode(monitor, &mode); + GLFWvidmode mode = glfwGetVideoMode(monitor); width = mode.width; height = mode.height; } diff --git a/tests/modes.c b/tests/modes.c index ecd3baf1..d2b8d08e 100644 --- a/tests/modes.c +++ b/tests/modes.c @@ -93,11 +93,9 @@ static void key_callback(GLFWwindow* window, int key, int action) static void list_modes(GLFWmonitor* monitor) { int count, widthMM, heightMM, dpi, i; - GLFWvidmode mode; + GLFWvidmode mode = glfwGetVideoMode(monitor); const GLFWvidmode* modes = glfwGetVideoModes(monitor, &count); - glfwGetVideoMode(monitor, &mode); - printf("Name: %s (%s)\n", glfwGetMonitorName(monitor), glfwGetPrimaryMonitor() == monitor ? "primary" : "secondary");