Avoid resizable window?

cozman wrote on Saturday, February 21, 2004:

Hey, great work on glfw, I was just wondering if there was any way to disable window-resizing, I’m porting some 2D stuff to glfw, and wanted to disable resizing.

marcus256 wrote on Saturday, February 21, 2004:

Currently, there is no way to control window decorations/constraints (other than going fullscreen). I’m not sure if there will ever be a way to do this through GLFW, but I get requests for this kind of functionalty from time to time, so it’s at least on my things-to-consider list.

cozman wrote on Sunday, February 22, 2004:

Thanks for clearing that up, it’s not a major problem, my current solution is to specify a callback function for the resize event that sets the window size to the desired size, which works fine for what I need.

I came across this while searching for information on another resize issue.

However, I do note that GLFW has been updated since this post, so I’m posting it here in case anyone comes across this thread in the future.

GLFW now has the GLFW_RESIZABLE window hint and also functions like glfwSetWindowSizeLimits.

One very important thing should be noted. glfwWindowHint() must be called before glfwCreateWindow().

int main()
{
    if (!glfwInit())
        fatalError("Failed to init GLFW");

    glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);

    const int winW = 350;
    const int winH = 350;
    GLFWwindow *window = glfwCreateWindow(winW, winH, "GLFW, OpenGL 1.1, C++",
        nullptr, nullptr);
    if (!window)
        fatalError("Failed to create the GLFW window");
    glfwMakeContextCurrent(window);

    /* ... */
}

GLFW_RESIZABLE is also an attribute and can be set at any time, including after window creation, via glfwSetWindowAttrib.