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


C++ LPDIRECT3D8类代码示例

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


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

示例1: GetModes

void XBVideoConfig::GetModes(LPDIRECT3D8 pD3D)
{
  bHasPAL = false;
  bHasNTSC = false;
  DWORD numModes = pD3D->GetAdapterModeCount(D3DADAPTER_DEFAULT);
  D3DDISPLAYMODE mode;
  CLog::Log(LOGINFO, "Available videomodes:");
  for ( DWORD i = 0; i < numModes; i++ )
  {
    pD3D->EnumAdapterModes( 0, i, &mode );

    // Skip modes we don't care about
    if ( mode.Format != D3DFMT_LIN_A8R8G8B8 )
      continue;
    // ignore 640 wide modes
    if ( mode.Width < 720)
      continue;

    // If we get here, we found an acceptable mode
    CLog::Log(LOGINFO, "Found mode: %ix%i at %iHz", mode.Width, mode.Height, mode.RefreshRate);
    if (mode.Width == 720 && mode.Height == 576 && mode.RefreshRate == 50)
      bHasPAL = true;
    if (mode.Width == 720 && mode.Height == 480 && mode.RefreshRate == 60)
      bHasNTSC = true;
  }
}
开发者ID:derobert,项目名称:debianlink-xbmc,代码行数:26,代码来源:XBVideoConfig.cpp

示例2: GetFullscreenFrontBufferFormat

//Get a supported front buffer format
bool WINDOW::GetFullscreenFrontBufferFormat(D3DFORMAT requestedFormat, D3DFORMAT & resultFormat,
											LPDIRECT3D8 d3d)
{
	//See if the requested front buffer format is supported
	HRESULT hr;
	
	bool requestedFormatSupported=false;
	bool X8R8G8B8Supported=false;
	bool R5G6B5Supported=false;

	//Get the number of available display modes
	unsigned int numModes=d3d->GetAdapterModeCount(D3DADAPTER_DEFAULT);

	//Loop through the modes to see if the formats are supported
	for(unsigned int i=0; i<numModes; ++i)
	{
		D3DDISPLAYMODE mode;
		hr=d3d->EnumAdapterModes(D3DADAPTER_DEFAULT, i, &mode);

		if(mode.Format==requestedFormat)
			requestedFormatSupported=true;

		if(mode.Format==D3DFMT_X8R8G8B8)
			X8R8G8B8Supported=true;

		if(mode.Format==D3DFMT_R5G6B5)
			R5G6B5Supported=true;
	}

	//Return the best supported format
	if(requestedFormatSupported)
	{
		LOG::Instance()->OutputSuccess("Chosen front buffer format is available in fullscreen mode");
		resultFormat=requestedFormat;
		return true;
	}

	if(X8R8G8B8Supported)
	{
		LOG::Instance()->OutputMisc("D3DFMT_X8R8G8B8 will be used instead of chosen front buffer format in %s mode");
		resultFormat=D3DFMT_X8R8G8B8;
		return true;
	}

	if(R5G6B5Supported)
	{
		LOG::Instance()->OutputMisc("D3DFMT_R5G6B5 will be used instead of chosen front buffer format in %s mode");
		resultFormat=D3DFMT_R5G6B5;
		return true;
	}

	
	//No color formats supported
	LOG::Instance()->OutputError("No suitable front buffer formats supported in fullscreen mode");
	
	return false;
}
开发者ID:akeeb-alam,项目名称:Shadow-Mapping,代码行数:58,代码来源:WINDOW_GetFullscreenFrontBufferFormat.cpp

示例3: GetBackBufferFormat

