Ejemplo n.º 1
0
/*virtual*/ void D3D9Renderer::EnumerateDisplayModes(
    Array<SDisplayMode>& DisplayModes) {
  DisplayModes.Clear();

  EnumerateDisplayModes(DisplayModes, D3DFMT_X8R8G8B8);
  EnumerateDisplayModes(DisplayModes, D3DFMT_A8R8G8B8);

  ASSERT(DisplayModes.Size());
}
Ejemplo n.º 2
0
/*static*/ SDisplayMode Display::GetBestDisplayMode( const uint DesiredWidth, const uint DesiredHeight )
{
	Array<SDisplayMode> DisplayModes;
	EnumerateDisplayModes( DisplayModes );

	SDisplayMode BestDisplayMode;
	FOR_EACH_ARRAY( ModeIter, DisplayModes, SDisplayMode )
	{
		const SDisplayMode& Mode = ModeIter.GetValue();
		if( Mode.Width	>= BestDisplayMode.Width &&
			Mode.Height	>= BestDisplayMode.Height &&
			Mode.Width	<= DesiredWidth &&
			Mode.Height	<= DesiredHeight )
		{
			BestDisplayMode = Mode;
		}
	}

	// This case can occur if our desired dimensions are *smaller* than any available display mode.
	if( BestDisplayMode.Width == 0 ||
		BestDisplayMode.Height == 0 )
	{
		PRINTF( "Could not find a more suitable display mode.\n" );
		BestDisplayMode.Width   = DesiredWidth;
		BestDisplayMode.Height  = DesiredHeight;
	}

	PRINTF( "Using display mode %dx%d\n", BestDisplayMode.Width, BestDisplayMode.Height );
	return BestDisplayMode;
}
Ejemplo n.º 3
0
//--------------------------------------------------------------------------------------
HRESULT CD3D11Enumeration::EnumerateOutputs( CD3D11EnumAdapterInfo* pAdapterInfo )
{
    HRESULT hr;
    IDXGIOutput* pOutput;

    for( int iOutput = 0; ; ++iOutput )
    {
        pOutput = NULL;
        hr = pAdapterInfo->m_pAdapter->EnumOutputs( iOutput, &pOutput );
        if( DXGI_ERROR_NOT_FOUND == hr )
        {
            return S_OK;
        }
        else if( FAILED( hr ) )
        {
            return hr;	//Something bad happened.
        }
        else //Success!
        {
            CD3D11EnumOutputInfo* pOutputInfo = new CD3D11EnumOutputInfo;
            if( !pOutputInfo )
            {
                SAFE_RELEASE( pOutput );
                return E_OUTOFMEMORY;
            }
            ZeroMemory( pOutputInfo, sizeof( CD3D11EnumOutputInfo ) );
            pOutput->GetDesc( &pOutputInfo->Desc );
            pOutputInfo->Output = iOutput;
            pOutputInfo->m_pOutput = pOutput;

            EnumerateDisplayModes( pOutputInfo );
            if( pOutputInfo->displayModeList.GetSize() <= 0 )
            {
                // If this output has no valid display mode, do not save it.
                delete pOutputInfo;
                continue;
            }

            hr = pAdapterInfo->outputInfoList.Add( pOutputInfo );
            if( FAILED( hr ) )
            {
                delete pOutputInfo;
                return hr;
            }
        }
    }
}
Ejemplo n.º 4
0
//-----------------------------------------------------------------------------
// Name : EnumerateAdapters () (Private)
// Desc : Enumerates the individual adapters contained within the user machine.
//-----------------------------------------------------------------------------
HRESULT CD3DInitialize::EnumerateAdapters()
{
    HRESULT hRet;

    // Store the number of available adapters
    ULONG nAdapterCount = m_pD3D->GetAdapterCount();

    // Loop through each adapter
    for ( ULONG i = 0; i < nAdapterCount; i++ )
    {
        CD3DEnumAdapter * pAdapter = new CD3DEnumAdapter;
        if ( !pAdapter ) return E_OUTOFMEMORY;

        // Store adapter ordinal
        pAdapter->Ordinal = i;

        // Retrieve adapter identifier
        m_pD3D->GetAdapterIdentifier( i, 0, &pAdapter->Identifier );

        // Enumerate all display modes for this adapter
        if ( FAILED( hRet = EnumerateDisplayModes( pAdapter ) ) ||
             FAILED( hRet = EnumerateDevices( pAdapter ) )) 
        {
            delete pAdapter;
            if ( hRet == E_ABORT ) continue; else return hRet;
        
        } // End if Failed Code

        // Add this adapter the list
        try { m_vpAdapters.push_back( pAdapter ); } catch ( ... )
        {
            delete pAdapter;
            return E_OUTOFMEMORY;

        } // End Try / Catch Block

    } // Next Adapter

    // Success!
    return S_OK;

}
Ejemplo n.º 5
0
//--------------------------------------------------------------------------------------
HRESULT CD3D11Enumeration::EnumerateOutputs( _In_ CD3D11EnumAdapterInfo* pAdapterInfo )
{
    HRESULT hr;
    IDXGIOutput* pOutput;

    for( int iOutput = 0; ; ++iOutput )
    {
        pOutput = nullptr;
        hr = pAdapterInfo->m_pAdapter->EnumOutputs( iOutput, &pOutput );
        if( DXGI_ERROR_NOT_FOUND == hr )
        {
            return S_OK;
        }
        else if( FAILED( hr ) )
        {
            return hr;	//Something bad happened.
        }
        else //Success!
        {
            CD3D11EnumOutputInfo* pOutputInfo = new (std::nothrow) CD3D11EnumOutputInfo;
            if( !pOutputInfo )
            {
                SAFE_RELEASE( pOutput );
                return E_OUTOFMEMORY;
            }
            pOutputInfo->Output = iOutput;
            pOutputInfo->m_pOutput = pOutput;
            pOutput->GetDesc( &pOutputInfo->Desc );

            EnumerateDisplayModes( pOutputInfo );
            if( pOutputInfo->displayModeList.empty() )
            {
                // If this output has no valid display mode, do not save it.
                delete pOutputInfo;
                continue;
            }

            pAdapterInfo->outputInfoList.push_back( pOutputInfo );
        }
    }
}
Ejemplo n.º 6
0
    void Initialize( HWND hParentWindow )
    {
		// Store the window handle.
		m_hParentWindow = hParentWindow;

		// Get the D3D pointer
		m_pd3d = Direct3DCreate9( D3D_SDK_VERSION );

        // Enumerate the display modes
        EnumerateDisplayModes( );

		// TBD: Enumerate the zbuffer formats properly!
		EnumerateZBufferModes( );

		// Create the D3D device now.
		m_pD3DDevice = CreateD3DDevice( hParentWindow );		// Calls CreateD3DDevice in this (dddevice) class().
		
/*		if (pdd == NULL) 
		{
            TRef<IDirectDraw> pddPrimary;

            HRESULT hr = DirectDrawCreate(NULL, &pddPrimary, NULL);

            if (SUCCEEDED(hr)) 
			{
                DDCall(pddPrimary->QueryInterface(IID_IDirectDrawX, (void**)&m_pdd));
            }
        } 
		else 
		{
            m_pdd = pdd;
        }

        if (m_pdd) 
		{
            // Get Device Info
            DDDeviceIdentifier dddi;
            m_pdd->GetDeviceIdentifier(&dddi, DDGDI_GETHOSTIDENTIFIER);

            m_strName = dddi.szDescription;

            // Get device capabilities.
            DDCall(m_pdd->GetCaps(&m_ddcapsHW, &m_ddcapsSW));

            // Get the amount of video memory
            DWORD dwFree;
            DDSCaps ddsc;
            ddsc.dwCaps = DDSCAPS_VIDEOMEMORY;

            HRESULT hr = m_pdd->GetAvailableVidMem(&ddsc, &m_dwTotalVideoMemory, &dwFree);
            if (DDERR_NODIRECTDRAWHW != hr)
                DDCall(hr);

            // Does the driver support 3D with texture mapping and zbuffer?
            DWORD ddsCaps = DDSCAPS_TEXTURE | DDSCAPS_ZBUFFER;

            m_b3DAcceleration =
                   ((m_ddcapsHW.dwCaps         & DDCAPS_3D) !=       0)
                && ((m_ddcapsHW.ddsCaps.dwCaps & ddsCaps  ) == ddsCaps);

            // Set the cooperative level to Normal
			DDCall(m_pdd->SetCooperativeLevel(NULL, DDSCL_NORMAL));

            // Get the D3D pointer
//            DDCall(m_pdd->QueryInterface(IID_IDirect3DX, (void**)&m_pd3d));
			m_pd3d = Direct3DCreate9( D3D_SDK_VERSION );

            // Enumerate the display modes
            m_pdd->EnumDisplayModes(0, NULL, this, StaticEnumModes);

			// Enumerate the zbuffer formats
//            m_pd3d->EnumZBufferFormats(GetIID(true), StaticEnumZBufferFormats, this);
        }*/
    }