mirror of
https://github.com/glfw/glfw.git
synced 2024-11-22 13:04:35 +00:00
Removed window size DWIM.
This commit is contained in:
parent
14355d692f
commit
b8c16e49f1
@ -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
|
||||
|
19
src/window.c
19
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));
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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()));
|
||||
|
@ -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()));
|
||||
|
Loading…
Reference in New Issue
Block a user