//Get a supported back buffer format
bool WINDOW::GetBackBufferFormat(	D3DFORMAT requestedFormat, D3DFORMAT & resultFormat,
									D3DFORMAT frontBufferFormat,
									LPDIRECT3D8 d3d, bool windowed)
{
	//See if the requested back buffer format is supported
	HRESULT hr;
	
	hr=d3d->CheckDeviceType(	D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, frontBufferFormat,
								requestedFormat, windowed);
	if(SUCCEEDED(hr))
	{
		LOG::Instance()->OutputSuccess("Chosen back buffer format is available in %s mode",
										windowed ? "windowed" : "fullscreen");
		resultFormat=requestedFormat;
		return true;
	}

	//If failed, try A8R8G8B8, X8R8G8B8, R5G6B5
	D3DFORMAT testFormats[3]={D3DFMT_A8R8G8B8, D3DFMT_X8R8G8B8, D3DFMT_R5G6B5};
	char * testStrings[3]={"D3DFMT_A8R8G8B8", "D3DFMT_X8R8G8B8", "D3DFMT_R5G6B5"};
	for(int i=0; i<3; ++i)
	{
		D3DFORMAT currentTestFormat=testFormats[i];

		if(FAILED(hr))
		{
			hr=d3d->CheckDeviceType(	D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, frontBufferFormat,
										currentTestFormat, windowed);
			if(SUCCEEDED(hr))
			{
				LOG::Instance()->OutputMisc("%s will be used instead of chosen back buffer format in %s mode",
												testStrings[i],
												windowed ? "windowed" : "fullscreen");
				resultFormat=testFormats[i];
				return true;
			}
		}
	}

	//If still failed, no color formats supported
	LOG::Instance()->OutputError("No suitable back buffer formats supported in %s mode",
										windowed ? "windowed" : "fullscreen");

	return false;
}
开发者ID:maxiaoyuzdz,项目名称:studywork,代码行数:46,代码来源:WINDOW_GetBackBufferFormat.cpp

示例4: GetInitialMode

//pre: XBVideoConfig::GetModes has been called before this function
RESOLUTION XBVideoConfig::GetInitialMode(LPDIRECT3D8 pD3D, D3DPRESENT_PARAMETERS *p3dParams)
{
  bool bHasPal = HasPAL();
  DWORD numModes = pD3D->GetAdapterModeCount(D3DADAPTER_DEFAULT);
  D3DDISPLAYMODE mode;
  for ( DWORD i = 0; i < numModes; i++ )
  {
    pD3D->EnumAdapterModes( 0, i, &mode );

    // ignore 640 wide modes
    if ( mode.Width < 720)
      continue;

    p3dParams->BackBufferWidth = mode.Width;
    p3dParams->BackBufferHeight = mode.Height;
    p3dParams->FullScreen_RefreshRateInHz = mode.RefreshRate;
    if ((bHasPal) && ((mode.Height != 576) || (mode.RefreshRate != 50)))
    {
      continue;
    }
    //take the first available mode
  }

  if (HasPAL())
  {
    if (HasWidescreen() && (p3dParams->Flags & D3DPRESENTFLAG_WIDESCREEN))
    {
      return PAL_16x9;
    }
    else
    {
      return PAL_4x3;
    }
  }
  if (HasWidescreen() && (p3dParams->Flags & D3DPRESENTFLAG_WIDESCREEN))
  {
    return NTSC_16x9;
  }
  else
  {
    return NTSC_4x3;
  }
}
开发者ID:derobert,项目名称:debianlink-xbmc,代码行数:44,代码来源:XBVideoConfig.cpp

示例5:

int	IsTextureFormatOk( D3DFORMAT TextureFormat, D3DFORMAT AdapterFormat )
{
	int	ret=0;
	HRESULT hr;
	hr = pD3D->CheckDeviceFormat( D3DADAPTER_DEFAULT,
											D3DDEVTYPE_HAL,
											AdapterFormat,
											0,
											D3DRTYPE_TEXTURE,
											TextureFormat );
	if(D3D_OK == hr){
		ret=1;
	}

	hr = pD3D->CheckDeviceFormat( D3DADAPTER_DEFAULT,
											D3DDEVTYPE_HAL,
											AdapterFormat,
											D3DUSAGE_RENDERTARGET,
											D3DRTYPE_TEXTURE,
											TextureFormat );
	if(D3D_OK == hr){
		ret=2;
	}

	return ret;
}
开发者ID:0xrofi,项目名称:Aquaplus,代码行数:26,代码来源:d3d_main.cpp

示例6: InitD3D

