Ejemplo n.º 1
0
GLFWAPI const GLFWvidmode* glfwGetVideoModes(GLFWmonitor* handle, int* count)
{
    _GLFWmonitor* monitor = (_GLFWmonitor*) handle;

    if (!_glfwInitialized)
    {
        _glfwInputError(GLFW_NOT_INITIALIZED, NULL);
        return NULL;
    }

    if (monitor == NULL)
    {
        _glfwInputError(GLFW_INVALID_VALUE,
                        "glfwGetVideoModes: Invalid monitor handle");
        return 0;
    }

    if (count == NULL)
    {
        _glfwInputError(GLFW_INVALID_VALUE, NULL);
        return NULL;
    }

    if (!refreshVideoModes(monitor))
        return GL_FALSE;

    *count = monitor->modeCount;
    return monitor->modes;
}
Ejemplo n.º 2
0
const GLFWvidmode* _glfwChooseVideoMode(_GLFWmonitor* monitor,
                                        const GLFWvidmode* desired)
{
    int i;
    unsigned int sizeDiff, leastSizeDiff = UINT_MAX;
    unsigned int colorDiff, leastColorDiff = UINT_MAX;
    const GLFWvidmode* current;
    const GLFWvidmode* closest = NULL;

    if (!refreshVideoModes(monitor))
        return NULL;

    for (i = 0;  i < monitor->modeCount;  i++)
    {
        current = monitor->modes + i;

        colorDiff = abs((current->redBits + current->greenBits + current->blueBits) -
                        (desired->redBits + desired->greenBits + desired->blueBits));

        sizeDiff = abs((current->width - desired->width) *
                       (current->width - desired->width) +
                       (current->height - desired->height) *
                       (current->height - desired->height));

        if ((colorDiff < leastColorDiff) ||
            (colorDiff == leastColorDiff && sizeDiff < leastSizeDiff))
        {
            closest = current;
            leastSizeDiff = sizeDiff;
            leastColorDiff = colorDiff;
        }
    }

    return closest;
}
Ejemplo n.º 3
0
GLFWAPI const GLFWvidmode* glfwGetVideoModes(GLFWmonitor* handle, int* count)
{
    _GLFWmonitor* monitor = (_GLFWmonitor*) handle;

    *count = 0;

    _GLFW_REQUIRE_INIT_OR_RETURN(NULL);

    if (!refreshVideoModes(monitor))
        return NULL;

    *count = monitor->modeCount;
    return monitor->modes;
}