Recommended Posts

Hi all. Im trying to write my first game using DirectX 8.1
The following code worked just fine for the last couple months, but yesterday, it suddenly stopped working on my desktop system while it still works on my laptop. My desktop has DirectX 9.0b, ATI 9700 Pro with 3.9 drivers. Laptop has Radeon mobility.
The DMan object you see in the code is just an encapusation class for common DIrectX functions.
The problem is that I am able to render a polygon using a vertex buffer, but if I try to render say, a D3DXSprite or D3DXFont, the polygon will disappear after one frame is rendered. It is not throwing any errors at me, it is just now showing up. Also, if I simply add a Begin()/End() block from the Sprite class, the same thing happens. I dont even need to call Draw() to cause the problem.
Any help will be...uh...helpful. Thanks
//play with vertex buffers
CUSTOMVERTEX g_Vertices[] =
{
{ v1.x, v1.y, 0.5f, 1.0f, 0xffff0000, }, // x, y, z, rhw, color
{ v2.x, v2.y, 0.5f, 1.0f, 0xff00ff00, },
{ v3.x, v3.y, 0.5f, 1.0f, 0xff0000ff, },
};
IDirect3DVertexBuffer8* g_pVB;
if( FAILED( DMan.GetDevice()->CreateVertexBuffer( 3*sizeof(CUSTOMVERTEX),
0 /* Usage */, D3DFVF_CUSTOMVERTEX,
D3DPOOL_DEFAULT, &g_pVB ) ) )
return;
VOID* pVertices;
if( FAILED( g_pVB->Lock( 0, sizeof(g_Vertices), (BYTE**)&pVertices, 0 ) ) )
return;
memcpy( pVertices, g_Vertices, sizeof(g_Vertices) );
g_pVB->Unlock();
//Start animation
DMan.Begin();
DMan.GetDevice()->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_RGBA(255,255,255,255), 0, 0);
//Play with vertex buffers
DMan.GetDevice()->SetStreamSource( 0, g_pVB, sizeof(CUSTOMVERTEX) );
DMan.GetDevice()->SetVertexShader( D3DFVF_CUSTOMVERTEX );
DMan.GetDevice()->DrawPrimitive( D3DPT_TRIANGLELIST, 0, 1 );
/*
***PROBLEM***
If I try to use ID3DXSprite::Draw()
or ID3DXFont::DrawText()
the sprite or font will display but
the above trianglelist will display for one
frame and then disappear.
In fact, If I even call a Begin/End block from either of
those classes, without actually drawing anything the
same problem occurs.
*/
DMan.End();
DMan.GetDevice()->Present(NULL,NULL,NULL,NULL);

0

Share this post

Link to post

Share on other sites

Nevermind everyone...I somehow fixed it by changing the ''BehaviorFlags'' parameter in CreateDevice() from D3DCREATE_HARDWARE_VERTEXPROCESSING TO D3DCREATE_MIXED_VERTEXPROCESSING. I dont understand what changing that worked, so if anyone has any ideas...Im all ears.