Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > Avalon

Vista Tutorial - WPF and D3DImage and D3D surface has annoying Flicker?

 
 
Old 01-26-2009   #1 (permalink)
BartMan
Guest


 
 

WPF and D3DImage and D3D surface has annoying Flicker?

Greetings,

I am doing a project where I am copying a texture onto a D3D surface, and I
am using D3DImage to use it in a WPF panel.

Unfortunately I am getting a very noticable flicker when the image is being
drawn?
I am not sure how to make this go away?

I modeled it from the sample code found on MS web site:
CRendererManager,CRenderer, and CTriangleRenderer.

I modified the CTriangleRenderer to be a plane object, and I applied a
texture to it.
Now that the texture is being applied it flickers? I am not sure how to fix
this? Any suggestions?

// Render code.
HRESULT hr = S_OK;

IFC(m_pd3dDevice->BeginScene());
m_pd3dDevice->Clear( 0L, NULL, D3DCLEAR_TARGET,
D3DCOLOR_XRGB(255,255,255), 1.0f, 0L );

// Set up the rotation
UINT iTime = GetTickCount() % 1000;
FLOAT fAngle = iTime * (2.0f * D3DX_PI) / 1000.0f;
//D3DXMatrixRotationY(&matWorld, fAngle);
D3DXMatrixRotationY(&matWorld, 0);
IFC(m_pd3dDevice->SetTransform(D3DTS_WORLD, &matWorld));

// Make sure that we can see the texture.
// (NOTE If this isn't here, the texture will appear black.
m_pd3dDevice->SetRenderState( D3DRS_LIGHTING, FALSE);
m_pd3dDevice->SetRenderState( D3DRS_CLIPPING, FALSE);

if(m_pTexture)
{
IFC( m_pd3dDevice->SetTexture( 0, m_pTexture));
D3DTSS_COLORARG1, D3DTA_TEXTURE));
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_DISABLE );

}


IFC(m_pd3dDevice->SetStreamSource(0, m_pd3dVB, 0, sizeof(CUSTOMVERTEX)));
IFC(m_pd3dDevice->SetFVF(D3DFVF_CUSTOMVERTEX));

IFC(m_pd3dDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2));

if(m_pTexture)
IFC( m_pd3dDevice->SetTexture( 0, NULL));

IFC(m_pd3dDevice->EndScene());


// WPF Render code.
void CompositionTarget_Rendering(object sender, EventArgs e)
{
try
{

RenderingEventArgs args = (RenderingEventArgs)e;
if (d3dImage.IsFrontBufferAvailable)
{
IntPtr pSurface = myWrapperD3DClass.RenderScene();

if (pSurface != IntPtr.Zero)
{
d3dImage.Lock();
// Repeatedly calling SetBackBuffer with the same IntPtr is
// a no-op. There is no performance penalty.
d3dImage.SetBackBuffer(D3DResourceType.IDirect3DSurface9, pSurface);
d3dImage.AddDirtyRect(new Int32Rect(0, 0, d3dImage.PixelWidth,
d3dImage.PixelHeight));
d3dImage.Unlock();

}

}

Thanks for any suggestions?

My System SpecsSystem Spec
 

Thread Tools


Similar Threads
Thread Forum
Annoying cursor flicker with WMP Vista General
Annoying "Flicker" Problem Vista General
Annoying "Flicker" Problem written 4/10/08 by Island Momma Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46