Direct3D 9 and RHW vertices
I'm trying to draw a triangle inside a Direct3D9 window that belongs to another program. Athough everything seems to be ok, and all of the functions return without errors, the triangle doesn't get drawn. I'm puzzled: what could be the reason it's not getting drawn?
P.S. I do the drawing by intercepting Present, and the hook is called, as is evident inside the debugger, the triangle should not be clipped since it is inside the window boundaries. Everything works fine in my test application.
I forget if hooking conflicts with PIX, but you could try stepping through the call-stream to see the intermediary frame states to get more insight...
Also, are you using MH's D3D Hooking sample? If so, compare your code to his and see what you're doing differently.
hth
Jack
Also, are you using MH's D3D Hooking sample? If so, compare your code to his and see what you're doing differently.
hth
Jack
I've just checked MH's hooking example - it doesn't work either. Will check the PIX tool now :)
Currently I'm using this code (It's not really RHW anymore, since I'm transforming the vertices, but it's the same thing, AFAIK. I'm using an orthographic projection matrix for camera and identity matrices for world and view)
pDevice->GetTransform(D3DTS_VIEW,&mOldView);
pDevice->GetTransform(D3DTS_PROJECTION,&mOldProject);
pDevice->GetTransform(D3DTS_WORLD,&mOldWorld);
pDevice->SetTransform(D3DTS_VIEW,&mView);
pDevice->SetTransform(D3DTS_PROJECTION,&mProject);
pDevice->SetTransform(D3DTS_WORLD,&mWorld);
pDevice->SetRenderState(D3DRS_ZENABLE,D3DZB_FALSE);
if (pDevice->BeginScene()==0)
{
pDevice->SetStreamSource( 0, pVB, 0, sizeof(CUSTOMVERTEX) );
pDevice->SetFVF( D3DFVF_CUSTOMVERTEX );
pDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, 1 );
}
pDevice->EndScene();
pDevice->SetRenderState(D3DRS_ZENABLE,D3DZB_TRUE);
pDevice->SetTransform(D3DTS_VIEW,&mOldView);
pDevice->SetTransform(D3DTS_PROJECTION,&mOldProject);
pDevice->SetTransform(D3DTS_WORLD,&mOldWorld);
Currently I'm using this code (It's not really RHW anymore, since I'm transforming the vertices, but it's the same thing, AFAIK. I'm using an orthographic projection matrix for camera and identity matrices for world and view)
pDevice->GetTransform(D3DTS_VIEW,&mOldView);
pDevice->GetTransform(D3DTS_PROJECTION,&mOldProject);
pDevice->GetTransform(D3DTS_WORLD,&mOldWorld);
pDevice->SetTransform(D3DTS_VIEW,&mView);
pDevice->SetTransform(D3DTS_PROJECTION,&mProject);
pDevice->SetTransform(D3DTS_WORLD,&mWorld);
pDevice->SetRenderState(D3DRS_ZENABLE,D3DZB_FALSE);
if (pDevice->BeginScene()==0)
{
pDevice->SetStreamSource( 0, pVB, 0, sizeof(CUSTOMVERTEX) );
pDevice->SetFVF( D3DFVF_CUSTOMVERTEX );
pDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, 1 );
}
pDevice->EndScene();
pDevice->SetRenderState(D3DRS_ZENABLE,D3DZB_TRUE);
pDevice->SetTransform(D3DTS_VIEW,&mOldView);
pDevice->SetTransform(D3DTS_PROJECTION,&mOldProject);
pDevice->SetTransform(D3DTS_WORLD,&mOldWorld);
What's your vertices look like? Are they clockwise or counter-clockwise? If the app has backface culling enabled (SetRenderState with D3DRS_CULLMODE and a value of D3DCULL_CCW) and your vertices are counter-clockwise, they won't be drawn.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement