GLFW: window & contextGLFW 3.0

glfwDestroyWindow

Closes a window and destroys its OpenGL context.

Signature

void glfwDestroyWindow(GLFWwindow* window);

How it works

The window disappears and its callbacks stop. If its context was current on this thread, no context is current afterwards.

With a single window you can skip it, since glfwTerminate destroys every remaining window. With several windows, destroy each one when the user closes it.

Parameters

windowGLFWwindow*

The window to destroy. NULL is allowed and does nothing.

Tips & pitfalls

  • Delete OpenGL objects first, while the context still exists.

  • Never call it from inside one of that window's callbacks.

Errors

When the call is invalid it does nothing and sets an error, which glGetError returns:

GLFW_NOT_INITIALIZED
Called before glfwInit or after glfwTerminate.
GLFW_PLATFORM_ERROR
The operating system or window system reported a failure; the description says which.

Example

example.cpp
Official GLFW documentation