當前位置: 首頁>>代碼示例>>C++>>正文


C++ Direct3DCreate9函數代碼示例

本文整理匯總了C++中Direct3DCreate9函數的典型用法代碼示例。如果您正苦於以下問題:C++ Direct3DCreate9函數的具體用法?C++ Direct3DCreate9怎麽用?C++ Direct3DCreate9使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了Direct3DCreate9函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: Direct3DCreate9

int Renderer::startEngine(HWND hwnd, Model& model) {
	HRESULT r = 0;//return values

	pD3D_ = Direct3DCreate9(D3D_SDK_VERSION);//COM object
	if (pD3D_ == NULL) {
		Errors::SetError(TEXT("Could not create IDirect3D9 object"));
		return E_FAIL;
	}

	//4th argument is TRUE or FALSE, where FALSE means fullscreen.
	r = InitDirect3DDevice(hwnd, model.getWidth(), model.getHeight(), WINDOWED_MODE, D3DFMT_X8R8G8B8, pD3D_, &pDevice_);
	if (FAILED(r)) {//FAILED is a macro that returns false if return value is a failure - safer than using value itself
		Errors::SetError(TEXT("Initialization of the device failed"));
		return E_FAIL;
	}

	r = pDevice_->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &pBackBuffer_);
	if (FAILED(r)) {
		Errors::SetError(TEXT("Couldn't get backbuffer"));
	}

	return S_OK;
}
開發者ID:JoePelz,項目名稱:COMP4995_1,代碼行數:23,代碼來源:Renderer.cpp

示例2: InitD3D

//-----------------------------------------------------------------------------
// Desc: 初始化Direct3D
//-----------------------------------------------------------------------------
HRESULT InitD3D( HWND hWnd )
{
	//創建Direct3D對象, 該對象用於創建Direct3D設備對象
	if( NULL == ( g_pD3D = Direct3DCreate9( D3D_SDK_VERSION ) ) )
		return E_FAIL;

	//設置D3DPRESENT_PARAMETERS結構, 準備創建Direct3D設備對象
	D3DPRESENT_PARAMETERS d3dpp; 
	ZeroMemory( &d3dpp, sizeof(d3dpp) );
	d3dpp.Windowed = TRUE;
	d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
	d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
	d3dpp.EnableAutoDepthStencil = TRUE;
	d3dpp.AutoDepthStencilFormat = D3DFMT_D16;

	//創建Direct3D設備對象
	if( FAILED( g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,
		D3DCREATE_SOFTWARE_VERTEXPROCESSING,
		&d3dpp, &g_pd3dDevice ) ) )
	{
		return E_FAIL;
	}

	//設置紋理過濾狀態
	g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
	g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP,   D3DTOP_SELECTARG1 );
	g_pd3dDevice->SetSamplerState( 0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR );
	g_pd3dDevice->SetSamplerState( 0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR );

	//設置觀察矩陣和投影矩陣
	SetViewAndProjMatrix();

	ZeroMemory( m_bKey, 256 );
	D3DXMatrixIdentity(&g_matWorld);

	return S_OK;
}
開發者ID:as2120,項目名稱:ZNginx,代碼行數:40,代碼來源:StateControlUseMatrix.cpp

示例3: sizeof

	int D3DDevice::Init(HWND hWnd, bool bWindowed)
	{
		m_hWnd = hWnd;
		if( NULL == ( m_pD3D = Direct3DCreate9( D3D_SDK_VERSION ) ) )
			return -1;

		memset(&m_kCaps, 0, sizeof(D3DCAPS9));
		m_pD3D->GetDeviceCaps(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &m_kCaps);
		
		int vp = m_kCaps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT ? D3DCREATE_HARDWARE_VERTEXPROCESSING : D3DCREATE_SOFTWARE_VERTEXPROCESSING;
		
		memset( &m_kD3Dpp, 0, sizeof( m_kD3Dpp ) );
		m_kD3Dpp.Windowed = bWindowed;
		m_kD3Dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
		m_kD3Dpp.BackBufferFormat = D3DFMT_UNKNOWN;
		m_kD3Dpp.EnableAutoDepthStencil = TRUE;
		m_kD3Dpp.AutoDepthStencilFormat = D3DFMT_D16;

		// Create the D3DDevice
		if( FAILED( m_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, m_hWnd,
										  vp,
										  &m_kD3Dpp, &m_pd3dDevice ) ) )
		{
			return -1;
		}

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

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

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

		return 0;
	}
