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


C++ LPDIRECT3DDEVICE9::Reset方法代码示例

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


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

示例1:

// Resets the D3D device and recreates triangle geometry.
HRESULT FxPlayerTiny::ResetD3D()
{   
    // Set new mode
    if( FAILED(pDevice->Reset(&PresentParams) ))
        return E_FAIL;
    return S_OK;
}
开发者ID:0521guo,项目名称:RakNet,代码行数:8,代码来源:GFxPlayerTinyD3D9.cpp

示例2: BuildPresentParameters

//-----------------------------------------------------------------------------
// Name : ResetDisplay ()
// Desc : Reset the display device, and optionally the window etc.
//-----------------------------------------------------------------------------
HRESULT CD3DInitialize::ResetDisplay( LPDIRECT3DDEVICE9 pD3DDevice, CD3DSettings& D3DSettings, HWND hWnd )
{   
    D3DPRESENT_PARAMETERS d3dpp = BuildPresentParameters( D3DSettings );
    CD3DSettings::Settings *pSettings   = D3DSettings.GetSettings();

    if ( hWnd )
    {
        // Setup styles based on windowed / fullscreen mode
        if ( !D3DSettings.Windowed )
        {
            SetMenu( hWnd, NULL );
            SetWindowLong( hWnd, GWL_STYLE, WS_VISIBLE | WS_POPUP );
            SetWindowPos( hWnd, NULL, 0, 0, pSettings->DisplayMode.Width, pSettings->DisplayMode.Height, SWP_NOZORDER );
        
        } // End if Fullscreen
        else
        {
            SetWindowLong( hWnd, GWL_STYLE, WS_OVERLAPPEDWINDOW );
            SetWindowPos( hWnd, HWND_NOTOPMOST, 50, 50, 800, 600, SWP_NOACTIVATE | SWP_SHOWWINDOW );

        } // End if Windowed

    } // End if

    // Reset the device
    HRESULT hRet = pD3DDevice->Reset( &d3dpp );
    if ( FAILED( hRet ) ) return hRet;

    // Success
    return S_OK;
}
开发者ID:alwynd,项目名称:PublicGitRepo,代码行数:35,代码来源:CD3DInitialize.cpp

示例3: ResizeWindowDX9

void ResizeWindowDX9(int width, int height)
{
	// 取得Direct3D 9裝置
	LPDIRECT3DDEVICE9 device = GutGetGraphicsDeviceDX9();

	D3DPRESENT_PARAMETERS d3dpresent;

	ZeroMemory( &d3dpresent, sizeof(d3dpresent) );
	d3dpresent.Windowed = TRUE; // 使用視窗模式
	d3dpresent.SwapEffect = D3DSWAPEFFECT_DISCARD;
	d3dpresent.BackBufferFormat = D3DFMT_UNKNOWN; // 使用視窗模式可以不去設定
	d3dpresent.BackBufferCount = 1; // 提供一塊backbuffer
	d3dpresent.EnableAutoDepthStencil = TRUE; // 自動開啟DepthStencil Buffer
	d3dpresent.AutoDepthStencilFormat = D3DFMT_D24S8; // DepthStencil Buffer模式

	device->Reset(&d3dpresent);

	// 投影矩陣, 重設水平跟垂直方向的視角.
	float aspect = (float) height / (float) width;
	Matrix4x4 projection_matrix = GutMatrixPerspectiveRH_DirectX(90.0f, aspect, 0.1f, 100.0f);
	device->SetTransform(D3DTS_PROJECTION, (D3DMATRIX *) &projection_matrix);
	// 關閉打光
	device->SetRenderState(D3DRS_LIGHTING, FALSE);
	// 改變三角形正面的面向
	device->SetRenderState(D3DRS_CULLMODE, D3DCULL_CW);
}
开发者ID:as2120,项目名称:ZNginx,代码行数:26,代码来源:render_dx9.cpp

示例4: WndProc

LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {
	if (ImGui_ImplDX9_WndProcHandler(hWnd, msg, wParam, lParam))
		return true;

	switch (msg) {
	case WM_SIZE:
		if (g_pd3dDevice != NULL && wParam != SIZE_MINIMIZED) {
			ImGui_ImplDX9_InvalidateDeviceObjects();
			g_d3dpp.BackBufferWidth = LOWORD(lParam);
			g_d3dpp.BackBufferHeight = HIWORD(lParam);
			HRESULT hr = g_pd3dDevice->Reset(&g_d3dpp);
			if (hr == D3DERR_INVALIDCALL)
				IM_ASSERT(0);
			ImGui_ImplDX9_CreateDeviceObjects();
		}
		return 0;
	case WM_SYSCOMMAND:
		if ((wParam & 0xfff0) == SC_KEYMENU) // Disable ALT application menu
			return 0;
		break;
	case WM_DESTROY:
		PostQuitMessage(0);
		return 0;
	}
	return DefWindowProc(hWnd, msg, wParam, lParam);
}
开发者ID:Junky228,项目名称:OpenBoardView,代码行数:26,代码来源:main.cpp

示例5: GetBackBufferDesc

HRESULT KG3DGraphicsEngine::Reset()
{
    HRESULT hr = E_FAIL;

    if (!m_bDeviceObjectsLost)
    {
        if (m_pDeviceCallback)
        {
            hr = m_pDeviceCallback->OnLostDevice();
            KGLOG_COM_PROCESS_ERROR(hr);
        }

        m_bDeviceObjectsLost = true;
    }

    if (m_bDeviceObjectsLost)
    {
        hr = g_pd3dDevice->Reset(&m_PresentParam);
        KGLOG_COM_PROCESS_ERROR(hr);

        hr = g_pd3dDevice->EvictManagedResources();
        KGLOG_COM_PROCESS_ERROR(hr);

        hr = GetBackBufferDesc(g_pd3dDevice, &m_BackBufferSurfaceDesc);
        KGLOG_COM_PROCESS_ERROR(hr);

        if (m_pDeviceCallback)
        {
            D3DLIGHT9 Light;

            hr = m_pDeviceCallback->OnResetDevice(g_pd3dDevice, &m_BackBufferSurfaceDesc, &m_PresentParam);
            KGLOG_COM_PROCESS_ERROR(hr);

            m_bDeviceLost = false;

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

            Light.Type = D3DLIGHT_DIRECTIONAL;
            Light.Direction.x = 1.0f;
            Light.Direction.y = 0.0f;
            Light.Direction.z = 0.0f;

            hr = g_pd3dDevice->SetLight(0, &Light);
            KGLOG_COM_PROCESS_ERROR(hr);

        }
        m_bDeviceObjectsLost = false;
    }

Exit0:
    if (hr == D3DERR_DEVICELOST)
        m_bDeviceLost = true;
    else
        KGLOG_COM_CHECK_ERROR(hr);
    return hr;
}
开发者ID:1suming,项目名称:pap2,代码行数:56,代码来源:KG3DGraphiceEngine.cpp

示例6:

// 描画終了
bool D3D::End()
{
	s_lpD3DDevice->EndScene();

	if( FAILED( s_lpD3DDevice->Present( NULL, NULL, NULL, NULL ) ) )
	{
		if( FAILED( s_lpD3DDevice->Reset( &s_D3DPP ) ) )
		{
			return false;
		}
	}

	return true;
}
开发者ID:akinobufujii,项目名称:BubbleFight,代码行数:15,代码来源:DirectGraphics.cpp

