Skip to main content
GameDev.net gamedev.net
🔒 Locked

CD3DFont Error.

Started by DivineLight Jan 18, 2004 at 8:22 PM 6 replies 2k views
Original Post
DivineLight
DivineLight
Hi! i don''t know why i get a linker error while using CD3Dfont?? this is the error: SimpleFont.obj : error LNK2001: unresolved external symbol "public: __thiscall CD3DFont::CD3DFont(char const *,unsigned long,unsigned long)" (??0CD3DFont@@QAE@PBDKK@Z) any one knows what libs to link, or what headers to include? i include the following: #include <d3dfont.h> #pragma comment(lib,"d3d9.lib") #pragma comment(lib,"dxerr9.lib") #pragma comment(lib,"dxguid.lib") #pragma comment(lib,"dinput8.lib") #pragma comment(lib,"d3dxof.lib") #pragma comment(lib,"d3dx9dt.lib") #ifdef _DEBUG #pragma comment(lib,"d3dx9d.lib") #else #pragma comment(lib,"d3dx9.lib") #endif
Syntax is same, Thinking is Different<<<
DrunkenHyena
DrunkenHyena
CD3DFont is not in a library, it''s included in the SDK as plain source. There''s a "Common" directory in the SDK and I believe the file you''re looking for is called d3dfont.cpp.

BTW, you don''t need to link to d3dx9dt.lib since you later link to d3dx9d.lib or d3dx9d.lib. It''s redundant.


Stay Casual,

Ken
Drunken Hyena
Stay Casual,KenDrunken Hyena</FON
DrunkenHyena
DrunkenHyena
What''s improper about that? It''s source, so you include it in your project. If you wanted to you could compile it into a link library, and then add it to your project.

Though technically there is no reason to move the file, you can include it in your project from where it is in the SDK directory.

The other alternative is to use D3DXFont which is part of D3DX and is pretty spiffy.


Stay Casual,

Ken
Drunken Hyena
Stay Casual,KenDrunken Hyena</FON
DorRaba
DorRaba
Why do I have linker errors?
this is my code

#include <Windows.h>
#include <mmsystem.h>
#include <d3dx9.h>


INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR, INT );
LRESULT WINAPI MsgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam );

LPDIRECT3D9 g_pD3D = NULL;
LPDIRECT3DDEVICE9 g_pd3dDevice = NULL;
D3DPRESENT_PARAMETERS d3dpp;


#include <D3DFont.h>
CD3DFont* m_pFont; // Font for drawing text

void InitD3D( HWND hWnd )
{
g_pD3D=Direct3DCreate9(D3D_SDK_VERSION);
d3dpp.Windowed=TRUE;
d3dpp.EnableAutoDepthStencil=TRUE;
d3dpp.SwapEffect=D3DSWAPEFFECT_DISCARD;
d3dpp.AutoDepthStencilFormat=D3DFMT_D16;
g_pD3D->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,hWnd,D3DCREATE_SOFTWARE_VERTEXPROCESSING,&d3dpp,&g_pd3dDevice);

m_pFont = new CD3DFont( _T("Arial"), 12, D3DFONT_BOLD );
m_pFont->InitDeviceObjects( g_pd3dDevice );

m_pFont->RestoreDeviceObjects();

}

void Render()
{
g_pd3dDevice->Clear(0,NULL,D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER,D3DCOLOR_XRGB(0,0,255),1.0f,0);
g_pd3dDevice->BeginScene();

m_pFont->DrawText( 2, 60, D3DCOLOR_ARGB(255,255,255,255),
TEXT("Use arrow keys to change mesh density") );

g_pd3dDevice->EndScene();
g_pd3dDevice->Present(NULL,NULL,NULL,NULL);

}

LRESULT WINAPI MsgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
switch( msg )
{
case WM_DESTROY:
if( g_pd3dDevice != NULL )
g_pd3dDevice->Release();

if( g_pD3D != NULL )
g_pD3D->Release();
m_pFont->DeleteDeviceObjects();

PostQuitMessage( 0 );
return 0;
}

return DefWindowProc( hWnd, msg, wParam, lParam );
}



INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR, INT )
{
WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, MsgProc, 0L, 0L,
GetModuleHandle(NULL), NULL, NULL, NULL, NULL,
"THE REAL", NULL };
RegisterClassEx( &wc );

HWND hWnd = CreateWindow( "THE REAL", "THE REAL THING BABY!!!",
WS_OVERLAPPEDWINDOW, 100, 100, 256, 256,
GetDesktopWindow(), NULL, wc.hInstance, NULL );

ShowWindow( hWnd, SW_SHOWDEFAULT );
UpdateWindow( hWnd );

InitD3D( hWnd );
//InitGeometry();

MSG msg;
ZeroMemory( &msg, sizeof(msg) );
while( msg.message!=WM_QUIT )
{
if( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}
else
Render();
}



UnregisterClass( "THE REAL", wc.hInstance );
return 0;
}


I have linker errors like this:
NewD3DProj error LNK2001: unresolved external symbol "public: long __thiscall CD3DFont::RestoreDeviceObjects(void)" (?RestoreDeviceObjects@CD3DFont@@$$FQAEJXZ)


What am I doing wrong are there function that I can''t use, If not how do I fix it?
DDDDor RRRRaba
DorRaba
DorRaba
Forget what I wrote, This is my problem.
Before I tried to show the FPSTime variable, I succeded to show text on the screen and now I can''t view the FPSTime variable.

what is wrong here that doesn''t let me execute?

//m_pFont in a CD3DFont object

DWORD FPSTime = GetTickCount();
char dor[100];

sprintf(dor,"%s",FPSTime);
m_pFont->DrawText( 2, 60, D3DCOLOR_ARGB(255,255,255,255),dor);


I''m sure the problem is in the 2 last lines I wrote, what is wrong in there?
DDDDor RRRRaba
DrunkenHyena
DrunkenHyena
quote:
Original post by DorRaba
sprintf(dor,"%s",FPSTime);



You''re using %s which expects a string, however you''re passing a DWORD so it''s interpreting it as a pointer to a string. I''m surprised it didn''t print out random garbage. %d should work much better.



Stay Casual,

Ken
Drunken Hyena
Stay Casual,KenDrunken Hyena</FON
DivineLight
DivineLight
HA! THANKS God it''s working now because i copied d3dfont.cpp & header into my project dir then added these files to my project and it works now. Thanks DH. the credit goes to you
Syntax is same, Thinking is Different<<<

Topic Locked

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

Sign in to reply to this topic.