GLFW: size, position & monitorsGLFW 1.0

glfwSetWindowTitle

Changes the text in the window's title bar.

Signature

void glfwSetWindowTitle(GLFWwindow* window, const char* title);

How it works

A cheap place to show live numbers while you develop, such as frames per second or the frame time, without drawing any text with OpenGL. Update it a few times per second, not every frame: on some systems the call is slow.

Parameters

windowGLFWwindow*

The window to rename.

titleconst char*

The new title, UTF-8. GLFW copies it, so a temporary buffer is fine.

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
1static double last = glfwGetTime();
2static int frames = 0;
3++frames;
4if (glfwGetTime() - last >= 0.5) {
5    char title[64];
6    std::snprintf(title, sizeof title, "Demo - %.1f fps", frames / (glfwGetTime() - last));
7    glfwSetWindowTitle(window, title);
8    last = glfwGetTime();
9    frames = 0;
10}
Official GLFW documentation