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


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

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


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

示例1: initializeD3D

bool initializeD3D(HWND hwnd) {
	//创建一个d3d管理器
	d3dManager = Direct3DCreate9(D3D_SDK_VERSION);
	if (d3dManager == NULL)
		return false;

	//创建一份d3d配置
	D3DPRESENT_PARAMETERS d3dCfg = {};
	d3dCfg.Windowed = TRUE;
	d3dCfg.BackBufferWidth = 1024;
	d3dCfg.BackBufferHeight = 768;
	d3dCfg.SwapEffect = D3DSWAPEFFECT_DISCARD;
	D3DDISPLAYMODE displayMode;//用d3d管理器读取显示器显示模式
	if (FAILED(d3dManager->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &displayMode)))
		return false;
	d3dCfg.BackBufferFormat = displayMode.Format;

	//用d3d管理器根据d3d配置创建一个d3d设备
	if (FAILED(d3dManager->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
										hwnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING,
										&d3dCfg, &d3dDevice)))
		return false;

	if (!initializeObj())
		return false;

	return true;
}
开发者ID:henianming,项目名称:WayToDirectx,代码行数:28,代码来源:csdn_lesson003.cpp

示例2: InitD3D

LRESULT InitD3D(HWND hWnd)
{
	if( NULL == ( g_pD3D = Direct3DCreate9( D3D_SDK_VERSION ) ) )
		return E_FAIL;
	D3DDISPLAYMODE d3ddm;
	if( FAILED( g_pD3D->GetAdapterDisplayMode( D3DADAPTER_DEFAULT, &d3ddm ) ) )
		return E_FAIL;
	D3DPRESENT_PARAMETERS d3dpp; 
	ZeroMemory( &d3dpp, sizeof(d3dpp) );
	d3dpp.Windowed   = TRUE;

	d3dpp.BackBufferCount        = 2;
	d3dpp.MultiSampleType        = D3DMULTISAMPLE_NONE;
	d3dpp.MultiSampleQuality     =0;

	d3dpp.SwapEffect = D3DSWAPEFFECT_FLIP;
	d3dpp.BackBufferFormat = d3ddm.Format;
    d3dpp.EnableAutoDepthStencil = TRUE;
    d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
	d3dpp.Flags              = D3DPRESENTFLAG_DISCARD_DEPTHSTENCIL;
	d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;

	if(theViewer.getFullscreen())
	{
		d3dpp.Windowed   = FALSE;
		d3dpp.BackBufferWidth=theViewer.getWidth();
		d3dpp.BackBufferHeight=theViewer.getHeight();

	}

	D3DCAPS9 Caps;
	g_pD3D->GetDeviceCaps(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,&Caps);

	if((Caps.TextureOpCaps & D3DTEXOPCAPS_DOTPRODUCT3) == 0)
	{
		MessageBox(hWnd,
              "Your 3D Card don't support DOT3 operation, bumpmapping is disabled",
		      "Warning",MB_OK);

		g_bCanDot3=false;
	}

	if(Caps.VertexShaderVersion >= D3DVS_VERSION(1,1))
	{
        if( FAILED( g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,
                                  D3DCREATE_HARDWARE_VERTEXPROCESSING,
                                  &d3dpp, &g_pD3DDevice ) ) )
			return E_FAIL;
	}
	else
	{
		if( FAILED( g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,
                                  D3DCREATE_SOFTWARE_VERTEXPROCESSING,
                                  &d3dpp, &g_pD3DDevice ) ) )
			return E_FAIL;
	}

	
	return S_OK;
}
开发者ID:AAnguix,项目名称:TTOD_Engine,代码行数:60,代码来源:main.cpp

示例3: InitializeD3D