//-----------------------------------------------------------------------------
// Name: InitD3D()
// Desc: Initializes Direct3D
//-----------------------------------------------------------------------------
HRESULT InitD3D( HWND hWnd )
{
    // Create the D3D object.
    if( NULL == ( g_pD3D = Direct3DCreate8( D3D_SDK_VERSION ) ) )
        return E_FAIL;

    // Get the current desktop display mode, so we can set up a back
    // buffer of the same format
    D3DDISPLAYMODE d3ddm;
    if( FAILED( g_pD3D->GetAdapterDisplayMode( D3DADAPTER_DEFAULT, &d3ddm ) ) )
        return E_FAIL;

    // Set up the structure used to create the D3DDevice
    D3DPRESENT_PARAMETERS d3dpp;
    ZeroMemory( &d3dpp, sizeof(d3dpp) );
    d3dpp.Windowed = TRUE;
    d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
    d3dpp.BackBufferFormat = d3ddm.Format;

    // Create the D3DDevice
    if( FAILED( g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,
                                      D3DCREATE_SOFTWARE_VERTEXPROCESSING,
                                      &d3dpp, &g_pd3dDevice ) ) )
    {
        return E_FAIL;
    }

    // Turn off culling, so we see the front and back of the triangle
    g_pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE );

    // Turn off D3D lighting, since we are providing our own vertex colors
    g_pd3dDevice->SetRenderState( D3DRS_LIGHTING, FALSE );

    return S_OK;
}
开发者ID:grakidov,项目名称:Render3D,代码行数:39,代码来源:Matrices.cpp

示例7:

void RageDisplay_D3D::GetDisplayResolutions( DisplayResolutions &out ) const
{
	out.clear();
	int iCnt = g_pd3d->GetAdapterModeCount( D3DADAPTER_DEFAULT );

	for( int i = 0; i < iCnt; ++i )
	{
		D3DDISPLAYMODE mode;
		g_pd3d->EnumAdapterModes( D3DADAPTER_DEFAULT, i, &mode );

		DisplayResolution res = { mode.Width, mode.Height };
		out.insert( res );
	}
}
开发者ID:SamDecrock,项目名称:stepmania5-http-post-scores,代码行数:14,代码来源:RageDisplay_D3D.cpp

示例8: SUCCEEDED

bool RageDisplay_D3D::SupportsTextureFormat( PixelFormat pixfmt, bool realtime )
{
#if defined(XBOX)
	// Lazy...  Xbox handles paletted textures completely differently
	// than D3D and I don't want to add a bunch of code for it.  Also, 
	// paletted textures result in worse cache efficiency (see "Xbox 
	// Palettized Texture Performance" in XDK).  So, we'll force 32bit
	// ARGB textures.  -Chris
	// This is also needed for XGSwizzleRect().
	return pixfmt == FMT_RGBA8;
#endif

	// Some cards (Savage) don't support alpha in palettes.
	// Don't allow paletted textures if this is the case.
	if( pixfmt == FMT_PAL  &&  !(g_DeviceCaps.TextureCaps & D3DPTEXTURECAPS_ALPHAPALETTE) )
		return false;

	if(	D3DFORMATS[pixfmt] == D3DFMT_UNKNOWN )
		return false;

	D3DFORMAT d3dfmt = D3DFORMATS[pixfmt];
	HRESULT hr = g_pd3d->CheckDeviceFormat( 
		D3DADAPTER_DEFAULT,
		D3DDEVTYPE_HAL,
		g_d3dpp.BackBufferFormat,
		0,
		D3DRTYPE_TEXTURE,
		d3dfmt);

    return SUCCEEDED( hr );
}
开发者ID:Prcuvu,项目名称:StepMania-3.95,代码行数:31,代码来源:RageDisplay_D3D.cpp

示例9: cleanup

void cleanup()   // it's a dirty job.. but some function has to do it...
{
   if (myRect1)
      delete myRect1;
   if (myRect2)
      delete myRect2;
   if (myRect3)
      delete myRect3;
   if (myRect4)
      delete myRect4;
   if (myRect5)
      delete myRect5;

   if( lpD3DDevice8 != NULL ) 
      lpD3DDevice8->Release();

   if( lpD3D8 != NULL )       
      lpD3D8->Release();

   if( lpD3DXFont != NULL )
      lpD3DXFont->Release();

   if( lpD3DTex1 != NULL )
      lpD3DTex1->Release();
}
开发者ID:pnchang,项目名称:advgraphics,代码行数:25,代码来源:example06.cpp

示例10: Cleanup

