DrawTextの参照エラー?

フォーラム(掲示板)ルール
フォーラム(掲示板)ルールはこちら  ※コードを貼り付ける場合は [code][/code] で囲って下さい。詳しくはこちら
めび

DrawTextの参照エラー?

#1

投稿記事 by めび » 10年前

はじめまして
Directx d3d8で文字を描画したいのですが、エラーが出て困っております

D3DFont.h

コード:


//-----------------------------------------------------------------------------
// File: D3DFont.h
// Desc: Texture-based font class
// Copyright (c) 1999-2001 Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
#ifndef D3DFONT_H
#define D3DFONT_H
#include <tchar.h>


// Font creation flags
#define D3DFONT_BOLD        0x0001
#define D3DFONT_ITALIC      0x0002
#define D3DFONT_ZENABLE     0x0004

// Font rendering flags
#define D3DFONT_CENTERED    0x0001
#define D3DFONT_TWOSIDED    0x0002
#define D3DFONT_FILTERED    0x0004
#define D3DFONT_RIGHT       0x0008		// non standard
#define D3DFONT_SHADOW      0x0010		// non standard



//-----------------------------------------------------------------------------
// Name: class CD3DFont
// Desc: Texture-based font class for doing text in a 3D scene.
//-----------------------------------------------------------------------------
class CD3DFont
{
    TCHAR   m_strFontName[80];            // Font properties
    DWORD   m_dwFontHeight;
    DWORD   m_dwFontFlags;

    LPDIRECT3DDEVICE8      m_pd3dDevice; // A D3DDevice used for rendering
    LPDIRECT3DTEXTURE8     m_pTexture;   // The d3d texture for this font
    LPDIRECT3DVERTEXBUFFER8 m_pVB;        // VertexBuffer for rendering text
    DWORD   m_dwTexWidth;                 // Texture dimensions
    DWORD   m_dwTexHeight;
    FLOAT   m_fTextScale;
    FLOAT   m_fTexCoords[128-32][4];
    DWORD   m_dwSpacing;                  // Character pixel spacing per side

    // Stateblocks for setting and restoring render states
    DWORD   m_dwSavedStateBlock;
    DWORD   m_dwDrawTextStateBlock;

public:
    // 2D and 3D text drawing functions
    HRESULT DrawText( FLOAT x, FLOAT y, DWORD dwColor, 
                      TCHAR* strText, DWORD dwFlags=0L );
    
    // Function to get extent of text
    HRESULT GetTextExtent( TCHAR* strText, SIZE* pSize );

    // Initializing and destroying device-dependent objects
    HRESULT InitDeviceObjects( LPDIRECT3DDEVICE8 pd3dDevice );
    HRESULT RestoreDeviceObjects();
    HRESULT InvalidateDeviceObjects();
    HRESULT DeleteDeviceObjects();

    // Constructor / destructor
    CD3DFont( TCHAR* strFontName, DWORD dwHeight, DWORD dwFlags=0L );
    ~CD3DFont();
};
#endif
main.cpp

コード:

CD3DFont	*pFont=NULL;
void DrawText(char *text, int x, int y, DWORD color,CD3DFont *font)
{
    if (font==0)  font=pFont;
    if (!text)	  return;
    if (font==0)  return;
    font->DrawText((float)x  , (float)y  , D3DCOLOR_ARGB( 255, 0, 0, 0 ), text);
    font->DrawText((float)x  , (float)y  , D3DCOLOR_ARGB( 255, 0, 0, 0 ), text);
    font->DrawText((float)x  , (float)y  , D3DCOLOR_ARGB( 255, 0, 0, 0 ), text);
    font->DrawText((float)x  , (float)y  , D3DCOLOR_ARGB( 255, 0, 0, 0 ), text);
    font->DrawText((float)x  , (float)y  , color, text);
}


//↓文字描画命令
	pFont->DrawText(400,		10,		txtRed,	"ここの文字が表示されます",		D3DFONT_SHADOW);

開発環境 Visual Studio C++ 2010 Express
SDK DirectX 9.0 Sdk Summer 2004

文字列の表示を行いたいのですが、エラーがでます。特に命令文に赤線が引かれてエラーがでているのではなく
デバッグして実行したときに以下のエラーが出力ウインドウに表示されデバッグコンパイルビルドができません
1>main.obj : error LNK2019: 未解決の外部シンボル "public: long __thiscall CD3DFont::DrawTextA(float,float,unsigned long,char *,unsigned long)" (?DrawTextA@CD3DFont@@QAEJMMKPADK@Z) が関数 "void __cdecl DrawTextA(char *,int,int,unsigned long,class CD3DFont *)" (?DrawTextA@@YAXPADHHKPAVCD3DFont@@@Z) で参照されました。
1>C:\Users\Maru\documents\visual studio 2010\Projects\d3d8game.exe\Debug\d3d8game.exe : fatal error LNK1120: 外部参照 1 が未解決です。

私自身初心者でどうやればこのエラーがなくなるか自分なりにいろいろとネットで検索かけてみたのですが、解決にいたりそうな記事は見つからず質問させていただきました。
わかる方いらっしゃいましたら教えていただけるとたすかります。

参考までに四角形描画は成功しました。

コード:

void DrawRect(IDirect3DDevice8* pDevice, int X, int Y, int W, int H, D3DCOLOR Color)
{
D3DRECT Rect = { X, Y, X + W, Y + H }; 
pDevice->Clear(1, &Rect, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, Color, 0, 0); 
}
void DrawBox (IDirect3DDevice8* pDevice,int X, int Y, int Width, int Height)
{
DrawRect(pDevice, X, Y, Width, Height, D3DCOLOR_ARGB(255, 0, 255, 0));

DrawRect(pDevice, X, Y, Width, 1, D3DCOLOR_ARGB(255, 255, 0, 0)); 
DrawRect(pDevice, X, Y, 1, Height, D3DCOLOR_ARGB(255, 255, 0, 0)); 
DrawRect(pDevice, X + Width, Y, 1, Height, D3DCOLOR_ARGB(255, 255, 0, 0)); 
DrawRect(pDevice, X, Y + Height, Width, 1, D3DCOLOR_ARGB(255, 255, 0, 0)); 
}

//四角形描画命令
DrawBox(pDevice,0, 0 , 250, 250);
回答おまちしております。よろしくおねがいします!

“C言語何でも質問掲示板” へ戻る