HRESULT InitializeD3D(HWND hWnd)
{
	g_pD3D=Direct3DCreate9(D3D_SDK_VERSION);
	if(g_pD3D==NULL) return E_FAIL;

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

	//Create a structure to hold the settings for our device
	D3DPRESENT_PARAMETERS d3dpp;
	ZeroMemory(&d3dpp, sizeof(d3dpp));

	//Fill the structure
	//We want our program to be windowed and set the back buffer to a format that matches the current display mode
	d3dpp.Windowed=TRUE;
	d3dpp.SwapEffect=D3DSWAPEFFECT_COPY;
	d3dpp.BackBufferFormat=d3ddm.Format;

	//Create a Direct3D device
	if(FAILED(g_pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &g_pD3DDevice)))
		return E_FAIL;

	//Hide the back
	g_pD3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
	//Turn off the light
	g_pD3DDevice->SetRenderState(D3DRS_LIGHTING, FALSE);

	return S_OK;
}
开发者ID:viticm,项目名称:pap2,代码行数:30,代码来源:TestRender.cpp

示例4: setup

void setup( void )
{
	// ---- direct3d initialisation ----
  g_pD3D = Direct3DCreate9( D3D_SDK_VERSION );

	// ---- display mode ----
  D3DDISPLAYMODE d3ddm;
  g_pD3D->GetAdapterDisplayMode( D3DADAPTER_DEFAULT, &d3ddm );
  ZeroMemory( &g_d3dpp, sizeof(g_d3dpp) );

	// ---- set present parameters ----
  g_d3dpp.Windowed = TRUE;
  g_d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
  g_d3dpp.BackBufferFormat = d3ddm.Format;
  g_d3dpp.EnableAutoDepthStencil = TRUE;
  g_d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
  g_d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;


	// ---- create the d3d device ----
  g_pD3D->CreateDevice( D3DADAPTER_DEFAULT,
	  D3DDEVTYPE_HAL,
	  g_hWnd,
	  D3DCREATE_SOFTWARE_VERTEXPROCESSING,
	  &g_d3dpp,
	  &g_pd3dDevice
  );
}
开发者ID:iqabsent,项目名称:cge-lsystem,代码行数:28,代码来源:main.cpp

示例5: dx9vid_init

BOOL dx9vid_init()
{
	d3d = Direct3DCreate9(D3D_SDK_VERSION);    // create the Direct3D interface
	D3DCAPS9 d3dCaps;
	d3d->GetDeviceCaps( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &d3dCaps );
	d3d->GetAdapterDisplayMode( D3DADAPTER_DEFAULT, &d3ddm );

	ZeroMemory( &d3dpp, sizeof(d3dpp) );
	d3dpp.Windowed               = TRUE;
	d3dpp.SwapEffect             = D3DSWAPEFFECT_DISCARD;
	d3dpp.BackBufferFormat       = d3ddm.Format;
	d3dpp.EnableAutoDepthStencil = TRUE;
	d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
	d3dpp.PresentationInterval   = D3DPRESENT_INTERVAL_IMMEDIATE;

	d3d->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, g_hwnd,
						D3DCREATE_SOFTWARE_VERTEXPROCESSING,
						&d3dpp, &d3ddev );

	// Create the screen texture
	D3DXCreateTexture( d3ddev, 256, 256, D3DX_FILTER_NONE, D3DUSAGE_DYNAMIC, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT, &g_screenTex);

	// Create the screen sprite (ignores 3d perspective)
	D3DXCreateSprite( d3ddev, &g_screenSprite );

	// Scale our matrix to match the screen
	D3DXMatrixIdentity( &pTransform );
	spritePos = D3DXVECTOR2( 0.f, 0.f );
	rotCenter = D3DXVECTOR2( 0.f, 0.f);
	D3DXVECTOR2 vscale = D3DXVECTOR2( float(3.0f), float(3.0f));
	D3DXMatrixTransformation2D( &pTransform, NULL, 0.0f, &vscale, &rotCenter, 0.f, &spritePos );
	g_screenSprite->SetTransform(&pTransform);

	return TRUE;
}
开发者ID:frangarcj,项目名称:neogpc,代码行数:35,代码来源:video_directx.cpp

示例6: InitD3D

