本文整理汇总了C++中CDrawPort::Unlock方法的典型用法代码示例。如果您正苦于以下问题:C++ CDrawPort::Unlock方法的具体用法?C++ CDrawPort::Unlock怎么用?C++ CDrawPort::Unlock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CDrawPort
的用法示例。
在下文中一共展示了CDrawPort::Unlock方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Credits_Render
// render credits to given drawport
FLOAT Credits_Render(CDrawPort *pdp)
{
if (!_bCreditsOn) {
return 0;
}
CDrawPort dpWide;
pdp->MakeWideScreen(&dpWide);
pdp->Unlock();
dpWide.Lock();
FLOAT fTime = GetTime();
pixW = dpWide.GetWidth();
pixH = dpWide.GetHeight();
fResolutionScaling = (FLOAT)pixW / 640.0f;
dpWide.SetFont( _pfdDisplayFont);
pixLineHeight = floor(20*fResolutionScaling);
const FLOAT fLinesPerSecond = _fSpeed;
FLOAT fOffset = fTime*fLinesPerSecond;
INDEX ctLinesOnScreen = pixH/pixLineHeight;
INDEX iLine1 = fOffset;
pixJ = iLine1*pixLineHeight-fOffset*pixLineHeight;
iLine1-=ctLinesOnScreen;
INDEX ctLines = _astrCredits.Count();
BOOL bOver = TRUE;
for (INDEX i = iLine1; i<iLine1+ctLinesOnScreen+1; i++) {
CTString *pstr = &strEmpty;
INDEX iLine = i;
if (iLine>=0 && iLine<ctLines) {
pstr = &_astrCredits[iLine];
bOver = FALSE;
}
PrintOneLine(&dpWide, *pstr);
}
dpWide.Unlock();
pdp->Lock();
if (bOver) {
return 0;
} else if (ctLines-iLine1<ctLinesOnScreen) {
return FLOAT(ctLines-iLine1)/ctLinesOnScreen;
} else {
return 1;
}
}
示例2: TestGame
//.........这里部分代码省略.........
}
} // register the window class
hInstanceFullScreen = AfxGetInstanceHandle();
ASSERT( hInstanceFullScreen!=NULL);
wcFullScreen.cbSize = sizeof(wcFullScreen);
wcFullScreen.style = CS_HREDRAW | CS_VREDRAW;
wcFullScreen.lpfnWndProc = ::DefWindowProc;
wcFullScreen.cbClsExtra = 0;
wcFullScreen.cbWndExtra = 0;
wcFullScreen.hInstance = hInstanceFullScreen;
wcFullScreen.hIcon = LoadIcon( hInstanceFullScreen, (LPCTSTR)IDR_MAINFRAME );
wcFullScreen.hCursor = NULL;
wcFullScreen.hbrBackground = NULL;
wcFullScreen.lpszMenuName = CString(APPLICATION_NAME);
wcFullScreen.lpszClassName = CString(APPLICATION_NAME);
wcFullScreen.hIconSm = NULL;
RegisterClassEx(&wcFullScreen);
// create a window, invisible initially
hWndFullScreen = CreateWindowExA(
WS_EX_TOPMOST,
APPLICATION_NAME,
"Serious Editor - Full Screen Test Game", // title
WS_POPUP,
0,0,
pixSizeI, pixSizeJ, // window size
NULL,
NULL,
hInstanceFullScreen,
NULL);
// didn't make it?
ASSERT( hWndFullScreen!=NULL);
if( hWndFullScreen==NULL) {
if( gat==GAT_OGL) _pGfx->ResetDisplayMode( (enum GfxAPIType)theApp.m_iApi);
WarningMessage( "Unable to setup window for full screen display.");
return;
}
// set windows for engine
CMainFrame* pMainFrame = STATIC_DOWNCAST(CMainFrame, AfxGetMainWnd());
SE_UpdateWindowHandle( hWndFullScreen);
// set window title and show it
sprintf( achWindowTitle, "Serious Editor - Test Game (FullScreen %dx%d)", pixSizeI, pixSizeJ);
::SetWindowTextA( hWndFullScreen, achWindowTitle);
::ShowWindow( hWndFullScreen, SW_SHOWNORMAL);
// set Direct3D full screen (after window)
#ifdef SE1_D3D
if( gat==GAT_D3D) {
const BOOL bRes = _pGfx->SetDisplayMode( gat, 0, pixSizeI, pixSizeJ, dd);
if( !bRes) {
WarningMessage( "Unable to setup full screen display.");
::DestroyWindow( hWndFullScreen);
SE_UpdateWindowHandle( pMainFrame->m_hWnd);
return;
}
}
#endif // SE1_D3D
// create canvas
_pGfx->CreateWindowCanvas( hWndFullScreen, &pvp, &pdp);
// initial screen fill and swap, just to get context running
BOOL bSuccess = FALSE;
if( pdp!=NULL && pdp->Lock()) {
pdp->Fill(C_dGREEN|CT_OPAQUE);
pdp->Unlock();
pvp->SwapBuffers();
bSuccess = TRUE;
}
// must succeed!
ASSERT( bSuccess);
if( !bSuccess) {
_pGfx->ResetDisplayMode( (enum GfxAPIType)theApp.m_iApi);
WarningMessage( "Unable to setup canvas for full screen display.");
return;
}
}
// enable sound
snd_iFormat = Clamp( snd_iFormat, (INDEX)CSoundLibrary::SF_NONE, (INDEX)CSoundLibrary::SF_44100_16);
_pSound->SetFormat( (enum CSoundLibrary::SoundFormat)snd_iFormat, TRUE);
// run quick test game
extern BOOL _bInOnDraw;
_bInOnDraw = TRUE;
_pGameGUI->QuickTest( fnmWorldToPlay, pdp, pvp);
_bInOnDraw = FALSE;
// disable sound
_pSound->SetFormat( CSoundLibrary::SF_NONE);
// restore default display mode and close test full screen window
if( hWndFullScreen!=NULL) {
_pGfx->ResetDisplayMode( (enum GfxAPIType)theApp.m_iApi);
::DestroyWindow( hWndFullScreen);
SE_UpdateWindowHandle( pMainFrame->m_hWnd);
}
// redraw all views
pDoc->UpdateAllViews( NULL);
pPerspectiveView->EnableToolTips( TRUE);
}