当前位置: 首页>>代码示例>>C++>>正文


C++ LPDIRECT3D9::CheckDepthStencilMatch方法代码示例

本文整理汇总了C++中LPDIRECT3D9::CheckDepthStencilMatch方法的典型用法代码示例。如果您正苦于以下问题:C++ LPDIRECT3D9::CheckDepthStencilMatch方法的具体用法?C++ LPDIRECT3D9::CheckDepthStencilMatch怎么用?C++ LPDIRECT3D9::CheckDepthStencilMatch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LPDIRECT3D9的用法示例。


在下文中一共展示了LPDIRECT3D9::CheckDepthStencilMatch方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: FindDepthStencilFormat

BOOL FindDepthStencilFormat(UINT iAdapter, D3DDEVTYPE DeviceType,
    D3DFORMAT TargetFormat, D3DFORMAT *pDepthStencilFormat)
{
	// prima lo cerco a 32bit, poi a 24 e infine a 16...e se non
	// c'è vaffanculo alla tua scheda grafica.

    if (SUCCEEDED(g_pD3D->CheckDeviceFormat(iAdapter, DeviceType,
                  TargetFormat, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, D3DFMT_D32)))
    {
       if (SUCCEEDED(g_pD3D->CheckDepthStencilMatch(iAdapter, DeviceType,
                TargetFormat, TargetFormat, D3DFMT_D32)))
       {
           *pDepthStencilFormat = D3DFMT_D32;
           return TRUE;
       }
    }

    
	if (SUCCEEDED(g_pD3D->CheckDeviceFormat( iAdapter, DeviceType,
                  TargetFormat, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, D3DFMT_D24X8)))
    {
       if (SUCCEEDED(g_pD3D->CheckDepthStencilMatch(iAdapter, DeviceType,
                     TargetFormat, TargetFormat, D3DFMT_D24X8 )))
       {
           *pDepthStencilFormat = D3DFMT_D24X8;
           return TRUE;
       }
    }

    
	if(SUCCEEDED(g_pD3D->CheckDeviceFormat(iAdapter, DeviceType,
                 TargetFormat, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, D3DFMT_D24S8)))
    {
       if(SUCCEEDED(g_pD3D->CheckDepthStencilMatch(iAdapter, DeviceType,
                    TargetFormat, TargetFormat, D3DFMT_D24S8)))
       {
           *pDepthStencilFormat = D3DFMT_D24S8;
           return TRUE;
       }
    }
    
	
	if (SUCCEEDED(g_pD3D->CheckDeviceFormat(iAdapter, DeviceType,
                  TargetFormat, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, D3DFMT_D16)))
    {
       if (SUCCEEDED(g_pD3D->CheckDepthStencilMatch( iAdapter, DeviceType,
                     TargetFormat, TargetFormat, D3DFMT_D16)))
       {
           *pDepthStencilFormat = D3DFMT_D16;
            return TRUE;
       }
    }
    return FALSE;
}
开发者ID:ApocalypseDesign,项目名称:ad_public,代码行数:54,代码来源:enumerate.cpp

示例2:

HRESULT HookIDirect3D9::CheckDepthStencilMatch(LPVOID _this, UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT AdapterFormat,D3DFORMAT RenderTargetFormat,D3DFORMAT DepthStencilFormat)
{
	LOG_API();
	return pD3D->CheckDepthStencilMatch(Adapter, DeviceType, AdapterFormat, RenderTargetFormat, DepthStencilFormat);
}
开发者ID:zxmarcos,项目名称:bg4t_monitor,代码行数:5,代码来源:D3DWrapper.cpp

示例3: InitializeWindowed

HRESULT KGraphicsEngine::InitializeWindowed(HWND hBaseWindow, HWND hRenderWindow)
{
	// Create the D3D object.
    if ( NULL == ( g_pD3D = Direct3DCreate9( D3D_SDK_VERSION ) ) )
	{
		MessageBox(hBaseWindow,"Failed Create the D3D object!.","Failed Create the D3D object!",0);
        return E_FAIL;
	}
    // Get the current desktop display mode, so we can set up a back
    // buffer of the same format
	g_pD3D->GetDeviceCaps(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,&g_D3DCaps);

    if ( FAILED( g_pD3D->GetAdapterDisplayMode( D3DADAPTER_DEFAULT, &m_DisplayMode ) ) )
	{
		MessageBox(hBaseWindow,"Failed GetAdapterDisplayMode !.","Failed Create the D3D object!",0);
		return E_FAIL;
	}
     
    // Set up the structure used to create the D3DDevice
	D3DFORMAT  DepFormat;
	if (SUCCEEDED(g_pD3D->CheckDepthStencilMatch(D3DADAPTER_DEFAULT,
		D3DDEVTYPE_HAL,
		m_DisplayMode.Format,
		m_DisplayMode.Format,
		D3DFMT_D24S8)))
	{
		DepFormat = D3DFMT_D24S8;
	}
	else
	{
		DepFormat = D3DFMT_D16;
	}

    memset( &m_PresentParam, 0, sizeof(D3DPRESENT_PARAMETERS) );

    memset(&m_RenderWindowRect, 0, sizeof(m_RenderWindowRect));	

	if(hRenderWindow)
		::GetWindowRect(hRenderWindow,&m_RenderWindowRect);
	else
	{
		::GetWindowRect(hBaseWindow,&m_RenderWindowRect);
		hRenderWindow = hBaseWindow;
	}
		
	//m_PresentParam.BackBufferWidth = m_RenderWindowRect.right-m_RenderWindowRect.left ;
    //m_PresentParam.BackBufferHeight= m_RenderWindowRect.bottom - m_RenderWindowRect.top;
	m_PresentParam.BackBufferWidth = m_DisplayMode.Width ;
	m_PresentParam.BackBufferHeight= m_DisplayMode.Height;

    m_PresentParam.Windowed = TRUE ;
    m_PresentParam.SwapEffect = D3DSWAPEFFECT_DISCARD;
    m_PresentParam.BackBufferFormat = m_DisplayMode.Format;
	m_PresentParam.EnableAutoDepthStencil = TRUE;
    m_PresentParam.AutoDepthStencilFormat = DepFormat;
    m_PresentParam.MultiSampleType = D3DMULTISAMPLE_NONE;
    m_PresentParam.hDeviceWindow = hBaseWindow;
    m_PresentParam.Flags = 0;
    m_PresentParam.FullScreen_RefreshRateInHz = 0;
    m_PresentParam.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;

	//just set camera's aspect
	m_cCamera.Aspect = m_PresentParam.BackBufferWidth*1.0f/m_PresentParam.BackBufferHeight; 

	HRESULT hr;

	// Set default settings
	UINT AdapterToUse=D3DADAPTER_DEFAULT;
	D3DDEVTYPE DeviceType=D3DDEVTYPE_HAL;
//#if SHIPPING_VERSION
	// When building a shipping version, disable NVPerfHUD (opt-out)
//#else
	// Look for 'NVIDIA NVPerfHUD' adapter
	// If it is present, override default settings
	for (UINT Adapter=0;Adapter<g_pD3D->GetAdapterCount();Adapter++)
	{
		D3DADAPTER_IDENTIFIER9 Identifier;
		HRESULT Res=g_pD3D->GetAdapterIdentifier(Adapter,0,&Identifier);
		if (strcmp(Identifier.Description,"NVIDIA NVPerfHUD")==0)
		{
			AdapterToUse=Adapter;
			DeviceType=D3DDEVTYPE_REF;
			break;
		}
	}
//#endif

    // Create the D3DDevice
    /*if ( FAILED(hr = g_pD3D->CreateDevice( AdapterToUse, DeviceType, hBaseWindow,
                                      D3DCREATE_HARDWARE_VERTEXPROCESSING,
                                      &m_PresentParam, &g_pd3dDevice ) ) )
    {*/
		if ( FAILED(hr = g_pD3D->CreateDevice( AdapterToUse, DeviceType, hBaseWindow,
                                      D3DCREATE_MIXED_VERTEXPROCESSING,
                                      &m_PresentParam, &g_pd3dDevice ) ) )
		{
			if ( FAILED(hr = g_pD3D->CreateDevice( AdapterToUse, DeviceType, hBaseWindow,
                                      D3DCREATE_SOFTWARE_VERTEXPROCESSING,
                                      &m_PresentParam, &g_pd3dDevice ) ) )
			{
//.........这里部分代码省略.........
开发者ID:viticm,项目名称:pap2,代码行数:101,代码来源:GraphiceEngine.cpp

示例4: if

HRESULT KGraphicsEngine::Toggle2Windowed()
{
	if (m_lpCurScene)
	{
		g_cMeshTable.InvalidateDeviceObjects();
		g_SceneTable.InvalidateDeviceObjects();
	}
	g_EffectMgr.InvalidateDeviceObjects();

	if (m_bUseMotionBlur)
	{
		BackBufferRelease();
	}

	HRESULT hr = S_OK;
	
	GetWindowRect(m_LastRenderWindow,&m_RenderWindowRect);
		
	//m_PresentParam.BackBufferWidth = m_RenderWindowRect.right-m_RenderWindowRect.left ;
    //m_PresentParam.BackBufferHeight= m_RenderWindowRect.bottom - m_RenderWindowRect.top;
	m_PresentParam.BackBufferWidth = m_DisplayMode.Width;
    m_PresentParam.BackBufferHeight= m_DisplayMode.Height;

  	D3DFORMAT  DepFormat;
	if (SUCCEEDED(g_pD3D->CheckDepthStencilMatch(D3DADAPTER_DEFAULT,
		D3DDEVTYPE_HAL,
		m_DisplayMode.Format,
		m_DisplayMode.Format,
		D3DFMT_D24S8)))
	{
		DepFormat = D3DFMT_D24S8;
	}
	else
	{
		DepFormat = D3DFMT_D16;
	}
	m_PresentParam.Windowed = TRUE ;
    m_PresentParam.SwapEffect = D3DSWAPEFFECT_DISCARD;
    m_PresentParam.BackBufferFormat = m_DisplayMode.Format;
	m_PresentParam.EnableAutoDepthStencil = TRUE;
    m_PresentParam.AutoDepthStencilFormat = DepFormat;
    m_PresentParam.MultiSampleType = D3DMULTISAMPLE_NONE;
    m_PresentParam.hDeviceWindow = g_hBaseWnd;
    m_PresentParam.Flags = 0;
    m_PresentParam.FullScreen_RefreshRateInHz = 0;
	m_PresentParam.BackBufferCount = 0;
    m_PresentParam.PresentationInterval = D3DPRESENT_INTERVAL_DEFAULT;

	//just set camera's aspect
	m_cCamera.Aspect = m_PresentParam.BackBufferWidth*1.0f/m_PresentParam.BackBufferHeight; 

	g_pd3dDevice->SetDialogBoxMode( FALSE );
   
	if ( FAILED(hr = g_pd3dDevice->Reset( &m_PresentParam )))
    {
        //fprintf(Note,"Create D3D Device Failed.\n");
		if (hr == D3DERR_INVALIDCALL)
			MessageBox(g_hBaseWnd,"Toggle to Windowed Failed!","Failed in Toggling",0);
		else if (hr == E_OUTOFMEMORY )
			MessageBox(g_hBaseWnd,"Direct3D could not allocate sufficient memory to complete the call.","Failed Create Device!",0);
		else if (hr == D3DERR_OUTOFVIDEOMEMORY)
			MessageBox(g_hBaseWnd,"Direct3D does not have enough display memory to perform the operation. ","Failed Create Device!",0);

        return E_FAIL;
    }
	SetWindowLong( g_hBaseWnd , GWL_STYLE, m_BaseWinStyle );

	SetRenderWindow(m_LastRenderWindow);

	m_bWindowed = TRUE;

	if (m_lpCurScene)
	{
		g_cMeshTable.RestoreDeviceObjects();
		g_SceneTable.RestoreDeviceObjects();
	}
	g_EffectMgr.RestoreDeviceObjects();

	if (m_bUseMotionBlur)
	{
		BackBufferCreate();
	}
	return S_OK;
}
开发者ID:viticm,项目名称:pap2,代码行数:84,代码来源:GraphiceEngine.cpp

示例5: InitScene

HRESULT InitScene()
{
	HRESULT hr;
	D3DDISPLAYMODE mode;

	if( FAILED(hr = direct3d->GetAdapterDisplayMode(0, &mode)) )
	{
		MYERROR("Could not get adapter mode");
		return hr;
	}
	
	if( FAILED(hr = direct3d->CheckDeviceFormat( 0, D3DDEVTYPE_HAL, mode.Format, D3DUSAGE_RENDERTARGET, D3DRTYPE_TEXTURE, D3DFMT_A16B16G16R16F)) )
	{
		MYERROR("No floating point rendertarget support");
		return hr;
	}
	
	// más depth/stencil-el még müködhet
	if( FAILED(hr = direct3d->CheckDepthStencilMatch( 0, D3DDEVTYPE_HAL, mode.Format, D3DFMT_A16B16G16R16F, D3DFMT_D24S8)) )
	{
		MYERROR("D3DFMT_A16B16G16R16F does not support D3DFMT_D24S8");
		return hr;
	}

	D3DVERTEXELEMENT9 elem[] =
	{
		{ 0, 0, D3DDECLTYPE_FLOAT4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITIONT, 0 },
		{ 0, 16, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0 },
		D3DDECL_END()
	};
	
	SetWindowText(hwnd, TITLE);

	MYVALID(D3DXLoadMeshFromX("../media/meshes/skullocc3.X", D3DXMESH_MANAGED, device, NULL, NULL, NULL, NULL, &mesh1));
	MYVALID(D3DXLoadMeshFromX("../media/meshes//knot.X", D3DXMESH_MANAGED, device, NULL, NULL, NULL, NULL, &mesh2));
	MYVALID(D3DXLoadMeshFromX("../media/meshes//teapot.X", D3DXMESH_MANAGED, device, NULL, NULL, NULL, NULL, &mesh3));
	MYVALID(D3DXLoadMeshFromX("../media/meshes/sky.X", D3DXMESH_MANAGED, device, NULL, NULL, NULL, NULL, &skymesh));

	mesh = mesh1;

	//MYVALID(D3DXCreateCubeTextureFromFile(device, "../media/textures/altar.dds", &skytexture));
	//MYVALID(D3DXCreateCubeTextureFromFile(device, "../media/textures/altar_rough.dds", &roughspecular));
	MYVALID(D3DXCreateCubeTextureFromFile(device, "../media/textures/grace.dds", &skytexture));
	MYVALID(D3DXCreateCubeTextureFromFile(device, "../media/textures/grace_rough.dds", &roughspecular));
	//MYVALID(D3DXCreateCubeTextureFromFile(device, "../media/textures/beach.dds", &skytexture));
	//MYVALID(D3DXCreateCubeTextureFromFile(device, "../media/textures/beach_rough.dds", &roughspecular));
	//MYVALID(D3DXCreateCubeTextureFromFile(device, "../media/textures/stpeters.dds", &skytexture));
	//MYVALID(D3DXCreateCubeTextureFromFile(device, "../media/textures/stpeters_rough.dds", &roughspecular));

	MYVALID(D3DXCreateTextureFromFile(device, "../media/textures/gold.jpg", &texture));
	MYVALID(D3DXCreateTextureFromFile(device, "../media/textures/fresnel.png", &fresneltexture));

	// downsample & blur textures
	for( int i = 0; i < 5; ++i )
	{
		MYVALID(device->CreateTexture(screenwidth / (2 << i), screenheight / (2 << i), 1, D3DUSAGE_RENDERTARGET,
			D3DFMT_A16B16G16R16F, D3DPOOL_DEFAULT, &dstargets[i], NULL));

		MYVALID(device->CreateTexture(screenwidth / (2 << i), screenheight / (2 << i), 1, D3DUSAGE_RENDERTARGET,
			D3DFMT_A16B16G16R16F, D3DPOOL_DEFAULT, &blurtargets[i], NULL));

		MYVALID(blurtargets[i]->GetSurfaceLevel(0, &blursurfaces[i]));
		MYVALID(dstargets[i]->GetSurfaceLevel(0, &dssurfaces[i]));
	}

	// star textures (8x 1 MB @ 1080p)
	for( int i = 0; i < 4; ++i )
	{
		for( int j = 0; j < 2; ++j )
		{
			MYVALID(device->CreateTexture(screenwidth / 4, screenheight / 4, 1, D3DUSAGE_RENDERTARGET,
				D3DFMT_A16B16G16R16F, D3DPOOL_DEFAULT, &startargets[i][j], NULL));

			MYVALID(startargets[i][j]->GetSurfaceLevel(0, &starsurfaces[i][j]));
		}
	}

	// lens flare textures (2x 4 MB @ 1080p)
	for( int i = 0; i < 2; ++i )
	{
		MYVALID(device->CreateTexture(screenwidth / 2, screenheight / 2, 1, D3DUSAGE_RENDERTARGET,
			D3DFMT_A16B16G16R16F, D3DPOOL_DEFAULT, &ghosttargets[i], NULL));

		MYVALID(ghosttargets[i]->GetSurfaceLevel(0, &ghostsurfaces[i]));
	}

	// luminance textures
	for( int i = 0; i < 4; ++i )
	{
		UINT j = 256 / (4 << (2 * i));

		MYVALID(device->CreateTexture(j, j, 1, D3DUSAGE_RENDERTARGET,
			D3DFMT_R16F, D3DPOOL_DEFAULT, &avglumtargets[i], NULL));

		MYVALID(avglumtargets[i]->GetSurfaceLevel(0, &avglumsurfaces[i]));
	}

	// adapted luminance textures
	MYVALID(device->CreateTexture(1, 1, 1, D3DUSAGE_RENDERTARGET, D3DFMT_R16F, D3DPOOL_DEFAULT, &avglumtargets[4], NULL));
	MYVALID(device->CreateTexture(1, 1, 1, D3DUSAGE_RENDERTARGET, D3DFMT_R16F, D3DPOOL_DEFAULT, &avglumtargets[5], NULL));
//.........这里部分代码省略.........
开发者ID:galek,项目名称:Asylum_Tutorials,代码行数:101,代码来源:main.cpp


注:本文中的LPDIRECT3D9::CheckDepthStencilMatch方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。