開發者ID:oksangman,項目名稱:Ant,代碼行數:37,代碼來源:AntD3DDevice.cpp

示例4: InitD3D

//-----------------------------------------------------------------------------
// Desc: 初始化Direct3D
//-----------------------------------------------------------------------------
HRESULT InitD3D( HWND hWnd )
{
    HRESULT hr = S_OK;

    //創建Direct3D對象, 該對象用來創建Direct3D設備對象
    if( NULL == ( g_pD3D = Direct3DCreate9( D3D_SDK_VERSION ) ) )
        return E_FAIL;

    //設置D3DPRESENT_PARAMETERS結構, 準備創建Direct3D設備對象
    D3DPRESENT_PARAMETERS d3dpp;
    ZeroMemory( &d3dpp, sizeof(d3dpp) );
    d3dpp.Windowed         = TRUE;
    d3dpp.SwapEffect       = D3DSWAPEFFECT_DISCARD;
    d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
    d3dpp.MultiSampleType  = D3DMULTISAMPLE_4_SAMPLES;

    //創建Direct3D設備對象
    if(FAILED(g_pD3D->CheckDeviceMultiSampleType (D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL
              ,D3DFMT_X8R8G8B8,FALSE,D3DMULTISAMPLE_4_SAMPLES,NULL)))
    {
        MessageBox(hWnd, L"硬件不支持多采樣反鋸齒!\n采用參考設備!"
                   , L"AntiAlisa", 0);
        hr = g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_REF, hWnd,
                                   D3DCREATE_SOFTWARE_VERTEXPROCESSING,
                                   &d3dpp, &g_pd3dDevice );
    }
    else
    {
        hr = g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,
                                   D3DCREATE_SOFTWARE_VERTEXPROCESSING,
                                   &d3dpp, &g_pd3dDevice );
    }

    //在此設置整個程序運行期間不變換的渲染狀態

    return hr;
}
開發者ID:erickterri,項目名稱:3dlearn,代碼行數:40,代碼來源:AntiAlisa.cpp

示例5: DummyWindowHandle

FD3D9MeshUtilities::FD3D9MeshUtilities()
	: DummyWindowHandle(0), Direct3D(0), Device(0)
{
	Direct3D = Direct3DCreate9(D3D_SDK_VERSION);

	if(!Direct3D)
	{
		return;
	}

	WNDCLASSEXW wc;

	ZeroMemory(&wc, sizeof(WNDCLASSEXW));

	wc.cbSize = sizeof(WNDCLASSEX);
	wc.lpszClassName = L"DummyWindowClass";
	wc.style = CS_HREDRAW | CS_VREDRAW;
	wc.lpfnWndProc = WindowProc;
	wc.hInstance = GetModuleHandle(0);
//	wc.hbrBackground = (HBRUSH)COLOR_WINDOW;

	RegisterClassExW(&wc);

	DummyWindowHandle = CreateWindowExW(NULL, wc.lpszClassName, L"", WS_OVERLAPPEDWINDOW, 0, 0, 100, 100, NULL, NULL, wc.hInstance, NULL);

	D3DPRESENT_PARAMETERS d3dpp;

	ZeroMemory(&d3dpp, sizeof(d3dpp));
	d3dpp.Windowed = 1;
	d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
	d3dpp.hDeviceWindow = DummyWindowHandle;
	d3dpp.BackBufferWidth = 1;
	d3dpp.BackBufferHeight = 1;
	d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;

	Direct3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_NULLREF, DummyWindowHandle, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &Device);
}
開發者ID:Tigrouzen,項目名稱:UnrealEngine-4,代碼行數:37,代碼來源:D3D9MeshUtils.cpp

