troubleshooting Question

Image Flickers using directx9

Avatar of nchannon
nchannonFlag for Ireland asked on
Game ProgrammingC++
14 Comments1 Solution1382 ViewsLast Modified:
Hi I cant seem to see why my image keeps flickering when I use Clear(..) before BeginScene(...)
I am loading two surfaces like this LPDIRECT3DSURFACE9      p_pSurface[2];
one is for YUY2 data and the other is for a bmp file and they are draw onto the same back buffer.
I create my offscreen surface like this
D3DXGetImageInfoFromFile( L"img\\NoSignal.bmp",&Info);
hr = p_pd3dDevice->CreateOffscreenPlainSurface(Info.Width,Info.Height, D3DFMT_X8R8G8B8,D3DPOOL_DEFAULT , &p_pSurface[0], NULL);
      hr = p_pd3dDevice->CreateOffscreenPlainSurface(704,576,D3DFMT_YUY2,D3DPOOL_DEFAULT, &p_pSurface[1], NULL);
      D3DXLoadSurfaceFromFile(p_pSurface[0], NULL, NULL,L"img\\NoSignal.bmp", NULL, D3DX_DEFAULT,0, NULL);

This on only loaded the once.
now my problem begins with
//p_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET , D3DCOLOR_XRGB(255,255,255), 1.0f, 0 );
      p_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(255,255,255), 1.0f, 0 );      
      p_pd3dDevice->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO,&p_pBackBuffer);
      p_pd3dDevice->BeginScene();

if I dont have D3DCLEAR_ZBUFFER  then my images from p_pSurface[1] flicker when they are rendered but p_pSurface[0] seems fine
D3DXLoadSurfaceFromMemory(p_pSurface[1], NULL,NULL,pYUV422[oytoData->chid] ,D3DFMT_YUY2,oytoData->width*2, NULL, srcrc, D3DX_FILTER_NONE, 0 );
p_pd3dDevice->StretchRect(p_pSurface[1], srcrc,p_pBackBuffer, dstrc, D3DTEXF_NONE);
p_pd3dDevice->StretchRect(p_pSurface[0], img_src_rc,p_pBackBuffer, dst,  D3DTEXF_NONE);
p_pBackBuffer->Release();
 p_pd3dDevice->EndScene();
p_pd3dDevice->Present( NULL, NULL, NULL, NULL );


Also my CPU is working at about 18% on a quad core I though that when I sent my pool to D3DPOOL_DEFAULT the GPU dose all the work or am i missing something
Thanks
 
      
ASKER CERTIFIED SOLUTION
Member_2_5069294

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 14 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 14 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros