1
0
Fork 0
mirror of https://github.com/gwm17/glfw.git synced 2024-11-23 02:38:52 -05:00

Removed window size DWIM.

This commit is contained in:
Camilla Berglund 2012-11-22 17:04:54 +01:00
parent 14355d692f
commit b8c16e49f1
12 changed files with 20 additions and 33 deletions

View File

@ -1063,12 +1063,10 @@ GLFWAPI void glfwWindowHint(int target, int hint);
/*! @brief Creates a window and its associated context. /*! @brief Creates a window and its associated context.
* *
* @param[in] width The desired width, in pixels, of the window. If @p width * @param[in] width The desired width, in pixels, of the window. This must be
* is zero, it will be set to 4/3 times @p height. If both are zero, it will * greater than zero.
* be set to 640. * @param[in] height The desired height, in pixels, of the window. This must
* @param[in] height The desired height, in pixels, of the window. If @p * be greater than zero.
* 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] mode One of @ref GLFW_WINDOWED or @ref GLFW_FULLSCREEN. * @param[in] mode One of @ref GLFW_WINDOWED or @ref GLFW_FULLSCREEN.
* @param[in] title The initial, UTF-8 encoded window title. * @param[in] title The initial, UTF-8 encoded window title.
* @param[in] share The window whose context to share resources with, or @c * @param[in] share The window whose context to share resources with, or @c

View File

@ -263,22 +263,11 @@ GLFWAPI GLFWwindow glfwCreateWindow(int width, int height,
return GL_FALSE; return GL_FALSE;
} }
// Check width & height if (width <= 0 || height <= 0)
if (width > 0 && height <= 0)
{ {
// Set the window aspect ratio to 4:3 _glfwSetError(GLFW_INVALID_VALUE,
height = (width * 3) / 4; "glfwCreateWindow: Invalid window size");
} return GL_FALSE;
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;
} }
window = (_GLFWwindow*) calloc(1, sizeof(_GLFWwindow)); window = (_GLFWwindow*) calloc(1, sizeof(_GLFWwindow));

View File

@ -125,7 +125,7 @@ int main(int argc, char** argv)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
window = glfwCreateWindow(0, 0, GLFW_WINDOWED, "Clipboard Test", NULL); window = glfwCreateWindow(200, 200, GLFW_WINDOWED, "Clipboard Test", NULL);
if (!window) if (!window)
{ {
glfwTerminate(); glfwTerminate();

View File

@ -85,7 +85,7 @@ int main(void)
glfwWindowHint(GLFW_VISIBLE, GL_FALSE); glfwWindowHint(GLFW_VISIBLE, GL_FALSE);
window = glfwCreateWindow(0, 0, GLFW_WINDOWED, "Defaults", NULL); window = glfwCreateWindow(640, 480, GLFW_WINDOWED, "Defaults", NULL);
if (!window) if (!window)
{ {
glfwTerminate(); glfwTerminate();

View File

@ -353,7 +353,7 @@ int main(void)
printf("Library initialized\n"); printf("Library initialized\n");
window = glfwCreateWindow(0, 0, GLFW_WINDOWED, "Event Linter", NULL); window = glfwCreateWindow(640, 480, GLFW_WINDOWED, "Event Linter", NULL);
if (!window) if (!window)
{ {
glfwTerminate(); glfwTerminate();

View File

@ -133,8 +133,8 @@ int main(int argc, char** argv)
} }
else else
{ {
width = 0; width = 200;
height = 0; height = 200;
} }
window = glfwCreateWindow(width, height, mode, "Gamma Test", NULL); window = glfwCreateWindow(width, height, mode, "Gamma Test", NULL);

View File

@ -268,7 +268,7 @@ int main(int argc, char** argv)
// We assume here that we stand a better chance of success by leaving all // We assume here that we stand a better chance of success by leaving all
// possible details of pixel format selection to GLFW // 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) if (!window)
{ {
glfwTerminate(); glfwTerminate();

View File

@ -128,8 +128,8 @@ int main(int argc, char** argv)
} }
else else
{ {
width = 0; width = 640;
height = 0; height = 480;
} }
window = glfwCreateWindow(width, height, mode, "Iconify", NULL); window = glfwCreateWindow(width, height, mode, "Iconify", NULL);

View File

@ -186,7 +186,7 @@ int main(void)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
window = glfwCreateWindow(0, 0, GLFW_WINDOWED, "Joystick Test", NULL); window = glfwCreateWindow(640, 480, GLFW_WINDOWED, "Joystick Test", NULL);
if (!window) if (!window)
{ {
glfwTerminate(); glfwTerminate();

View File

@ -92,7 +92,7 @@ static void window_size_callback(GLFWwindow window, int width, int height)
static GLboolean open_window(void) 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) if (!window_handle)
return GL_FALSE; return GL_FALSE;

View File

@ -70,7 +70,7 @@ int main(void)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
window = glfwCreateWindow(0, 0, GLFW_WINDOWED, "", NULL); window = glfwCreateWindow(640, 480, GLFW_WINDOWED, "", NULL);
if (!window) if (!window)
{ {
fprintf(stderr, "Failed to open GLFW window: %s\n", glfwErrorString(glfwGetError())); fprintf(stderr, "Failed to open GLFW window: %s\n", glfwErrorString(glfwGetError()));

View File

@ -47,7 +47,7 @@ int main(void)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
window = glfwCreateWindow(0, 0, GLFW_WINDOWED, "English 日本語 русский язык 官話", NULL); window = glfwCreateWindow(400, 400, GLFW_WINDOWED, "English 日本語 русский язык 官話", NULL);
if (!window) if (!window)
{ {
fprintf(stderr, "Failed to open GLFW window: %s\n", glfwErrorString(glfwGetError())); fprintf(stderr, "Failed to open GLFW window: %s\n", glfwErrorString(glfwGetError()));