//-----------------------------------------------------------------------------
// Name: InitD3D()
// Desc: Initializes Direct3D
//-----------------------------------------------------------------------------
HRESULT InitD3D( HWND hWnd )
{
	int nOutputWindowID;

	g_pD3D = Direct3DCreate9( D3D_SDK_VERSION );

	D3DDISPLAYMODE d3ddm;

	g_pD3D->GetAdapterDisplayMode( D3DADAPTER_DEFAULT, &d3ddm );

	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;
	d3dpp.PresentationInterval   = D3DPRESENT_INTERVAL_IMMEDIATE;

	g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,
		D3DCREATE_SOFTWARE_VERTEXPROCESSING,
		&d3dpp, &g_pd3dDevice );


	g_cEngineMemStack.Initialize( KG3DMEM_LEQUAL_32M );
	g_hWnd = hWnd;


	return S_OK;
}
开发者ID:1suming,项目名称:pap2,代码行数:35,代码来源:KG3DUITest.cpp

示例7: InitD3D

HRESULT InitD3D( HWND hWnd ) 
{ 
	HRESULT hr ;

	// Create the D3D object, which is needed to create the D3DDevice. 
	if( NULL == ( g_pD3D = Direct3DCreate9( D3D_SDK_VERSION ) ) ) 
	{ 
		MessageBox(NULL, "Create D3D9 object failed!", "Error", 0) ; 
		return E_FAIL; 
	} 

	D3DDISPLAYMODE	ddm;
	hr = g_pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT,&ddm) ;
	if(FAILED(hr))
	{
		MessageBox(NULL, "Unable to Get Adapter Display Mode", "Error", 0) ; 
		return E_FAIL;
	}

	ZeroMemory( &d3dpp, sizeof(d3dpp) ); 

	d3dpp.Windowed = TRUE;  
	d3dpp.BackBufferCount = 1 ;
	d3dpp.BackBufferWidth = ddm.Width ;
	d3dpp.BackBufferHeight = ddm.Height ;
	d3dpp.SwapEffect = D3DSWAPEFFECT_FLIP; 
	d3dpp.BackBufferFormat = D3DFMT_A8R8G8B8; 

	// Create device 
	if( FAILED( g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, 
		D3DCREATE_SOFTWARE_VERTEXPROCESSING, 
		&d3dpp, &g_pd3dDevice ) ) ) 
	{ 
		MessageBoxA(NULL, "Create D3D9 device failed!", "Error", 0) ; 
		return E_FAIL; 
	} 

	// Create Semaphore variable
	g_hMutex = CreateMutex(NULL,FALSE,NULL);
	g_hFullSemaphore = CreateSemaphore(NULL, g_PoolSize - 1, g_PoolSize - 1, NULL);
	g_hEmptySemaphore = CreateSemaphore(NULL, 0, g_PoolSize - 1, NULL);

	// Get back buffer
	g_pd3dDevice->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &g_pBackBuffer) ;

	// Create surface
	for (int i = 0; i < g_PoolSize; ++i)
	{
		g_SurfPool[i] = NULL ;
		if (FAILED(hr = g_pd3dDevice->CreateOffscreenPlainSurface(d3dpp.BackBufferWidth, 
			d3dpp.BackBufferHeight, d3dpp.BackBufferFormat, D3DPOOL_SYSTEMMEM, &g_SurfPool[i], NULL)))
		{
			return hr;
		}
	}

	return S_OK; 
} 
开发者ID:BillyKim,项目名称:directxcode,代码行数:58,代码来源:RealtimeScreenCopy_MultiThread.cpp

示例8: InitD3D