示例7: restore_objects

	bool restore_objects()
	{
		if ( retry_count )
		{
			if ( --retry_count ) return false;

			release_objects();
			if ( lpdev->Reset( &dpp ) != D3D_OK ) return false;
		}

		retry_count = 0;

		LPDIRECT3DSURFACE9 lpbb;
		HRESULT hr;
		if( SUCCEEDED( hr = lpdev->GetBackBuffer( 0, 0, D3DBACKBUFFER_TYPE_MONO, & lpbb ) ) ) {
			lpbb->GetDesc( & d3dsd );
			lpbb->Release();
		}

		lpdev->SetTextureStageState(0, D3DTSS_COLOROP,   D3DTOP_SELECTARG1);
		lpdev->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
		lpdev->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);

		lpdev->SetTextureStageState(0, D3DTSS_ALPHAOP,   D3DTOP_SELECTARG1);
		lpdev->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
		lpdev->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE);

		lpdev->SetRenderState(D3DRS_LIGHTING, false);
		lpdev->SetRenderState(D3DRS_ZENABLE,  false);
		lpdev->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);

		lpdev->SetRenderState(D3DRS_SRCBLEND,  D3DBLEND_SRCALPHA);
		lpdev->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
		lpdev->SetRenderState(D3DRS_ALPHABLENDENABLE, false);

		lpdev->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX1);

		if ( lpdev->CreateVertexBuffer( sizeof(d3dvertex) * 4, flags.v_usage, D3DFVF_XYZRHW | D3DFVF_TEX1, (D3DPOOL)flags.v_pool, &lpvbuf, NULL ) != D3D_OK )
			return false;

		update_filtering( 1 );

		lpdev->SetRenderState( D3DRS_DITHERENABLE,   TRUE );

		if ( lpdev->CreateTexture( surface_width, surface_height, 1, flags.t_usage, D3DFMT_X8R8G8B8, (D3DPOOL)flags.t_pool, &lptex, NULL ) != D3D_OK )
			return false;

		return true;
	}
开发者ID:kode54,项目名称:QuickNES_Windows,代码行数:49,代码来源:display_d3d9.cpp

示例8: ResetDevice

void ResetDevice(void)
{
    D3DPRESENT_PARAMETERS d3dpp;
    ZeroMemory(&d3dpp, sizeof(d3dpp));
    d3dpp.Windowed = windowed;
    d3dpp.hDeviceWindow = g_hWnd_0;
    d3dpp.SwapEffect = D3DSWAPEFFECT_FLIP;
    d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
    d3dpp.BackBufferWidth = SCREEN_WIDTH; // set the width of the buffer
    d3dpp.BackBufferHeight = SCREEN_HEIGHT; // set the height of the buffer
    d3dpp.BackBufferCount = 1;
    d3dpp.EnableAutoDepthStencil = TRUE;
    d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
    d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
    g_pd3dDevice_0->Reset(&d3dpp);
}
开发者ID:djrobx,项目名称:vpinballx,代码行数:16,代码来源:multipleFullscreen.c

示例9: ResetDevice

//因为要调用InitMyScene,所以用UINT作返回值,返回0表示正常
UINT ResetDevice()
{
	// 虽然只需要让弹出之前Release一次即可,但该操作并不费时,且类都有保护措施,重复Release也不会出问题(自动返回)
	ReleaseMyScene();
	
	d3dpp.Windowed = WindowMode;
	d3dpp.BackBufferWidth = d3ddm.Width;
	d3dpp.BackBufferHeight = d3ddm.Height;
	//若为窗口模式,则取桌面的颜色数,取当前窗口的大小和位置,并重置
	if(WindowMode)
	{
		d3ddm.Format = DesktopDisplayMode.Format;
		d3dpp.BackBufferWidth = WindowWidth;
		d3dpp.BackBufferHeight = WindowHeight;
		MoveWindow(hWnd, WindowX, WindowY, WindowWidth, WindowHeight, TRUE);
	}

	d3dpp.BackBufferFormat = d3ddm.Format;
	//根据显示模式来确定创建纹理和深度模板缓冲的像素格式
	if(d3ddm.Format == D3DFMT_X8R8G8B8)
	{
		d3dpp.AutoDepthStencilFormat = D3DFMT_D24S8;
		TextureFormat = D3DFMT_A8R8G8B8;
	}
	else
	{
		d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
		TextureFormat = D3DFMT_A4R4G4B4;
	}

	UINT hr = FAILED(d3ddevice->Reset(&d3dpp))?1:0;
	
	if(hr) return hr;

	// 弹出对话框之前也要调用该函数,可我们只需要让弹出之后Init一次即可,避免弹出之前也Init,没必要,费时
	if(!DialogSign)
	{
		hr = InitMyScene();
	}

	CameraChange.ViewTransform();

	return hr;
}
开发者ID:xiaohuaxiong,项目名称:hello-world,代码行数:45,代码来源:Myd3d.cpp

示例10: D3D9_Resize