示例6: InitD3D

//-----------------------------------------------------------------------------
// Desc: 初始化Direct3D
//-----------------------------------------------------------------------------
HRESULT InitD3D( HWND hWnd )
{
	//創建Direct3D對象, 該對象用於創建Direct3D設備對象
	if( NULL == ( g_pD3D = Direct3DCreate9( D3D_SDK_VERSION ) ) )
		return E_FAIL;

	//設置D3DPRESENT_PARAMETERS結構, 準備創建Direct3D設備對象
	D3DPRESENT_PARAMETERS d3dpp; 
	ZeroMemory( &d3dpp, sizeof(d3dpp) );
	d3dpp.Windowed = TRUE;
	d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
	d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;

	//創建Direct3D設備對象
	if( FAILED( g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,
		D3DCREATE_SOFTWARE_VERTEXPROCESSING,
		&d3dpp, &g_pd3dDevice ) ) )
	{
		return E_FAIL;
	}

	//禁用照明效果
	g_pd3dDevice->SetRenderState( D3DRS_LIGHTING, FALSE ); 

	//設置紋理渲染狀態
	g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP,   D3DTOP_SELECTARG1 );
	g_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
	g_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP,   D3DTOP_DISABLE );

	//設置紋理過濾方式
	g_pd3dDevice->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_POINT);

	//設置變換矩陣
	SetupMatrices();

	return S_OK;
}
開發者ID:chenbk85,項目名稱:3dlearn,代碼行數:40,代碼來源:TexAddressMode.cpp

示例7: ZeroMemory

HRESULT GraphicsEngine::InitD3D( HWND hWnd )
{
    // Create the D3D object.
    if( NULL == ( m_pD3D = Direct3DCreate9( D3D_SDK_VERSION ) ) )
        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	= D3DFMT_UNKNOWN;

	d3dpp.EnableAutoDepthStencil	= TRUE;
	d3dpp.AutoDepthStencilFormat	= D3DFMT_D16;

    // Create the D3DDevice
    if( FAILED( m_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,
                                      D3DCREATE_SOFTWARE_VERTEXPROCESSING,
                                      &d3dpp, &m_pDevice ) ) )
    {
        return E_FAIL;
    }
	
	//m_pDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_WIREFRAME);

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

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

	// Turn on the z-buffer
	m_pDevice->SetRenderState(D3DRS_ZENABLE, TRUE);
	
    return S_OK;
}
開發者ID:Nepomnyaschy,項目名稱:3d_graphic_engine_directx,代碼行數:37,代碼來源:GraphicsEngine.cpp

示例8: GetVertexProcessingCaps

	HRESULT DirectX9Renderer::InitDevice(D3DPRESENT_PARAMETERS d3dpp)
	{
		// Create the D3D object, which is needed to create the D3DDevice.
		if( NULL == ( m_pD3D = Direct3DCreate9( D3D_SDK_VERSION ) ) )
			return E_FAIL;

		////D3DCREATE_PUREDEVICE
		////D3DCREATE_MULTITHREADED
		//if( FAILED( m_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, m_hWindow,
		//	D3DCREATE_HARDWARE_VERTEXPROCESSING | D3DCREATE_MULTITHREADED,
		//	&d3dpp, &m_pd3dDevice ) ) )
		//{
		//	if( FAILED( m_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, m_hWindow,
		//		D3DCREATE_SOFTWARE_VERTEXPROCESSING | D3DCREATE_MULTITHREADED,
		//		&d3dpp, &m_pd3dDevice ) ) )
		//	{
		//		m_pd3dDevice=NULL;
		//		return E_FAIL;
		//	}
		//}

		// determine what type of vertex processing to use based on the device capabilities
		DWORD dwVertexProcessing = GetVertexProcessingCaps(m_pD3D);
		// create the D3D device
		if (FAILED(m_pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, m_hWindow,
			//dwVertexProcessing | D3DCREATE_MULTITHREADED | D3DCREATE_FPU_PRESERVE,
			dwVertexProcessing | D3DCREATE_MULTITHREADED,
			//dwVertexProcessing, //Very slow
			&d3dpp, &m_pd3dDevice))){
				return E_FAIL;
		}

		m_pd3dDevice->GetRenderTarget(0,&m_pBackBuffer);
		m_pd3dDevice->GetDepthStencilSurface(&m_pZStencilSurface);

		return S_OK;
	}
