Jump to content
  • Advertisement
Sign in to follow this  
davidprogrammer

Core files giving me errors

This topic is 5120 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've searched the forums several times with different results. All of which didn't help. I bought the book Programming Role Playing Games with DirectX 2nd Edition and I was flipping through the book code. The first few chapters work fine. They compile and link fine. When I get into the later chapters( ch13+ for example) I start using the core files (i.e. core_graphics.cpp and .h) I get errors such as: core_graphics.cpp(368) : error C2660: 'Begin' : function does not take 0 parameters core_graphics.cpp(989) : error C2664: 'D3DXCreateFontIndirectA' : cannot convert parameter 2 from 'struct tagLOGFONTA *' to 'const struct _D3DXFONT_DESCA core_graphics.cpp(1004) : error C2039: 'Begin' : is not a member of 'ID3DXFont' core_graphics.cpp(1013) : error C2039: 'End' : is not a member of 'ID3DXFont' core_graphics.cpp(1034) : error C2660: 'DrawTextA' : function does not take 5 parameters core_graphics.cpp(2391) : error C2660: 'Draw' : function does not take 7 parameters chap14\battle\window.cpp(75) : error C2660: 'DrawTextA' : function does not take 5 parameters They vary from project to project. Is there anything I can do? I have tried uninstalling and re-installing DirectX and Visual Studio 6.0. I re-copied the book code to the computer too. To no effect. [Edited by - davidprogrammer on October 14, 2004 3:46:43 AM]

Share this post


Link to post
Share on other sites
Advertisement
Just a wild guess, but a lot of DX interfaces are accessed through pointers.

Make sure you're using -> and not . when using a pointer to an interface. However, I can't tell if this is your problem unless you post some code. Be sure to include your code between [ source ] and [ / source ] tags without the spaces before and after.

Share this post


