mirror of
https://github.com/glfw/glfw.git
synced 2024-11-25 22:14:34 +00:00
Refactor platform selection for clarity?
This commit is contained in:
parent
76a5f781db
commit
2a78a2cf82
@ -73,31 +73,34 @@ GLFWbool _glfwSelectPlatform(int desiredID, _GLFWplatform* platform)
|
|||||||
if (desiredID == GLFW_PLATFORM_NULL)
|
if (desiredID == GLFW_PLATFORM_NULL)
|
||||||
return _glfwConnectNull(desiredID, platform);
|
return _glfwConnectNull(desiredID, platform);
|
||||||
|
|
||||||
// If there is only one platform available for auto-selection, let it emit the error
|
if (desiredID == GLFW_ANY_PLATFORM)
|
||||||
// on failure as the platform-specific error description may be more helpful
|
{
|
||||||
if (desiredID == GLFW_ANY_PLATFORM && count == 1)
|
// If there is exactly one platform available for auto-selection, let it emit the
|
||||||
|
// error on failure as the platform-specific error description may be more helpful
|
||||||
|
if (count == 1)
|
||||||
return supportedPlatforms[0].connect(supportedPlatforms[0].ID, platform);
|
return supportedPlatforms[0].connect(supportedPlatforms[0].ID, platform);
|
||||||
|
|
||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
{
|
|
||||||
if (desiredID == GLFW_ANY_PLATFORM || desiredID == supportedPlatforms[i].ID)
|
|
||||||
{
|
{
|
||||||
if (supportedPlatforms[i].connect(desiredID, platform))
|
if (supportedPlatforms[i].connect(desiredID, platform))
|
||||||
return GLFW_TRUE;
|
return GLFW_TRUE;
|
||||||
else if (desiredID == supportedPlatforms[i].ID)
|
|
||||||
return GLFW_FALSE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (desiredID == GLFW_ANY_PLATFORM)
|
|
||||||
{
|
|
||||||
if (count)
|
if (count)
|
||||||
_glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "Failed to detect any supported platform");
|
_glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "Failed to detect any supported platform");
|
||||||
else
|
else
|
||||||
_glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "This binary only supports the Null platform");
|
_glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "This binary only supports the Null platform");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
for (i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
if (supportedPlatforms[i].ID == desiredID)
|
||||||
|
return supportedPlatforms[i].connect(desiredID, platform);
|
||||||
|
}
|
||||||
|
|
||||||
_glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "The requested platform is not supported");
|
_glfwInputError(GLFW_PLATFORM_UNAVAILABLE, "The requested platform is not supported");
|
||||||
|
}
|
||||||
|
|
||||||
return GLFW_FALSE;
|
return GLFW_FALSE;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user