-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Open
Labels
Description
On Ubuntu 24.04.3 LTS and X11:
When resizing the window with either the left or right edge of the window, the window width will jump to 1 for a small range of widths. This only happens when glfwSetWindowAspectRatio() is used with actual values (not GLFW_DONT_CARE). It does not happen when dragging the corners or top/bottom edge to resize the window. The actual values for aspect ratio or initial window size doesn't seem to matter, but it affects the width at which the window collapses to 1. This issue occurred on versions 3.3.10 and "3.5.0" that I had on my machine.
Demo code:
#include <iostream>
#include "glfw3.h"
constexpr int DEFAULT_WINDOW_WIDTH = 1280;
constexpr int DEFAULT_WINDOW_HEIGHT = 720;
GLFWwindow* g_pWindow = nullptr;
void Framebuffer_size_callback(GLFWwindow* window, int width, int height)
{
std::cout << width << ", " << height << "\n";
}
void SetupWindow()
{
std::string windowName = "Test";
glfwInit();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 5);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
g_pWindow = glfwCreateWindow(DEFAULT_WINDOW_WIDTH, DEFAULT_WINDOW_HEIGHT, windowName.c_str(), NULL, NULL);
if (g_pWindow == nullptr)
{
std::cout << "Failed to create GLFW window\n";
glfwTerminate();
exit(EXIT_FAILURE);
}
//glfwSetWindowSizeLimits(g_pWindow, GLFW_DONT_CARE, GLFW_DONT_CARE, GLFW_DONT_CARE, GLFW_DONT_CARE);
glfwSetWindowAspectRatio(g_pWindow, 16, 9);
glfwMakeContextCurrent(g_pWindow);
glfwSetFramebufferSizeCallback(g_pWindow, Framebuffer_size_callback);
}
int main(int, char**)
{
SetupWindow();
while (!glfwWindowShouldClose(g_pWindow))
{
glfwPollEvents();
}
}
Sample output in the terminal window while resizing the window: