Setting a GLFW window as not resizable

Simba picture Simba · Nov 30, 2014 · Viewed 8.6k times · Source

I have a GLFW3 window that I am trying to change from resizable to not resizable.

I tried changing the Window Hint after the window was created but this doesn't do anything as the hints only affect window to be created.

what I tried:

glfwWindowHint(GLFW_RESIZABLE, GL_FALSE)

Is this possible? One way of doing it that I thought of was having a onResize function that changes the window size back to the current size after being set not resizable. This seems very hacky.

Answer

Your approach works as of GLFW 3.2.1-1 in Ubuntu 18.10:

main.cpp

#include <GLFW/glfw3.h>

int main(void) {
    GLFWwindow* window;
    if (!glfwInit())
        return -1;
    glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE);
    window = glfwCreateWindow(640, 480, __FILE__, NULL, NULL);
    if (!window) {
        glfwTerminate();
        return -1;
    }
    glfwMakeContextCurrent(window);
    while (!glfwWindowShouldClose(window)) {
        glfwSwapBuffers(window);
        glfwPollEvents();
    }
    glfwTerminate();
    return 0;
}

Compile and run:

g++ -std=c++11 -Wall -Wextra -pedantic-errors -o main.out main.cpp -lglfw
./main.out

As I hover the borders of the created window, the cursor never changes to resize mode.