BOOL InitD3D(HWND hwnd)
{
	HRESULT hr;
	D3DDISPLAYMODE disp_mode;
	D3DPRESENT_PARAMETERS pp;

	if (g_bSetupOK) return TRUE;

	if (g_pD3D) return FALSE;

	g_pD3D = Direct3DCreate9(D3D_SDK_VERSION);
	if (!g_pD3D) return FALSE;
	
	hr = g_pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &disp_mode);
	if (FAILED(hr)) 
	{
		g_pD3D->Release();
		g_pD3D = NULL;
		return FALSE;
	}
	
	ZeroMemory(&pp, sizeof(D3DPRESENT_PARAMETERS));
	pp.Windowed = true;
	pp.SwapEffect = D3DSWAPEFFECT_DISCARD;
	pp.BackBufferFormat = disp_mode.Format;
	pp.EnableAutoDepthStencil = TRUE;
	pp.AutoDepthStencilFormat = D3DFMT_D16;
    pp.BackBufferCount = 1;

	BOOL flgSoft = GetPrivateProfileInt("GENERIC","LEVEL",1,".\\TDWGame.ini");

	char buff[256];
	wsprintf(buff,"%d",flgSoft);
	WritePrivateProfileString("GENERIC","LEVEL",buff,".\\TDWGame.ini");

	hr = g_pD3D->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,hwnd,D3DCREATE_HARDWARE_VERTEXPROCESSING,&pp,&g_pD3DDevice);
	if (FAILED(hr))
	{
		hr = g_pD3D->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,hwnd,D3DCREATE_SOFTWARE_VERTEXPROCESSING,&pp,&g_pD3DDevice);
		if (FAILED(hr)) 
		{
			hr = g_pD3D->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_REF,hwnd,D3DCREATE_SOFTWARE_VERTEXPROCESSING,&pp,&g_pD3DDevice);
			if (FAILED(hr)) 
			{
				g_pD3D->Release();
				g_pD3D = NULL;
				return FALSE;
			}
		}
	}

	D3DCAPS9 DX9DCaps;
	g_pD3DDevice->GetDeviceCaps(&DX9DCaps);
	g_bSetupOK = TRUE;
	return TRUE;	
}
开发者ID:fedaykinofdune,项目名称:ffxinfinity,代码行数:56,代码来源:TDWGame.cpp

示例9: SetVideoMode

RString RageDisplay_D3D::Init( const VideoModeParams &p, bool /* bAllowUnacceleratedRenderer */ )
{
	GraphicsWindow::Initialize( true );

	LOG->Trace( "RageDisplay_D3D::RageDisplay_D3D()" );
	LOG->MapLog("renderer", "Current renderer: Direct3D");

	g_pd3d = Direct3DCreate9(D3D_SDK_VERSION);
	if(!g_pd3d)
	{
		LOG->Trace( "Direct3DCreate9 failed" );
		return D3D_NOT_INSTALLED.GetValue();
	}

	if( FAILED( g_pd3d->GetDeviceCaps(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &g_DeviceCaps) ) )
		return HARDWARE_ACCELERATION_NOT_AVAILABLE.GetValue();
			

	D3DADAPTER_IDENTIFIER9	identifier;
	g_pd3d->GetAdapterIdentifier( D3DADAPTER_DEFAULT, 0, &identifier );

	LOG->Trace( 
		"Driver: %s\n"
		"Description: %s\n"
		"Max texture size: %d\n"
		"Alpha in palette: %s\n",
		identifier.Driver, 
		identifier.Description,
		g_DeviceCaps.MaxTextureWidth,
		(g_DeviceCaps.TextureCaps & D3DPTEXTURECAPS_ALPHAPALETTE) ? "yes" : "no" );

	LOG->Trace( "This display adaptor supports the following modes:" );
	D3DDISPLAYMODE mode;

	UINT modeCount = g_pd3d->GetAdapterModeCount(D3DADAPTER_DEFAULT, g_DefaultAdapterFormat);

	for( UINT u=0; u < modeCount; u++ )
		if( SUCCEEDED( g_pd3d->EnumAdapterModes( D3DADAPTER_DEFAULT, g_DefaultAdapterFormat, u, &mode ) ) )
			LOG->Trace( "  %ux%u %uHz, format %d", mode.Width, mode.Height, mode.RefreshRate, mode.Format );

	g_PaletteIndex.clear();
	for( int i = 0; i < 256; ++i )
		g_PaletteIndex.push_back(i);

	// Save the original desktop format.
	g_pd3d->GetAdapterDisplayMode( D3DADAPTER_DEFAULT, &g_DesktopMode );

	/* Up until now, all we've done is set up g_pd3d and do some queries. Now,
	 * actually initialize the window. Do this after as many error conditions as
	 * possible, because if we have to shut it down again we'll flash a window briefly. */
	bool bIgnore = false;
	return SetVideoMode( p, bIgnore );
}
开发者ID:AratnitY,项目名称:stepmania,代码行数:53,代码来源:RageDisplay_D3D.cpp

