Esempio n. 1
0
File: XApp.cpp Progetto: xahgo/tama
void OnResumeHandler()
{
	XTRACE( "XE::OnResumeHandler()" );
	RestoreDevice();
	if( GetMain() )
		GetMain()->OnResumeHandler();
}
Esempio n. 2
0
//==============================================================
// 윈도우 모드와 풀 스크린 모드 전환
void CGraphics::SetFullMode(bool full_mode) {
	if (FullMode!=full_mode) {
		FullMode=full_mode;
		RestoreDevice();
		if (full_mode) {

			// 풀 스크린 모드:
			// 캡션이나 시스템 메뉴를 제거하기
			SetWindowLong(HWnd, GWL_STYLE, WS_VISIBLE);

		} else {

			// 윈도우 모드:
			// 윈도우 스타일과 사이즈를 원래로 되돌림
			SetWindowLong(HWnd, GWL_STYLE, WindowStyle);
			RECT dr;
			GetWindowRect(GetDesktopWindow(), &dr);
			int w=FrameWidth+WinModeWidth, h=FrameHeight+WinModeHeight;
			SetWindowPos(HWnd, HWND_NOTOPMOST, 
				(dr.right-dr.left-w)/2, (dr.bottom-dr.top-h)/2, 
				w, h, SWP_SHOWWINDOW);

		}
	}
}
Esempio n. 3
0
void CGameRenderer::ProcessFrame(){ //process a frame of animation
	if(g_bImagesLoaded){ //wait for the image loading thread to finish
		//check for lost graphics device
		if(DeviceLost())RestoreDevice(); //if device lost, restore it
		//process a frame of animation
		ComposeFrame(); //compose a frame of animation
		PageFlip(); //flip to front
	}
} //ProcessFrame
Esempio n. 4
0
//==============================================================
// 생성자
CGraphics::CGraphics(HWND hwnd, bool zbuffer)
:	HWnd(hwnd), 
	WinModeWidth(DEFAULT_WIDTH), WinModeHeight(DEFAULT_HEIGHT),
	FullModeWidth(DEFAULT_WIDTH), FullModeHeight(DEFAULT_HEIGHT),
	FullMode(false), ZBuffer(zbuffer), 
	Device(NULL), Restored(false)
{
	// 커맨드 라인 옵션 해석
	for (int i=1; i<__argc; i++) {
		char* s=__argv[i];
		if (strcmp("-w", s)==0 && ++i<__argc) {
			WinModeWidth=FullModeWidth=atoi(__argv[i]);
		} else
		if (strcmp("-h", s)==0 && ++i<__argc) {
			WinModeHeight=FullModeHeight=atoi(__argv[i]);
		} else
		if (strcmp("-ww", s)==0 && ++i<__argc) {
			WinModeWidth=atoi(__argv[i]);
		} else
		if (strcmp("-wh", s)==0 && ++i<__argc) {
			WinModeHeight=atoi(__argv[i]);
		} else
		if (strcmp("-fw", s)==0 && ++i<__argc) {
			FullModeWidth=atoi(__argv[i]);
		} else
		if (strcmp("-fh", s)==0 && ++i<__argc) {
			FullModeHeight=atoi(__argv[i]);
		} else
		if (strcmp("-f", s)==0) {
			FullMode=true;
		}
	}

	// 사이즈와 위치 조절
	RECT dr, wr, cr;
	GetWindowRect(GetDesktopWindow(), &dr);
	GetWindowRect(HWnd, &wr);
	GetClientRect(HWnd, &cr);
	FrameWidth=(wr.right-wr.left)-(cr.right-cr.left);
	FrameHeight=(wr.bottom-wr.top)-(cr.bottom-cr.top);
	int w=FrameWidth+WinModeWidth, h=FrameHeight+WinModeHeight;
	SetWindowPos(HWnd, HWND_NOTOPMOST, 
		(dr.right-dr.left-w)/2, (dr.bottom-dr.top-h)/2, 
		w, h, SWP_SHOWWINDOW);
	WindowStyle=GetWindowLong(HWnd, GWL_STYLE);

	// Direct3D 인스턴스 생성
	if (!(D3D=Direct3DCreate9(D3D_SDK_VERSION))) return;

	// 디바이스 생성
	if (!RestoreDevice()) return;
}
Esempio n. 5
0
//==============================================================
// 화면의 갱신
void CGraphics::Present() {

	// 디바이스가 소실되었다면 다시 생성함
	switch (Device->TestCooperativeLevel()) {
		case D3DERR_DEVICELOST: 
			return;
		case D3DERR_DEVICENOTRESET:
			if (!RestoreDevice()) return;
			break;
	}

	// 화면을 갱신하기
	Device->Present(0, 0, 0, 0);
}
Esempio n. 6
0
void CMysInput2::GetKeyState(byte pKeyState[])
{
	//初期化されていなかったら初期化する
	if(m_pDIKeyboard==NULL)	RestoreDevice();

	HRESULT hr=0;
	//キーボード状態取得
	hr = m_pDIKeyboard->GetDeviceState(256,pKeyState);
	if(hr==DI_OK)
	{
	}
	else if(hr==DIERR_INPUTLOST || hr==DIERR_NOTACQUIRED)
	{
		//入力デバイスのアクセス権を失っているので再取得したのちリトライ
		m_pDIKeyboard->Acquire();
		m_pDIKeyboard->GetDeviceState(256,pKeyState);
	}
	else
	{
		//予想外のときには初期化しなおす
		RestoreDevice();
	}
}