Ejemplo n.º 1
0
// Poll for changes in the set of connected monitors
//
void _glfwPollMonitorsMir(void)
{
    int i;
    MirDisplayConfiguration* displayConfig =
        mir_connection_create_display_config(_glfw.mir.connection);

    for (i = 0;  i < displayConfig->num_outputs;  i++)
    {
        const MirDisplayOutput* out = displayConfig->outputs + i;

        if (out->used &&
            out->connected &&
            out->num_modes &&
            out->current_mode < out->num_modes)
        {
            _GLFWmonitor* monitor = _glfwAllocMonitor("Unknown",
                                                      out->physical_width_mm,
                                                      out->physical_height_mm);

            monitor->mir.x        = out->position_x;
            monitor->mir.y        = out->position_y;
            monitor->mir.outputId = out->output_id;
            monitor->mir.curMode  = out->current_mode;
            monitor->modes = _glfwPlatformGetVideoModes(monitor, &monitor->modeCount);

            _glfwInputMonitor(monitor, GLFW_CONNECTED, _GLFW_INSERT_LAST);
        }
    }

    mir_display_config_destroy(displayConfig);
}
Ejemplo n.º 2
0
static int refreshVideoModes(_GLFWmonitor* monitor)
{
    int modeCount;

    GLFWvidmode* modes = _glfwPlatformGetVideoModes(monitor, &modeCount);
    if (!modes)
        return GL_FALSE;

    qsort(modes, modeCount, sizeof(GLFWvidmode), compareVideoModes);

    free(monitor->modes);
    monitor->modes = modes;
    monitor->modeCount = modeCount;

    return GL_TRUE;
}
Ejemplo n.º 3
0
GLFWAPI GLFWvidmode* glfwGetVideoModes(int* count)
{
    if (!_glfwInitialized)
    {
        _glfwSetError(GLFW_NOT_INITIALIZED, NULL);
        return NULL;
    }

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

    free(_glfwLibrary.modes);

    _glfwLibrary.modes = _glfwPlatformGetVideoModes(count);
    if (_glfwLibrary.modes)
        qsort(_glfwLibrary.modes, *count, sizeof(GLFWvidmode), compareVideoModes);

    return _glfwLibrary.modes;
}
GLFWAPI int GLFWAPIENTRY glfwGetVideoModes( GLFWvidmode *list, int maxcount )
{
    int         count, i, swap, res1, res2, depth1, depth2;
    GLFWvidmode vm;

    if( !_glfwInitialized || maxcount <= 0 || list == (GLFWvidmode*) 0 )
    {
        return 0;
    }

    // Get list of video modes
    count = _glfwPlatformGetVideoModes( list, maxcount );

    // Sort list (bubble sort)
    do
    {
        swap = 0;
        for( i = 0; i < count-1; ++ i )
        {
            res1   = list[i].Width*list[i].Height;
            depth1 = list[i].RedBits+list[i].GreenBits+list[i].BlueBits;
            res2   = list[i+1].Width*list[i+1].Height;
            depth2 = list[i+1].RedBits+list[i+1].GreenBits+
                     list[i+1].BlueBits;
            if( (depth2<depth1) || ((depth2==depth1) && (res2<res1)) )
            {
                vm = list[i];
                list[i] = list[i+1];
                list[i+1] = vm;
                swap = 1;
            }
        }
    }
    while( swap );

    return count;
}