From b8c16e49f1bb677e0b9de44c3b1a4efaf472f42f Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Thu, 22 Nov 2012 17:04:54 +0100 Subject: [PATCH] Removed window size DWIM. --- include/GL/glfw3.h | 10 ++++------ src/window.c | 19 ++++--------------- tests/clipboard.c | 2 +- tests/defaults.c | 2 +- tests/events.c | 2 +- tests/gamma.c | 4 ++-- tests/glfwinfo.c | 2 +- tests/iconify.c | 4 ++-- tests/joysticks.c | 2 +- tests/peter.c | 2 +- tests/tearing.c | 2 +- tests/title.c | 2 +- 12 files changed, 20 insertions(+), 33 deletions(-) diff --git a/include/GL/glfw3.h b/include/GL/glfw3.h index 73a84d07..ba2184da 100644 --- a/include/GL/glfw3.h +++ b/include/GL/glfw3.h @@ -1063,12 +1063,10 @@ GLFWAPI void glfwWindowHint(int target, int hint); /*! @brief Creates a window and its associated context. * - * @param[in] width The desired width, in pixels, of the window. If @p width - * is zero, it will be set to 4/3 times @p height. If both are zero, it will - * be set to 640. - * @param[in] height The desired height, in pixels, of the window. If @p - * height is zero, it will be set to 3/4 times @p width. If both are zero, it - * will be set to 480. + * @param[in] width The desired width, in pixels, of the window. This must be + * greater than zero. + * @param[in] height The desired height, in pixels, of the window. This must + * be greater than zero. * @param[in] mode One of @ref GLFW_WINDOWED or @ref GLFW_FULLSCREEN. * @param[in] title The initial, UTF-8 encoded window title. * @param[in] share The window whose context to share resources with, or @c diff --git a/src/window.c b/src/window.c index ed6d2435..908a2a7c 100644 --- a/src/window.c +++ b/src/window.c @@ -263,22 +263,11 @@ GLFWAPI GLFWwindow glfwCreateWindow(int width, int height, return GL_FALSE; } - // Check width & height - if (width > 0 && height <= 0) + if (width <= 0 || height <= 0) { - // Set the window aspect ratio to 4:3 - height = (width * 3) / 4; - } - else if (width <= 0 && height > 0) - { - // Set the window aspect ratio to 4:3 - width = (height * 4) / 3; - } - else if (width <= 0 && height <= 0) - { - // Default window size - width = 640; - height = 480; + _glfwSetError(GLFW_INVALID_VALUE, + "glfwCreateWindow: Invalid window size"); + return GL_FALSE; } window = (_GLFWwindow*) calloc(1, sizeof(_GLFWwindow)); diff --git a/tests/clipboard.c b/tests/clipboard.c index 818e6e65..c3746f19 100644 --- a/tests/clipboard.c +++ b/tests/clipboard.c @@ -125,7 +125,7 @@ int main(int argc, char** argv) exit(EXIT_FAILURE); } - window = glfwCreateWindow(0, 0, GLFW_WINDOWED, "Clipboard Test", NULL); + window = glfwCreateWindow(200, 200, GLFW_WINDOWED, "Clipboard Test", NULL); if (!window) { glfwTerminate(); diff --git a/tests/defaults.c b/tests/defaults.c index 2877cfd9..b1103ca4 100644 --- a/tests/defaults.c +++ b/tests/defaults.c @@ -85,7 +85,7 @@ int main(void) glfwWindowHint(GLFW_VISIBLE, GL_FALSE); - window = glfwCreateWindow(0, 0, GLFW_WINDOWED, "Defaults", NULL); + window = glfwCreateWindow(640, 480, GLFW_WINDOWED, "Defaults", NULL); if (!window) { glfwTerminate(); diff --git a/tests/events.c b/tests/events.c index 3bd0d82e..e260cc3b 100644 --- a/tests/events.c +++ b/tests/events.c @@ -353,7 +353,7 @@ int main(void) printf("Library initialized\n"); - window = glfwCreateWindow(0, 0, GLFW_WINDOWED, "Event Linter", NULL); + window = glfwCreateWindow(640, 480, GLFW_WINDOWED, "Event Linter", NULL); if (!window) { glfwTerminate(); diff --git a/tests/gamma.c b/tests/gamma.c index 9ff0e9e5..8b995afc 100644 --- a/tests/gamma.c +++ b/tests/gamma.c @@ -133,8 +133,8 @@ int main(int argc, char** argv) } else { - width = 0; - height = 0; + width = 200; + height = 200; } window = glfwCreateWindow(width, height, mode, "Gamma Test", NULL); diff --git a/tests/glfwinfo.c b/tests/glfwinfo.c index 792e4bd5..5e46fe1e 100644 --- a/tests/glfwinfo.c +++ b/tests/glfwinfo.c @@ -268,7 +268,7 @@ int main(int argc, char** argv) // We assume here that we stand a better chance of success by leaving all // possible details of pixel format selection to GLFW - window = glfwCreateWindow(0, 0, GLFW_WINDOWED, "Version", NULL); + window = glfwCreateWindow(200, 200, GLFW_WINDOWED, "Version", NULL); if (!window) { glfwTerminate(); diff --git a/tests/iconify.c b/tests/iconify.c index e10571c8..b0b6b6a1 100644 --- a/tests/iconify.c +++ b/tests/iconify.c @@ -128,8 +128,8 @@ int main(int argc, char** argv) } else { - width = 0; - height = 0; + width = 640; + height = 480; } window = glfwCreateWindow(width, height, mode, "Iconify", NULL); diff --git a/tests/joysticks.c b/tests/joysticks.c index a41eaa5f..c1abb5f8 100644 --- a/tests/joysticks.c +++ b/tests/joysticks.c @@ -186,7 +186,7 @@ int main(void) exit(EXIT_FAILURE); } - window = glfwCreateWindow(0, 0, GLFW_WINDOWED, "Joystick Test", NULL); + window = glfwCreateWindow(640, 480, GLFW_WINDOWED, "Joystick Test", NULL); if (!window) { glfwTerminate(); diff --git a/tests/peter.c b/tests/peter.c index 32748932..30690e68 100644 --- a/tests/peter.c +++ b/tests/peter.c @@ -92,7 +92,7 @@ static void window_size_callback(GLFWwindow window, int width, int height) static GLboolean open_window(void) { - window_handle = glfwCreateWindow(0, 0, GLFW_WINDOWED, "Peter Detector", NULL); + window_handle = glfwCreateWindow(640, 480, GLFW_WINDOWED, "Peter Detector", NULL); if (!window_handle) return GL_FALSE; diff --git a/tests/tearing.c b/tests/tearing.c index e3149c35..63ece2ba 100644 --- a/tests/tearing.c +++ b/tests/tearing.c @@ -70,7 +70,7 @@ int main(void) exit(EXIT_FAILURE); } - window = glfwCreateWindow(0, 0, GLFW_WINDOWED, "", NULL); + window = glfwCreateWindow(640, 480, GLFW_WINDOWED, "", NULL); if (!window) { fprintf(stderr, "Failed to open GLFW window: %s\n", glfwErrorString(glfwGetError())); diff --git a/tests/title.c b/tests/title.c index a9abebb2..62690f9c 100644 --- a/tests/title.c +++ b/tests/title.c @@ -47,7 +47,7 @@ int main(void) exit(EXIT_FAILURE); } - window = glfwCreateWindow(0, 0, GLFW_WINDOWED, "English 日本語 русский язык 官話", NULL); + window = glfwCreateWindow(400, 400, GLFW_WINDOWED, "English 日本語 русский язык 官話", NULL); if (!window) { fprintf(stderr, "Failed to open GLFW window: %s\n", glfwErrorString(glfwGetError()));