//This is in the pre-loop initialization
CD3DFont *Font = new CD3DFont(_T("Arial"), 12);
Font->InitDeviceObjects(pDirect3D->GetDevice());
// This is in the game loop, after begin scene
Font->DrawText( 2, 0, D3DCOLOR_ARGB(255,255,255,0),_T("Nick"));
// And finally, this is the post-loop (clean-up) phase
Font->InvalidateDeviceObjects();
Font->DeleteDeviceObjects();
delete Font;
🔒 Locked
CD3DFont
Advertisement
Original Post
CD3DFont is crashing my program. I''ve tried using the debugger and using the debug libs of DirectX, but all it tells me is that the kernal threw an exception. I''ve also looked through the sample to check what I''ve been doing differently, and I'' really not sure what it is. If someone could look threw this little piece of code I''d be eternally grateful
After you call InitDeviceObjects you have to call RestoreDeviceObjects. I know it seems a bit odd, but you do.
Stay Casual,
Ken
Drunke
Alright, now the text works, but I can''t seem to get my textured quad showing up on the screen now...
This is my main loop:
I''m not sure exactly what I have to do in order to get everything to draw properly now. The text shows up, but the quad doesnt.
This is my main loop:
while (TRUE)
{
pDirect3D->Clear();
pDirectInput->Read_Keyboard();
if (PeekMessage(&Msg, hWnd, 0, 0, PM_REMOVE))
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
if (KEYDOWN(KEY_ESCAPE))
break;
if (KEYDOWN(KEY_UP))
{
D3DXMatrixTranslation(&Position, 0.0f, test, 0.0f);
pDirect3D->GetDevice()->MultiplyTransform(D3DTS_WORLD, &Position);
}
if (KEYDOWN(KEY_LEFT))
{
pDirect3D->GetDevice()->MultiplyTransform(D3DTS_WORLD, &matRotate1);
}
if (KEYDOWN(KEY_RIGHT))
{
pDirect3D->GetDevice()->MultiplyTransform(D3DTS_WORLD, &matRotate2);
}
pDirect3D->GetDevice()->BeginScene();
Font->DrawText( 2, 0, D3DCOLOR_ARGB(255,255,255,0),_T("Nick"));
pDirect3D->GetDevice()->SetVertexShader(CUSTOM_VERTEX_FVF);
pDirect3D->GetDevice()->SetStreamSource(VERTEX_AMOUNT - 1, pVb->GetVb(), sizeof(CUSTOM_VERTEX_FVF));
pDirect3D->GetDevice()->SetTexture(0, pTexture);
pDirect3D->GetDevice()->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);
pDirect3D->GetDevice()->EndScene();
pDirect3D->GetDevice()->SetTexture(0, NULL);
pDirect3D->PresentScene();
}
I''m not sure exactly what I have to do in order to get everything to draw properly now. The text shows up, but the quad doesnt.
Are you running the Debug Runtime? Very likely the answer will be in the debug spew.
I''m not sure what this is:
SetStreamSource(VERTEX_AMOUNT - 1
What''s VERTEX_AMOUNT defined as?
Stay Casual,
Ken
Drunke
Try these things:
- Turn lighting off
- Turn Culling off
- Clear your backbuffer to a radically different colour
Does anything show up?
Stay Casual,
Ken
Drunken Hyena
- Turn lighting off
- Turn Culling off
- Clear your backbuffer to a radically different colour
Does anything show up?
Stay Casual,
Ken
Drunke
No, I tried what you said, but nothing is showing up..
I went into the d3dfont.cpp, and I notice that they restore all the render-states the way they used to be before the DrawText(...) call by using CaptureStateBlock and then re-applying them at the end of the DrawText function using ApplyStateBlock. This would mean that I would not have to touch any render states after the fuction, because they would be exactly like they were before, right? Also, what do people normally do after calling DrawText?
[edited by - laroche on August 6, 2002 10:28:25 AM]
I went into the d3dfont.cpp, and I notice that they restore all the render-states the way they used to be before the DrawText(...) call by using CaptureStateBlock and then re-applying them at the end of the DrawText function using ApplyStateBlock. This would mean that I would not have to touch any render states after the fuction, because they would be exactly like they were before, right? Also, what do people normally do after calling DrawText?
[edited by - laroche on August 6, 2002 10:28:25 AM]
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement