现在我的游戏目前正在展示一张拉伸到表面上的图像(bmp)。 我遇到的问题是在其上绘制文字。
正确绘制文字我想要的方式但是,如果游戏没有处于窗口模式,相反,如果它处于全屏模式,文本将会闪烁,我不能为了我的身材而生活出了什么问题。
int Game::Render(){
HRESULT r;
D3DLOCKED_RECT LockedRect;//locked area of display memory(buffer really) we are drawing to
LPDIRECT3DSURFACE9 pBackSurf = 0;
if(!g_pDevice){
SetError("Cannot render because there is no device");
return E_FAIL;
}
if(g_pDevice->BeginScene()){
//clear the display arera with colour black, ignore stencil buffer
//
g_pDevice->Clear(0,0,D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,25), 1.0f, 0);
//get pointer to backbuffer
r=g_pDevice->GetBackBuffer(0,0,D3DBACKBUFFER_TYPE_MONO, &backBuffer); //&pBackSurf
g_pDevice->StretchRect(surface, NULL, backBuffer, NULL, D3DTEXF_NONE);
if(FAILED(r)){
SetError("Couldn't get backbuffer");
}
r=backBuffer->LockRect(&LockedRect, NULL, 0);
if(FAILED(r)){
SetError("Could not lock the back buffer");
}
g_font-> DrawText的(NULL,fps_string,-1,&安培; font_rect,DT_LEFT | DT_NOCLIP,0xFFAABBCC); backBuffer-> UnlockRect();
//backBuffer->Release();//release lock
g_pDevice->EndScene();
g_pDevice->Present(NULL, NULL, NULL, NULL);//swap over buffer to primary surface
}
return S_OK;
}