Beispiel #1
0
static HRESULT WINAPI
d3dadapter9_EnumAdapterModes( struct d3dadapter9 *This,
                              UINT Adapter,
                              D3DFORMAT Format,
                              UINT Mode,
                              D3DDISPLAYMODE *pMode )
{
    HRESULT hr;

    if (Adapter >= d3dadapter9_GetAdapterCount(This)) {
        WARN("Adapter %u does not exist.\n", Adapter);
        return D3DERR_INVALIDCALL;
    }

    hr = d3dadapter9_CheckDeviceFormat(This, Adapter, D3DDEVTYPE_HAL,
                                   Format, D3DUSAGE_RENDERTARGET,
                                   D3DRTYPE_SURFACE, Format);
    if (FAILED(hr)) {
        TRACE("DeviceFormat not available.\n");
        return hr;
    }

    if (Mode >= ADAPTER_OUTPUT.nmodes) {
        WARN("Mode %u does not exist.\n", Mode);
        return D3DERR_INVALIDCALL;
    }

    pMode->Width = ADAPTER_OUTPUT.modes[Mode].Width;
    pMode->Height = ADAPTER_OUTPUT.modes[Mode].Height;
    pMode->RefreshRate = ADAPTER_OUTPUT.modes[Mode].RefreshRate;
    pMode->Format = Format;

    return D3D_OK;
}
Beispiel #2
0
static UINT WINAPI
d3dadapter9_GetAdapterModeCount( struct d3dadapter9 *This,
                                 UINT Adapter,
                                 D3DFORMAT Format )
{
    if (Adapter >= d3dadapter9_GetAdapterCount(This)) {
        WARN("Adapter %u does not exist.\n", Adapter);
        return 0;
    }
    if (FAILED(d3dadapter9_CheckDeviceFormat(This, Adapter, D3DDEVTYPE_HAL,
                                         Format, D3DUSAGE_RENDERTARGET,
                                         D3DRTYPE_SURFACE, Format))) {
        WARN("DeviceFormat not available.\n");
        return 0;
    }

    int NumMatchingModes = 0;
    int NumModes = SDL_GetNumDisplayModes(Adapter);
    int i;
    for (i=0;i<NumModes;i++) {
        SDL_DisplayMode mode;
        int err = SDL_GetDisplayMode(Adapter, i, &mode);
        if (err < 0) {
            WARN("SDL_GetDisplayMode returned an error: %s\n", SDL_GetError());
            return 0;
        }

        if (Format == ConvertFromSDL(mode.format))
            NumMatchingModes ++;
    }

    return NumMatchingModes;
}
Beispiel #3
0
static HRESULT WINAPI
d3dadapter9_EnumAdapterModes( struct d3dadapter9 *This,
                              UINT Adapter,
                              D3DFORMAT Format,
                              UINT ModeIndex,
                              D3DDISPLAYMODE *pMode )
{
    HRESULT hr;

    if (Adapter >= d3dadapter9_GetAdapterCount(This)) {
        WARN("Adapter %u does not exist.\n", Adapter);
        return D3DERR_INVALIDCALL;
    }
    if (!pMode) {
        WARN("pMode is NULL.\n");
        return D3DERR_INVALIDCALL;
    }

    hr = d3dadapter9_CheckDeviceFormat(This, Adapter, D3DDEVTYPE_HAL,
                                   Format, D3DUSAGE_RENDERTARGET,
                                   D3DRTYPE_SURFACE, Format);
    if (FAILED(hr)) {
        TRACE("DeviceFormat not available.\n");
        return hr;
    }

    int IndexMatchingModes = 0;
    int NumModes = SDL_GetNumDisplayModes(Adapter);
    int i;
    for (i=0;i<NumModes;i++) {
        SDL_DisplayMode mode;
        int err = SDL_GetDisplayMode(Adapter, i, &mode);
        if (err < 0) {
            WARN("SDL_GetDisplayMode returned an error: %s\n", SDL_GetError());
            return D3DERR_INVALIDCALL;
        }

        if (Format != ConvertFromSDL(mode.format))
            continue;

        if (IndexMatchingModes == ModeIndex) {
            TRACE("DiplayMode: %dx%d@%dHz, d3dformat=%d\n", mode.w, mode.h, mode.refresh_rate, Format);
            pMode->Width = mode.w;
            pMode->Height = mode.h;
            pMode->RefreshRate = mode.refresh_rate;
            pMode->Format = Format;

            return D3D_OK;
        }
        IndexMatchingModes ++;
    }

    WARN("invalid mode for format %d on adapter %d: %d\n", Format, Adapter, ModeIndex);
    return D3DERR_INVALIDCALL;
}
Beispiel #4
0
static UINT WINAPI
d3dadapter9_GetAdapterModeCount( struct d3dadapter9 *This,
                                 UINT Adapter,
                                 D3DFORMAT Format )
{
    if (Adapter >= d3dadapter9_GetAdapterCount(This)) {
        WARN("Adapter %u does not exist.\n", Adapter);
        return 0;
    }
    if (FAILED(d3dadapter9_CheckDeviceFormat(This, Adapter, D3DDEVTYPE_HAL,
                                         Format, D3DUSAGE_RENDERTARGET,
                                         D3DRTYPE_SURFACE, Format))) {
        WARN("DeviceFormat not available.\n");
        return 0;
    }

    TRACE("%u modes.\n", ADAPTER_OUTPUT.nmodes);
    return ADAPTER_OUTPUT.nmodes;
}