開發者ID:TheWhiteAmbit,項目名稱:TheWhiteAmbit,代碼行數:37,代碼來源:DirectX9Renderer.cpp

示例9: initDirect3D

bool initDirect3D(void)
{
    if (NULL == (pD3D = Direct3DCreate9(D3D_SDK_VERSION)))
    {
        return false;
    }

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

    DWORD flags = D3DCREATE_HARDWARE_VERTEXPROCESSING | D3DCREATE_PUREDEVICE | D3DCREATE_NOWINDOWCHANGES
            | D3DCREATE_MULTITHREADED;

    d3dpp.Windowed = true;
    d3dpp.Flags = 0;
    d3dpp.BackBufferCount = 0;
    d3dpp.BackBufferFormat = D3DFMT_A8R8G8B8;
    d3dpp.BackBufferHeight = HEIGHT;
    d3dpp.BackBufferWidth = WIDTH;
    d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE;
    d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
    d3dpp.hDeviceWindow = hWnd;
    d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
    d3dpp.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;

    if (FAILED(pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, flags, &d3dpp, &dev)))
    {
        return false;
    }

    if (FAILED(dev->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &pBackBuffer)))
    {
        return false;
    }

    return true;
}
開發者ID:112000,項目名稱:opencv,代碼行數:37,代碼來源:d3d9_interop.cpp

示例10: Direct3DCreate9

		bool DirectX9::InitializeContext( Gwen::WindowProvider* pWindow )
		{
			HWND pHWND = ( HWND ) pWindow->GetWindow();
			m_pD3D = Direct3DCreate9( D3D_SDK_VERSION );

			if ( !m_pD3D ) { return false; }

			D3DCAPS9 D3DCaps;
			m_pD3D->GetDeviceCaps( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &D3DCaps );
			DWORD BehaviourFlags = D3DCREATE_SOFTWARE_VERTEXPROCESSING;

			if ( D3DCaps.VertexProcessingCaps != 0 ) { BehaviourFlags = D3DCREATE_HARDWARE_VERTEXPROCESSING; }

			D3DPRESENT_PARAMETERS Params;
			FillPresentParameters( pWindow, Params );
			HRESULT hr = m_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, pHWND, D3DCREATE_HARDWARE_VERTEXPROCESSING, &Params, &m_pDevice );

			if ( FAILED( hr ) )
			{
				return false;
			}

			return true;
		}
開發者ID:garrynewman,項目名稱:GWEN,代碼行數:24,代碼來源:DirectX9.cpp

示例11: TRACE

bool Direct3D9Video::Init (bool fFirstInit_)
{
    TRACE("Direct3D9Video::Init()\n");

    // If hardware acceleration is disabled we should fall back on DirectDraw software
    if (!GetOption(hwaccel))
        return false;

    // D3D.DLL is delay-loaded, so be prepared for this to fail if it's not available
    __try
    {
        m_pd3d = Direct3DCreate9(D3D_SDK_VERSION);
    }
    __except (EXCEPTION_EXECUTE_HANDLER)
    {
        TRACE("D3D9.dll not found!\n");
        return false;
    }

    CreateDevice();
    UpdateSize();

    return m_pd3d != NULL;
}
開發者ID:libretro,項目名稱:libretro-simcoupe,代碼行數:24,代碼來源:Direct3D9.cpp

