Răsfoiți Sursa

Removed window size DWIM.

Camilla Berglund 13 ani în urmă
părinte
comite
b8c16e49f1
12 a modificat fișierele cu 20 adăugiri și 33 ștergeri
  1. 4 6
      include/GL/glfw3.h
  2. 4 15
      src/window.c
  3. 1 1
      tests/clipboard.c
  4. 1 1
      tests/defaults.c
  5. 1 1
      tests/events.c
  6. 2 2
      tests/gamma.c
  7. 1 1
      tests/glfwinfo.c
  8. 2 2
      tests/iconify.c
  9. 1 1
      tests/joysticks.c
  10. 1 1
      tests/peter.c
  11. 1 1
      tests/tearing.c
  12. 1 1
      tests/title.c

+ 4 - 6
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

+ 4 - 15
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));

+ 1 - 1
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();

+ 1 - 1
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();

+ 1 - 1
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();

+ 2 - 2
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);

+ 1 - 1
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();

+ 2 - 2
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);

+ 1 - 1
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();

+ 1 - 1
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;
 

+ 1 - 1
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()));

+ 1 - 1
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()));