mirror of
https://github.com/glfw/glfw.git
synced 2025-10-02 21:00:57 +00:00
docs for shutdown
This commit is contained in:
parent
30c5f3a924
commit
b9eb6affa3
@ -618,8 +618,8 @@ void window_close_callback(GLFWwindow* window)
|
|||||||
}
|
}
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
If you wish to be notified when the user attempts to shut down the machine, set a
|
If you wish to be notified when the user attempts to shut down the machine, or
|
||||||
machine shutdown callback.
|
interrupt a shutdown, then set a machine shutdown callback.
|
||||||
|
|
||||||
@code
|
@code
|
||||||
glfwSetMachineShutdownCallback(window, machine_shutdown_callback);
|
glfwSetMachineShutdownCallback(window, machine_shutdown_callback);
|
||||||
@ -627,11 +627,16 @@ glfwSetMachineShutdownCallback(window, machine_shutdown_callback);
|
|||||||
|
|
||||||
The callback function is called when GLFW detects that the machine is shutting down.
|
The callback function is called when GLFW detects that the machine is shutting down.
|
||||||
It can be used for example to save data to disk in order to minimize risk of data loss.
|
It can be used for example to save data to disk in order to minimize risk of data loss.
|
||||||
|
Another use is to interrupt the shutdown (return false).
|
||||||
|
|
||||||
@code
|
@code
|
||||||
void machine_shutdown_callback(GLFWwindow* window)
|
int machine_shutdown_callback(GLFWwindow* window)
|
||||||
{
|
{
|
||||||
initiate_save_of_important_data_to_disk();
|
initiate_save_of_important_data_to_disk();
|
||||||
|
if (prevent_machine_shutdown())
|
||||||
|
return GLFW_FALSE;
|
||||||
|
else
|
||||||
|
return GLFW_TRUE;
|
||||||
}
|
}
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user