示例12: InitD3D

//-----------------------------------------------------------------------------
// Name: InitD3D()
// Desc: Initializes Direct3D
//-----------------------------------------------------------------------------
HRESULT InitD3D( HWND hWnd )
{
    // Create the D3D object.
    if( NULL == ( g_pD3D = Direct3DCreate9( D3D_SDK_VERSION ) ) )
        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 ) );
	vp_os_memset(&d3dpp, 0, sizeof( d3dpp ));
    d3dpp.Windowed = TRUE;
    d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
    d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
    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:mtran1990,項目名稱:ARDrone-Stuff,代碼行數:40,代碼來源:directx_rendering.cpp

示例13: initD3D

// this function initializes and prepares Direct3D for use
void initD3D(HWND hWnd)
{
    d3d = Direct3DCreate9(D3D_SDK_VERSION);

    D3DPRESENT_PARAMETERS d3dpp;

    ZeroMemory(&d3dpp, sizeof(d3dpp));
    d3dpp.Windowed = TRUE;
    d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
    d3dpp.hDeviceWindow = hWnd;
    d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
    d3dpp.BackBufferWidth = SCREEN_WIDTH;
    d3dpp.BackBufferHeight = SCREEN_HEIGHT;

    // create a device class using this information and the info from the d3dpp stuct
    d3d->CreateDevice(D3DADAPTER_DEFAULT,
                      D3DDEVTYPE_HAL,
                      hWnd,
                      D3DCREATE_SOFTWARE_VERTEXPROCESSING,
                      &d3dpp,
                      &d3ddev);

    init_graphics();    // call the function to initialize the triangle
}
開發者ID:anokata,項目名稱:AllInOne,代碼行數:25,代碼來源:d2.cpp

示例14: 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 = Direct3DCreate9( D3D_SDK_VERSION ) ) )
        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 = D3DFMT_UNKNOWN;

    // 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:DenisMath,項目名稱:LinFrac,代碼行數:40,代碼來源:CreateDevice.cpp

示例15: Direct3DCreate9

void d3d_control::initD3D(HWND hWnd)
{
    d3d = Direct3DCreate9(D3D_SDK_VERSION);    // create the Direct3D interface

    D3DPRESENT_PARAMETERS d3dpp;    // create a struct to hold various device information

    ZeroMemory(&d3dpp, sizeof(d3dpp));    // clear out the struct for use
    d3dpp.Windowed = TRUE;    // program windowed, not fullscreen
    d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;    // discard old frames
    d3dpp.hDeviceWindow = hWnd;    // set the window to be used by Direct3D
	d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
	d3dpp.EnableAutoDepthStencil = TRUE;
    d3dpp.AutoDepthStencilFormat = D3DFMT_D16;


    // create a device class using this information and the info from the d3dpp stuct
    d3d->CreateDevice(D3DADAPTER_DEFAULT,
                      D3DDEVTYPE_HAL,
                      hWnd,
                      D3DCREATE_SOFTWARE_VERTEXPROCESSING,
                      &d3dpp,
                      &d3ddev);
	
	d3ddev->SetRenderState(D3DRS_LIGHTING, FALSE);    // turn off the 3D lighting
    d3ddev->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);    // turn off culling
    d3ddev->SetRenderState(D3DRS_ZENABLE, TRUE);    // turn on the z-buffer
	d3ddev->SetRenderState(D3DRS_AMBIENT, D3DCOLOR_XRGB(50, 50, 50));    // ambient light
	
	d3ddev->SetRenderState(D3DRS_FILLMODE,D3DFILL_SOLID);

	init_axis();
	init_text();
	rs.create();
	fillmode_changed=false;
	is_solid = true;
}
開發者ID:windkey,項目名稱:KATAMARI,代碼行數:36,代碼來源:d3d_control.cpp


注:本文中的Direct3DCreate9函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。