Link to post
Share on other sites
Sure, I'll post some code. And I'm using the DirectX version that came with the book -_-.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
BookCode\GameCore\Core_Graphics.cpp(368) : error C2660: 'Begin' : function does not take 0 parameters
<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
BOOL cGraphics::BeginSprite()
{
if(m_pSprite == NULL)
return FALSE;

if(FAILED(m_pSprite->Begin()))
return FALSE;

return TRUE;
}


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
BookCode\GameCore\Core_Graphics.cpp(989) : error C2664: 'D3DXCreateFontIndirectA' : cannot convert parameter 2 from 'struct tagLOGFONTA *' to 'const struct _D3DXFONT_DESCA
<><><><><><<><><<><><><><><><><><><><><><><><><><><><><><><><><>
BOOL cFont::Create(cGraphics *Graphics, char *Name, long Size, BOOL Bold, BOOL Italic, BOOL Underline, BOOL Strikeout)
{
LOGFONT lf;

if(Graphics == NULL || Name == NULL)
return FALSE;
if(Graphics->GetDeviceCOM() == NULL)
return FALSE;

// Clear out the font structure
ZeroMemory(&lf, sizeof(LOGFONT));

// Set the font name and height
strcpy(lf.lfFaceName, Name);
lf.lfHeight = -Size;
lf.lfWeight = (Bold == TRUE) ? 700 : 0;
lf.lfItalic = Italic;
lf.lfUnderline = Underline;
lf.lfStrikeOut = Strikeout;

// Create the font object
if(FAILED(D3DXCreateFontIndirect(Graphics->GetDeviceCOM(), &lf, &m_Font)))
return FALSE;
return TRUE;
}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
BookCode\GameCore\Core_Graphics.cpp(1004) : error C2039: 'Begin' : is not a member of 'ID3DXFont'
<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
BOOL cFont::Begin()
{
if(m_Font == NULL)
return FALSE;
if(FAILED(m_Font->Begin()))
return FALSE;
return TRUE;
}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
BookCode\GameCore\Core_Graphics.cpp(1013) : error C2039: 'End' : is not a member of 'ID3DXFont'
<><><><><><<><><<><><><><><><><><><><><><><><><><><><><><><><><>
BOOL cFont::End()
{
if(m_Font == NULL)
return FALSE;
if(FAILED(m_Font->End()))
return FALSE;
return TRUE;
}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
BookCode\GameCore\Core_Graphics.cpp(1034) : error C2660: 'DrawTextA' : function does not take 5 parameters
<><><><><><<><><<><><><><><><><><><><><><><><><><><><><><><><><>
BOOL cFont::Print(char *Text, long XPos, long YPos, long Width, long Height, D3DCOLOR Color, DWORD Format)
{
RECT Rect;

if(m_Font == NULL)
return FALSE;

if(!Width)
Width = 65535;
if(!Height)
Height = 65536;

Rect.left = XPos;
Rect.top = YPos;
Rect.right = Rect.left + Width;
Rect.bottom = Rect.top + Height;
if(FAILED(m_Font->DrawText(Text, -1, &Rect, Format, Color)))
return FALSE;
return TRUE;
}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
BookCode\GameCore\Core_Graphics.cpp(2391) : error C2660: 'Draw' : function does not take 7 parameters
<><><><><><<><><<><><><><><><><><><><><><><><><><><><><><><><><>
BOOL cTexture::Blit(long DestX, long DestY,                                       long SrcX, long SrcY,                                         long Width, long Height,                                      float XScale, float YScale,                                   D3DCOLOR Color)
{
RECT Rect;
ID3DXSprite *pSprite;

if(m_Texture == NULL)
return FALSE;
if(m_Graphics == NULL)
return FALSE;
if((pSprite = m_Graphics->GetSpriteCOM()) == NULL)
return FALSE;

if(!Width)
Width = m_Width;
if(!Height)
Height = m_Height;

Rect.left = SrcX;
Rect.top = SrcY;
Rect.right = Rect.left + Width;
Rect.bottom = Rect.top + Height;

if(FAILED(pSprite->Draw(m_Texture, &Rect, &D3DXVECTOR2(XScale, YScale), NULL, 0.0f, &D3DXVECTOR2((float)DestX, (float)DestY), Color)))
return FALSE;
return TRUE;
}

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bookcode\chap14\battle\window.cpp(75) : error C2660: 'DrawTextA' : function does not take 5 parameters
<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
BOOL cWindow::Move(long XPos, long YPos,                                         long Width, long Height,                                      long TargetX, long TargetY,                                   D3DCOLOR BackColor)
{
sVertex Verts[11];
long i;

// Save the coordinates and calculate height if needed
m_XPos = XPos;
m_YPos = YPos;
m_Width = Width;
if(!(m_Height = Height)) {
RECT Rect;
Rect.left = XPos;
Rect.top = 0;
Rect.right = XPos + Width - 12;
Rect.bottom = 1;

m_Height = m_Font->GetFontCOM()->DrawText(m_Text, -1, &Rect, DT_CALCRECT | DT_WORDBREAK, 0xFFFFFFFF) + 12;
}

Share this post


Link to post
Share on other sites
Is this book using DX9? If so, check if you have the Summer Update 2004 SDK installed - some interfaces have changed in this release and you would have to downgrade your DXSDK in that case.

Share this post


Link to post
Share on other sites
Quote:
Original post by davidprogrammer
I know the book couldn't have errors. I wonder what could be wrong...


[rofl]

Share this post


Link to post
Share on other sites
Quote:
Original post by davidprogrammer
hehehe. Seriously. I bought this book not 2 weeks ago. By the way Win32 experience is a must. :P

That doesn't matter - there could be errors anyway. Have you checked the book's website for code updates? ID3DXFont::Begin is present in the D3DX 8.1 helper library and has been removed in D3DX 9. So I assume you must use the DXSDK version 8.1.

Share this post


Link to post
Share on other sites
Right. That makes sense. But Jim Adams put DirectX 9.0 on the CD~ Should I not use the version that came with the book? He has his website but it doesn't show the book I bought

http://home.att.net/~rpgbook/

-_- Should I downgrade to DirectX 8.1?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!