void D3D9_Resize(HWND window) {
    // This should only be called from the emu thread.

    int xres, yres;
    GetRes(xres, yres);
    bool w_changed = pp.BackBufferWidth != xres;
    bool h_changed = pp.BackBufferHeight != yres;

    if (device && (w_changed || h_changed)) {
        DX9::fbo_shutdown();

        pp.BackBufferWidth = xres;
        pp.BackBufferHeight = yres;
        HRESULT hr = device->Reset(&pp);
        if (FAILED(hr)) {
            ERROR_LOG_REPORT(G3D, "Unable to reset device: %s", DXGetErrorStringA(hr));
            PanicAlert("Unable to reset D3D9 device: %s", DXGetErrorStringA(hr));
        }
        DX9::fbo_init(d3d);
    }
}
开发者ID:CTimpone,项目名称:libretro-ppsspp,代码行数:21,代码来源:D3D9Base.cpp

示例11: WindowProc

// this is the main message handler for the program
LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch(message)
    {
        case WM_DESTROY:
        {
			::exit(0);
            PostQuitMessage(0);
            return 0;
        } 
        case WM_SIZE:
        {
			// If the device is not NULL and the WM_SIZE message is not a
			// SIZE_MINIMIZED event, resize the device's swap buffers to match
			// the new window size.
			if( d3ddev != NULL && wParam != SIZE_MINIMIZED )
			{
				OnRelease();

				ScreenX					= LOWORD(lParam);	
				ScreenY					= HIWORD(lParam);
				d3dpp.BackBufferWidth  = LOWORD(lParam);
				d3dpp.BackBufferHeight = HIWORD(lParam);

				//if(
				d3ddev->Reset( &d3dpp )
                // == D3DERR_INVALIDCALL )
                //{
                   //error
                //}
				;
				OnInitialize(false);
			}
        }
		break;
    }

    return DefWindowProc (hWnd, message, wParam, lParam);
}
开发者ID:grasmanek94,项目名称:RA3-IM,代码行数:40,代码来源:main.cpp

示例12: resetdevice

int resetdevice(const char *)
{
	if(windowed==0)
	{
		if(screenwidth==0 || screenheight==0)
		{
			D3DDISPLAYMODE displaymode;
			g_pd3dDevice->GetDisplayMode(0,&displaymode);
			screenwidth  = displaymode.Width;
			screenheight = displaymode.Height;
		}
		Width = screenwidth;
		Height= screenheight;
	}
	else // windowed
	{
		Width = (int)(windowwidth );
		Height= (int)(windowheight);
	}
	oneoverwidth=1.0f/Width;
	oneoverheight=1.0f/Height;
	d3dpp.BackBufferWidth = Width;
	d3dpp.BackBufferHeight = Height;
    d3dpp.Windowed = (windowed)?1:0;
	d3dpp.BackBufferFormat = (d3dpp.Windowed)?D3DFMT_UNKNOWN:D3DFMT_X8R8G8B8 ;
	d3dpp.BackBufferCount = backbuffercount;
	d3dpp.PresentationInterval = vsync ? D3DPRESENT_INTERVAL_DEFAULT : D3DPRESENT_INTERVAL_IMMEDIATE;
	vsync_current = vsync;
	effectlostdevice();
	cuberelease();

	HRESULT hr = g_pd3dDevice->Reset(&d3dpp);
	assert(hr==0);
	effectresetdevice();
	if(windowed)
            SetWindowPos( hWnd, HWND_NOTOPMOST,windowx+window_inset.left,windowy+window_inset.top,windowwidth+window_inset.right-window_inset.left, windowheight+window_inset.bottom-window_inset.top,SWP_SHOWWINDOW );
	return hr;
}
开发者ID:Thyfate,项目名称:melax,代码行数:38,代码来源:winsetup.cpp

示例13: ResetDevice

