0

Right now my game is currently just showing an image (bmp) stretched onto a surface. The problem I'm having is drawing text onto it.

The text is drawn correctly how I want it however, if the game is not in windowed mode, rather, if it's in fullscreen mode, the text will flicker on and off, and I can't for the life of my figure out what's wrong.

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;

}

Barnes Noble
  • 305
  • 2
  • 4
  • 8

0 Answers0