//-----------------------------------------------------------------------------
// Name: Cleanup()
// Desc: Releases all previously initialized objects
//-----------------------------------------------------------------------------
VOID Cleanup()
{
    if( g_pd3dDevice != NULL) 
        g_pd3dDevice->Release();

    if( g_pD3D != NULL)
        g_pD3D->Release();
}
开发者ID:grakidov,项目名称:Render3D,代码行数:12,代码来源:CreateDevice.cpp

示例11: FindBackBufferType

D3DFORMAT FindBackBufferType(bool bWindowed, int iBPP)
{
	HRESULT hr;

	// If windowed, then bpp is ignored.  Use whatever works.
    vector<D3DFORMAT> vBackBufferFormats;		// throw all possibilities in here
	
	/* When windowed, add all formats; otherwise add only formats that match dwBPP. */
	if( iBPP == 16 || bWindowed )
	{
		vBackBufferFormats.push_back( D3DFMT_R5G6B5 );
		vBackBufferFormats.push_back( D3DFMT_X1R5G5B5 );
		vBackBufferFormats.push_back( D3DFMT_A1R5G5B5 );
	}
	if( iBPP == 32 || bWindowed )
	{
#if !defined(XBOX)
		vBackBufferFormats.push_back( D3DFMT_R8G8B8 );
#endif
		vBackBufferFormats.push_back( D3DFMT_X8R8G8B8 );
		vBackBufferFormats.push_back( D3DFMT_A8R8G8B8 );
	}
	if( !bWindowed && iBPP != 16 && iBPP != 32 )
	{
		GraphicsWindow::Shutdown();
		RageException::Throw( "Invalid BPP '%i' specified", iBPP );
	}

	// Test each back buffer format until we find something that works.
	for( unsigned i=0; i < vBackBufferFormats.size(); i++ )
	{
		D3DFORMAT fmtBackBuffer = vBackBufferFormats[i];

		D3DFORMAT fmtDisplay;
		if( bWindowed )
			fmtDisplay = g_DesktopMode.Format;
		else	// Fullscreen
			fmtDisplay = vBackBufferFormats[i];

		LOG->Trace( "Testing format: display %d, back buffer %d, windowed %d...",
					fmtDisplay, fmtBackBuffer, bWindowed );

		hr = g_pd3d->CheckDeviceType( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, 
			fmtDisplay, fmtBackBuffer, bWindowed );

		if( FAILED(hr) )
			continue;	// skip

		// done searching
		LOG->Trace( "This will work." );
		return fmtBackBuffer;
	}

	LOG->Trace( "Couldn't find an appropriate back buffer format." );
	return D3DFMT_UNKNOWN;
}
开发者ID:Prcuvu,项目名称:StepMania-3.95,代码行数:56,代码来源:RageDisplay_D3D.cpp

示例12: InitD3D

//-----------------------------------------------------------------------------
// Name: InitD3D()
// Desc: Initializes Direct3D
//-----------------------------------------------------------------------------
HRESULT InitD3D( HWND hWnd )
{
    // Create the D3D object, which is needed to create the D3DDevice.
    if( NULL == ( g_pD3D = Direct3DCreate8( D3D_SDK_VERSION ) ) )
        return E_FAIL;

    // Get the current desktop display mode
    D3DDISPLAYMODE d3ddm;
    if( FAILED( g_pD3D->GetAdapterDisplayMode( D3DADAPTER_DEFAULT, &d3ddm ) ) )
        return E_FAIL;

    // Set up the structure used to create the D3DDevice. Most parameters are
    // zeroed out. We set Windowed to TRUE, since we want to do D3D in a
    // window, and then set the SwapEffect to "discard", which is the most
    // efficient method of presenting the back buffer to the display.  And 
    // we request a back buffer format that matches the current desktop display 
    // format.
    D3DPRESENT_PARAMETERS d3dpp; 
    ZeroMemory( &d3dpp, sizeof(d3dpp) );
    d3dpp.Windowed = TRUE;
    d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
    d3dpp.BackBufferFormat = d3ddm.Format;

    // Create the Direct3D device. Here we are using the default adapter (most
    // systems only have one, unless they have multiple graphics hardware cards
    // installed) and requesting the HAL (which is saying we want the hardware
    // device rather than a software one). Software vertex processing is 
    // specified since we know it will work on all cards. On cards that support 
    // hardware vertex processing, though, we would see a big performance gain 
    // by specifying hardware vertex processing.
    if( FAILED( g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,
                                      D3DCREATE_SOFTWARE_VERTEXPROCESSING,
                                      &d3dpp, &g_pd3dDevice ) ) )
    {
        return E_FAIL;
    }

    // Device state would normally be set here

    return S_OK;
}
开发者ID:grakidov,项目名称:Render3D,代码行数:45,代码来源:CreateDevice.cpp

示例13: InitD3D

//-----------------------------------------------------------------------------
// Name: InitD3D()
// Desc: Initializes Direct3D
//-----------------------------------------------------------------------------
HRESULT InitD3D( HWND hWnd )
{
    // Create the D3D object.
    if( NULL == ( g_pD3D = Direct3DCreate8( D3D_SDK_VERSION ) ) )
        return E_FAIL;

    // Get the current desktop display mode, so we can set up a back
    // buffer of the same format
    D3DDISPLAYMODE d3ddm;
    if( FAILED( g_pD3D->GetAdapterDisplayMode( D3DADAPTER_DEFAULT, &d3ddm ) ) )
        return E_FAIL;

    // Set up the structure used to create the D3DDevice. Since we are now
    // using more complex geometry, we will create a device with a zbuffer.
    D3DPRESENT_PARAMETERS d3dpp;
    ZeroMemory( &d3dpp, sizeof(d3dpp) );
    d3dpp.Windowed = TRUE;
    d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
    d3dpp.BackBufferFormat = d3ddm.Format;
    d3dpp.EnableAutoDepthStencil = TRUE;
    d3dpp.AutoDepthStencilFormat = D3DFMT_D16;

    // Create the D3DDevice
    if( FAILED( g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,
                                      D3DCREATE_SOFTWARE_VERTEXPROCESSING,
                                      &d3dpp, &g_pd3dDevice ) ) )
    {
        return E_FAIL;
    }

    // Turn off culling
    g_pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE );

    // Turn off D3D lighting
    g_pd3dDevice->SetRenderState( D3DRS_LIGHTING, FALSE );

    // Turn on the zbuffer
    g_pd3dDevice->SetRenderState( D3DRS_ZENABLE, TRUE );

    return S_OK;
}
开发者ID:grakidov,项目名称:Render3D,代码行数:45,代码来源:Textures.cpp

示例14: EnumAdapters

void EnumAdapters( int nAdapter )
{
	int		i,n;
	char	buf[128];

	n = pD3D->GetAdapterModeCount(nAdapter);
	D3DCapsStruct.m_DisplayModeNum = n;

	if( D3DCapsStruct.m_DisplayMode==NULL )
		D3DCapsStruct.m_DisplayMode = (D3DDISPLAYMODE*)GAlloc( sizeof(D3DDISPLAYMODE)*n );

	for( i=0 ; i<n ; i++ ){
		if( pD3D->EnumAdapterModes(nAdapter,i,&D3DCapsStruct.m_DisplayMode[i]) == D3D_OK){
			wsprintf( buf, "%d x %d (%d Hz) - %s\n",
							D3DCapsStruct.m_DisplayMode[i].Width,
							D3DCapsStruct.m_DisplayMode[i].Height,
							D3DCapsStruct.m_DisplayMode[i].RefreshRate,
							TxFmtMode[ LIM(D3DCapsStruct.m_DisplayMode[i].Format,0,D3DFMT_D3DD_MAX-1) ] );
			DebugPrintf( buf );
		}
	}
}
开发者ID:0xrofi,项目名称:Aquaplus,代码行数:22,代码来源:d3d_main.cpp

示例15: Cleanup

//-----------------------------------------------------------------------------
// Name: Cleanup()
// Desc: Releases all previously initialized objects
//-----------------------------------------------------------------------------
VOID Cleanup()
{
    if( g_pTexture != NULL )
        g_pTexture->Release();

    if( g_pVB != NULL )
        g_pVB->Release();

    if( g_pd3dDevice != NULL )
        g_pd3dDevice->Release();

    if( g_pD3D != NULL )
        g_pD3D->Release();
}
开发者ID:grakidov,项目名称:Render3D,代码行数:18,代码来源:Textures.cpp


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