HRESULT ResetDevice(D3DPRESENT_PARAMETERS d3dpp)
{
	// Check device state
	HRESULT hr = g_pd3dDevice->TestCooperativeLevel() ;

	// Device can be reset now
	if (SUCCEEDED(hr) || hr == D3DERR_DEVICENOTRESET)
	{
		// Release resource allocated as D3DPOOL_DEFAULT
		g_pVB->Release();

		// Reset device
		HRESULT hr = g_pd3dDevice->Reset(&d3dpp) ;
		if (FAILED(hr))
		{
			const CHAR* errorString = DXGetErrorString(hr) ;
			DXTRACE_ERR_MSGBOX(errorString, hr) ;
		}

		// Recreate the vertex buffer, since it is create by using
		// D3DPOOL_DEFAULT, the function MUST placed here!!! why?
		// you cann't place it before the return clause of this function
		// what's the inner cause?
		InitVB();
	}
	// Device is still in lost state, wait
	else if (hr == D3DERR_DEVICELOST)
	{
		Sleep(25) ;
	}
	else // Other error, Show error box
	{
		const CHAR* errorString = DXGetErrorString(hr) ;
		DXTRACE_ERR_MSGBOX(errorString, hr) ;
	}

	return hr ;
}
开发者ID:Clearlove1992,项目名称:GraphicsDemos,代码行数:38,代码来源:HandleDeviceLost.cpp

示例14: SetD3DParams

RString SetD3DParams( bool &bNewDeviceOut )
{
	if( g_pd3dDevice == NULL ) // device is not yet created. We need to create it
	{
		bNewDeviceOut = true;
		HRESULT hr = g_pd3d->CreateDevice(
			D3DADAPTER_DEFAULT, 
			D3DDEVTYPE_HAL, 
			GraphicsWindow::GetHwnd(),
			D3DCREATE_HARDWARE_VERTEXPROCESSING | D3DCREATE_MULTITHREADED,
			&g_d3dpp, 
			&g_pd3dDevice );
		if( FAILED(hr) )
		{
			// Likely D3D_ERR_INVALIDCALL.  The driver probably doesn't support this video mode.
			return ssprintf( "CreateDevice failed: '%s'", GetErrorString(hr).c_str() );
		}
	}
	else
	{
		bNewDeviceOut = false;
		//LOG->Warn( "Resetting D3D device" );
		HRESULT hr = g_pd3dDevice->Reset( &g_d3dpp );
		if( FAILED(hr) )
		{
			// Likely D3D_ERR_INVALIDCALL.  The driver probably doesn't support this video mode.
			return ssprintf("g_pd3dDevice->Reset failed: '%s'", GetErrorString(hr).c_str() );
		}
	}

	g_pd3dDevice->SetRenderState( D3DRS_NORMALIZENORMALS, TRUE );	

	// Palettes were lost by Reset(), so mark them unloaded.
	g_TexResourceToPaletteIndex.clear();

	return RString();
}
开发者ID:AratnitY,项目名称:stepmania,代码行数:37,代码来源:RageDisplay_D3D.cpp

示例15: SetD3DParams

CString SetD3DParams( bool &bNewDeviceOut )
{
	if( g_pd3dDevice == NULL )		// device is not yet created.  We need to create it
	{
		bNewDeviceOut = true;
		HRESULT hr = g_pd3d->CreateDevice(
			D3DADAPTER_DEFAULT, 
			D3DDEVTYPE_HAL, 
#if !defined(XBOX)
			GraphicsWindow::GetHwnd(),
			D3DCREATE_SOFTWARE_VERTEXPROCESSING | D3DCREATE_MULTITHREADED,
#else
			NULL,
			D3DCREATE_HARDWARE_VERTEXPROCESSING,
#endif
			&g_d3dpp, 
			&g_pd3dDevice );
		if( FAILED(hr) )
		{
			// Likely D3D_ERR_INVALIDCALL.  The driver probably doesn't support this video mode.
			return ssprintf( "CreateDevice failed: '%s'", GetErrorString(hr).c_str() );
		}
	}
	else
	{
		bNewDeviceOut = false;
		HRESULT hr = g_pd3dDevice->Reset( &g_d3dpp );
		if( FAILED(hr) )
		{
			// Likely D3D_ERR_INVALIDCALL.  The driver probably doesn't support this video mode.
			return ssprintf("g_pd3dDevice->Reset failed: '%s'", GetErrorString(hr).c_str() );
		}
	}

	return "";
}
开发者ID:augustg,项目名称:openitg,代码行数:36,代码来源:RageDisplay_D3D.cpp


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