Skip to main content
gamedev.net
🔒 Locked

CD3DFont

Started by Laroche 9 replies 300+ views
Original Post
Laroche
Laroche
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
  
//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;
  
Check out my music at: http://zed.cbc.ca/go.ZeD?user_id=41947&user=Laroche&page=content
Wreakon
Wreakon
On which line does the exception actually occur?

-------
"Programming is like sex make one mistake, and you have to support it forever."
Homepage: http://students.washington.edu/andrey
-------Homepage: http://www.pclx.com
Wreakon
Wreakon
On which line does the exception actually occur?

-------
"Programming is like sex make one mistake, and you have to support it forever."
Homepage: http://students.washington.edu/andrey
-------Homepage: http://www.pclx.com
Laroche
Laroche
the DrawText one. If I comment that out, then everything works fine.
Check out my music at: http://zed.cbc.ca/go.ZeD?user_id=41947&user=Laroche&page=content
Laroche
Laroche
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:

  
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.
Check out my music at: http://zed.cbc.ca/go.ZeD?user_id=41947&user=Laroche&page=content
DrunkenHyena
DrunkenHyena

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
Drunken Hyena
Stay Casual,KenDrunken Hyena</FON
Laroche
Laroche
VERTEX_AMOUNT is 4 (the amount of vertices in the vb, the only quad), and I believe that is an error, and I set it to 0. However, my object STILL doesn''t show up. I tried debugging using the DX runtimes, but no errors! What else could it be?
Check out my music at: http://zed.cbc.ca/go.ZeD?user_id=41947&user=Laroche&page=content
Laroche
Laroche
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]
Check out my music at: http://zed.cbc.ca/go.ZeD?user_id=41947&user=Laroche&page=content
Laroche
Laroche
*bump*
Check out my music at: http://zed.cbc.ca/go.ZeD?user_id=41947&user=Laroche&page=content

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.