示例10: ZeroMemory

D3DDevice::D3DDevice(HWND hwnd, LPDIRECT3D9 d3d, size_t width, size_t height,
        bool fullscreen)
{
    HRESULT ret = 0;
    D3DPRESENT_PARAMETERS settings;
    D3DDISPLAYMODE dmode;

    ZeroMemory(&settings, sizeof(D3DPRESENT_PARAMETERS));

    ret = d3d->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &dmode);
    if(FAILED(ret))
    {
        return;
    }

    settings.BackBufferWidth = width;
    settings.BackBufferHeight = height;
    settings.BackBufferFormat = fullscreen ? dmode.Format : D3DFMT_UNKNOWN;
    settings.BackBufferCount = 1;
    //settings.hDeviceWindow = hwnd;
    settings.Windowed = !fullscreen;
    settings.SwapEffect = D3DSWAPEFFECT_DISCARD;

    if(SUCCEEDED(d3d->CheckDeviceMultiSampleType(D3DADAPTER_DEFAULT, 
                    D3DDEVTYPE_HAL, settings.BackBufferFormat, !fullscreen,
                    D3DMULTISAMPLE_2_SAMPLES, NULL)))
    {
        settings.MultiSampleQuality = D3DMULTISAMPLE_2_SAMPLES;
    }
    else
    {
        settings.MultiSampleQuality = D3DMULTISAMPLE_NONE;
    }

    settings.EnableAutoDepthStencil = false;
    settings.AutoDepthStencilFormat = D3DFMT_D16;
    settings.FullScreen_RefreshRateInHz = 0;
    settings.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; //0;
    settings.Flags = D3DPRESENTFLAG_LOCKABLE_BACKBUFFER;

    ret = d3d->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hwnd,
            D3DCREATE_SOFTWARE_VERTEXPROCESSING, &settings, &m_device);

    if(FAILED(ret))
    {
        m_device = NULL;
        /* TODO */
        return;
    }

    /* copy settings */
    memcpy(&m_settings, &settings, sizeof(settings));
}
开发者ID:xmppjingle,项目名称:sip-comm-jn,代码行数:53,代码来源:d3d_device.cpp

示例11: InitD3D

LRESULT InitD3D(HWND hWnd)
{
	if( NULL == ( g_pD3D = Direct3DCreate9( D3D_SDK_VERSION ) ) )
		return E_FAIL;
	D3DDISPLAYMODE d3ddm;
	if( FAILED( g_pD3D->GetAdapterDisplayMode( D3DADAPTER_DEFAULT, &d3ddm ) ) )
		return E_FAIL;
	D3DPRESENT_PARAMETERS d3dpp; 
	ZeroMemory( &d3dpp, sizeof(d3dpp) );
	d3dpp.Windowed   = TRUE;

	d3dpp.BackBufferCount        = 2;
	d3dpp.MultiSampleType        = D3DMULTISAMPLE_NONE;
	d3dpp.MultiSampleQuality     =0;

	d3dpp.SwapEffect = D3DSWAPEFFECT_FLIP;
	d3dpp.BackBufferFormat = d3ddm.Format;
    d3dpp.EnableAutoDepthStencil = TRUE;
    d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
	d3dpp.Flags              = D3DPRESENTFLAG_DISCARD_DEPTHSTENCIL;
	d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;

	if(theViewer.getFullscreen())
	{
		d3dpp.Windowed   = FALSE;
		d3dpp.BackBufferWidth=theViewer.getWidth();
		d3dpp.BackBufferHeight=theViewer.getHeight();

	}

	D3DCAPS9 Caps;
	g_pD3D->GetDeviceCaps(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,&Caps);

	if(Caps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT)
	{
        if( FAILED( g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,
                                  D3DCREATE_HARDWARE_VERTEXPROCESSING,
                                  &d3dpp, &g_pD3DDevice ) ) )
			return E_FAIL;
	}
	else
	{
		if( FAILED( g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,
                                  D3DCREATE_SOFTWARE_VERTEXPROCESSING,
                                  &d3dpp, &g_pD3DDevice ) ) )
			return E_FAIL;
	}

	
	return S_OK;
}
开发者ID:StevenTCramer,项目名称:WhiteStarUml,代码行数:51,代码来源:main.cpp

示例12: InitDX

bool InitDX(HWND hwnd)
{
	g_pD3D=Direct3DCreate9(D3D_SDK_VERSION);
	if(g_pD3D==NULL){
		OutputDebugString("failed -Direct3DCreate9()");
	}

	HRESULT hr;
	D3DDISPLAYMODE d3ddm;
	hr=g_pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT,&d3ddm);
	if(FAILED(hr)){
		OutputDebugString("InitD3D failed -GetAdapterDisplayMode() failed");
		return false;
	}

	//プレゼンテーションパラメータの設定
	D3DPRESENT_PARAMETERS D3DPP;
	ZeroMemory(&D3DPP,sizeof(D3DPRESENT_PARAMETERS));
	D3DPP.BackBufferCount=1;
	if(ISFULLSCREENED){
		D3DPP.Windowed			 = false;
		D3DPP.BackBufferWidth	 = DEFAULT_CLIANT_WIDTH;
		D3DPP.BackBufferHeight	 = DEFAULT_CLIANT_HEIGHT;
	}
	else{
		D3DPP.Windowed=true;
	}
	D3DPP.BackBufferFormat		 = d3ddm.Format;
	D3DPP.SwapEffect			 = D3DSWAPEFFECT_DISCARD;
	D3DPP.EnableAutoDepthStencil = true;
	D3DPP.AutoDepthStencilFormat = D3DFMT_D16;
	D3DPP.Flags					 = true;
	D3DPP.PresentationInterval	 = D3DPRESENT_INTERVAL_ONE;
   
//デバイスオブジェクトの作成
	if(FAILED(g_pD3D->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,hwnd,D3DCREATE_HARDWARE_VERTEXPROCESSING,&D3DPP,&g_pD3DDev))){
		if(FAILED(g_pD3D->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,hwnd,D3DCREATE_SOFTWARE_VERTEXPROCESSING,&D3DPP,&g_pD3DDev))){
			if(FAILED(g_pD3D->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_REF,hwnd,D3DCREATE_SOFTWARE_VERTEXPROCESSING,&D3DPP,&g_pD3DDev))){
				OutputDebugString("InitD3D failed -デバイスオブジェクトの作成に失敗 \n");
				return false;
			}
		}
	}

	g_pD3DDev->CreateTexture(SCREEN_WIDTH, SCREEN_HEIGHT, 1,D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8,D3DPOOL_DEFAULT,&g_tex, NULL);

	return true;
}
开发者ID:kairouen,项目名称:rendering1hour,代码行数:48,代码来源:Source.cpp

示例13: InitializeD3D

bool InitializeD3D(HWND hWnd, bool fullscreen)
{
    D3DDISPLAYMODE displayMode;

    g_D3D = Direct3DCreate9(D3D_SDK_VERSION);
    if(g_D3D == NULL) return false;

    if(FAILED(g_D3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT,
        &displayMode)))
    {
        return false;
    }

    D3DPRESENT_PARAMETERS d3dpp;
    ZeroMemory(&d3dpp, sizeof(d3dpp));

    if(fullscreen)
    {
        d3dpp.Windowed = FALSE;
        d3dpp.BackBufferWidth = 640;
        d3dpp.BackBufferHeight = 480;
    }
    else
    {
        d3dpp.Windowed = TRUE;
        d3dpp.BackBufferWidth = 640;
        d3dpp.BackBufferHeight = 480;
    }

    d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
    d3dpp.BackBufferFormat = displayMode.Format;

    if(FAILED(g_D3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,
        D3DCREATE_HARDWARE_VERTEXPROCESSING, &d3dpp, &g_D3DDevice)))
    {
        return false;
    }

    return true;
}
开发者ID:XadillaX,项目名称:dxlearning,代码行数:40,代码来源:main.cpp

示例14:

//--------------------------------------------------------------------------------------
DepthTexture::DepthTexture(const LPDIRECT3D9 d3d) {
	D3DDISPLAYMODE currentDisplayMode;
	d3d->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &currentDisplayMode);

	// determine if RESZ is supported
	m_isRESZ = d3d->CheckDeviceFormat(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
		currentDisplayMode.Format, D3DUSAGE_RENDERTARGET, D3DRTYPE_SURFACE, FOURCC_RESZ) == D3D_OK;
	SDLOG(-1, "[DepthTexture] RESZ: %s\n", m_isRESZ?"true":"false");

	// determine if INTZ is supported
	m_isINTZ = d3d->CheckDeviceFormat(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
		currentDisplayMode.Format, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, FOURCC_INTZ) == D3D_OK;
	SDLOG(-1, "[DepthTexture] INTZ: %s\n", m_isINTZ ? "true" : "false");

	// determine if RAWZ is supported, used in GeForce 6-7 series.
	m_isRAWZ = d3d->CheckDeviceFormat(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
		currentDisplayMode.Format, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, FOURCC_RAWZ) == D3D_OK;
	SDLOG(-1, "[DepthTexture] RAWZ: %s\n", m_isRAWZ ? "true" : "false");

	// determine if RESZ or NVAPI supported
	m_isSupported = (NvAPI_Initialize() == NVAPI_OK || m_isRESZ) && (m_isRAWZ || m_isINTZ);
}
开发者ID:007au,项目名称:gedosato,代码行数:23,代码来源:depth_texture.cpp

示例15: InitD3D

/**-----------------------------------------------------------------------------
* Direct3D 초기화
*------------------------------------------------------------------------------
*/
HRESULT InitD3D( HWND hWnd )
{
	/// 디바이스를 생성하기위한 D3D객체 생성
	if( NULL == ( g_pD3D = Direct3DCreate9( D3D_SDK_VERSION ) ) )
		return E_FAIL;

	/// 디바이스를 생성할 구조체
	D3DPRESENT_PARAMETERS d3dpp;
	ZeroMemory( &d3dpp, sizeof(d3dpp) );

	D3DDISPLAYMODE d3ddm;
	if(FAILED(g_pD3D->GetAdapterDisplayMode(0, &d3ddm))) {
		MessageBox(NULL, "GetAdapterDisplayMode failed", "Error", MB_OK);
		return false;
	}

	d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
	d3dpp.BackBufferCount		 = 1;
	d3dpp.BackBufferFormat		 = d3ddm.Format;
	d3dpp.BackBufferHeight		 = HEIGHT;
	d3dpp.BackBufferWidth		 = WIDTH;
	d3dpp.EnableAutoDepthStencil = TRUE;
	d3dpp.hDeviceWindow			 = hWnd;
	d3dpp.PresentationInterval	 = D3DPRESENT_INTERVAL_IMMEDIATE;
	d3dpp.SwapEffect			 = D3DSWAPEFFECT_DISCARD;
	d3dpp.Windowed				 = TRUE;


	/// 디바이스 생성
	if( FAILED( g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,
		D3DCREATE_SOFTWARE_VERTEXPROCESSING,
		&d3dpp, &g_pd3dDevice ) ) )
	{
		return E_FAIL;
	}

	return S_OK;
}
开发者ID:jjuiddong,项目名称:Dx3D-Study,代码行数:42,代码来源:BasicFrame.cpp


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