mirror of
https://github.com/glfw/glfw.git
synced 2025-06-07 16:24:57 +00:00
Merge 6ea62735e7
into 3eaf1255b2
This commit is contained in:
commit
da69ac1b2f
@ -58,7 +58,8 @@ if (!glfwInit())
|
|||||||
If any part of initialization fails, any parts that succeeded are terminated as
|
If any part of initialization fails, any parts that succeeded are terminated as
|
||||||
if @ref glfwTerminate had been called. The library only needs to be initialized
|
if @ref glfwTerminate had been called. The library only needs to be initialized
|
||||||
once and additional calls to an already initialized library will return
|
once and additional calls to an already initialized library will return
|
||||||
`GLFW_TRUE` immediately.
|
`GLFW_TRUE` immediately. For each additional call to this function an
|
||||||
|
additional call to @ref glfwTerminate will need to be done later.
|
||||||
|
|
||||||
Once the library has been successfully initialized, it should be terminated
|
Once the library has been successfully initialized, it should be terminated
|
||||||
before the application exits. Modern systems are very good at freeing resources
|
before the application exits. Modern systems are very good at freeing resources
|
||||||
@ -275,9 +276,10 @@ been initialized. This is done with @ref glfwTerminate.
|
|||||||
glfwTerminate();
|
glfwTerminate();
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
This will destroy any remaining window, monitor and cursor objects, restore any
|
This needs to be called once for every time @ref glfwInit was called successfully.
|
||||||
modified gamma ramps, re-enable the screensaver if it had been disabled and free
|
On last necessary call this will destroy any remaining window, monitor and cursor
|
||||||
any other resources allocated by GLFW.
|
objects, restore any modified gamma ramps, re-enable the screensaver if it had
|
||||||
|
been disabled and free any other resources allocated by GLFW.
|
||||||
|
|
||||||
Once the library is terminated, it is as if it had never been initialized, therefore
|
Once the library is terminated, it is as if it had never been initialized, therefore
|
||||||
you will need to initialize it again before being able to use GLFW. If the
|
you will need to initialize it again before being able to use GLFW. If the
|
||||||
|
@ -2117,7 +2117,9 @@ typedef struct GLFWallocator
|
|||||||
* succeeds, you should call @ref glfwTerminate before the application exits.
|
* succeeds, you should call @ref glfwTerminate before the application exits.
|
||||||
*
|
*
|
||||||
* Additional calls to this function after successful initialization but before
|
* Additional calls to this function after successful initialization but before
|
||||||
* termination will return `GLFW_TRUE` immediately.
|
* termination will return `GLFW_TRUE` immediately. For each additional call
|
||||||
|
* to this function an additional call to @ref glfwTerminate will need to be
|
||||||
|
* done later.
|
||||||
*
|
*
|
||||||
* The @ref GLFW_PLATFORM init hint controls which platforms are considered during
|
* The @ref GLFW_PLATFORM init hint controls which platforms are considered during
|
||||||
* initialization. This also depends on which platforms the library was compiled to
|
* initialization. This also depends on which platforms the library was compiled to
|
||||||
@ -2167,9 +2169,9 @@ GLFWAPI int glfwInit(void);
|
|||||||
* you will be able to use most GLFW functions.
|
* you will be able to use most GLFW functions.
|
||||||
*
|
*
|
||||||
* If GLFW has been successfully initialized, this function should be called
|
* If GLFW has been successfully initialized, this function should be called
|
||||||
* before the application exits. If initialization fails, there is no need to
|
* once for every successful call to @ref glfwInit before the application
|
||||||
* call this function, as it is called by @ref glfwInit before it returns
|
* exits. If initialization fails, there is no need to call this function, as
|
||||||
* failure.
|
* it is called by @ref glfwInit before it returns failure.
|
||||||
*
|
*
|
||||||
* This function has no effect if GLFW is not initialized.
|
* This function has no effect if GLFW is not initialized.
|
||||||
*
|
*
|
||||||
|
14
src/init.c
14
src/init.c
@ -41,7 +41,7 @@
|
|||||||
|
|
||||||
// This contains all mutable state shared between compilation units of GLFW
|
// This contains all mutable state shared between compilation units of GLFW
|
||||||
//
|
//
|
||||||
_GLFWlibrary _glfw = { GLFW_FALSE };
|
_GLFWlibrary _glfw = { 0 };
|
||||||
|
|
||||||
// These are outside of _glfw so they can be used before initialization and
|
// These are outside of _glfw so they can be used before initialization and
|
||||||
// after termination without special handling when _glfw is cleared to zero
|
// after termination without special handling when _glfw is cleared to zero
|
||||||
@ -122,7 +122,7 @@ static void terminate(void)
|
|||||||
_glfw.platform.terminateJoysticks();
|
_glfw.platform.terminateJoysticks();
|
||||||
_glfw.platform.terminate();
|
_glfw.platform.terminate();
|
||||||
|
|
||||||
_glfw.initialized = GLFW_FALSE;
|
_glfw.initialized = 0;
|
||||||
|
|
||||||
while (_glfw.errorListHead)
|
while (_glfw.errorListHead)
|
||||||
{
|
{
|
||||||
@ -409,7 +409,10 @@ void _glfwInputError(int code, const char* format, ...)
|
|||||||
GLFWAPI int glfwInit(void)
|
GLFWAPI int glfwInit(void)
|
||||||
{
|
{
|
||||||
if (_glfw.initialized)
|
if (_glfw.initialized)
|
||||||
|
{
|
||||||
|
_glfw.initialized++;
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
memset(&_glfw, 0, sizeof(_glfw));
|
memset(&_glfw, 0, sizeof(_glfw));
|
||||||
_glfw.hints.init = _glfwInitHints;
|
_glfw.hints.init = _glfwInitHints;
|
||||||
@ -446,7 +449,7 @@ GLFWAPI int glfwInit(void)
|
|||||||
_glfwPlatformInitTimer();
|
_glfwPlatformInitTimer();
|
||||||
_glfw.timer.offset = _glfwPlatformGetTimerValue();
|
_glfw.timer.offset = _glfwPlatformGetTimerValue();
|
||||||
|
|
||||||
_glfw.initialized = GLFW_TRUE;
|
_glfw.initialized = 1;
|
||||||
|
|
||||||
glfwDefaultWindowHints();
|
glfwDefaultWindowHints();
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
@ -456,6 +459,11 @@ GLFWAPI void glfwTerminate(void)
|
|||||||
{
|
{
|
||||||
if (!_glfw.initialized)
|
if (!_glfw.initialized)
|
||||||
return;
|
return;
|
||||||
|
if (_glfw.initialized > 1)
|
||||||
|
{
|
||||||
|
_glfw.initialized--;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
terminate();
|
terminate();
|
||||||
}
|
}
|
||||||
|
@ -756,7 +756,7 @@ struct _GLFWplatform
|
|||||||
//
|
//
|
||||||
struct _GLFWlibrary
|
struct _GLFWlibrary
|
||||||
{
|
{
|
||||||
GLFWbool initialized;
|
int initialized;
|
||||||
GLFWallocator allocator;
|
GLFWallocator allocator;
|
||||||
|
|
||||||
_GLFWplatform platform;
|
_GLFWplatform platform;
|
||||||
|
Loading…
Reference in New Issue
Block a user