Core files giving me errors

Started by
16 comments, last by davidprogrammer 19 years, 6 months ago
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]
"If you have spent hours trying to get a piece of code to work and you can't figure it out, post it on the forums. And when they make you look stupid because they reply with the solution within 5 minutes of your post. Don't give up. Grab a smoke. And join my club..."~David W.Current Project---> Morrowind: The Ultimate GuideMSN HANDLE: davidtwillingham@comcast.netAIM HANDLE: davidprogramerICQ HANDLE: 305-391-399XANGA PROFILE: http://www.xanga.com/home.aspx?user=LostInForeverWebSite updated! Check it out!http://home.comcast.net/~davidtwillingham
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.
- A momentary maniac with casual delusions.
Either that, or you have a different DirectX SDK version installed than is required by the book.
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;  }
"If you have spent hours trying to get a piece of code to work and you can't figure it out, post it on the forums. And when they make you look stupid because they reply with the solution within 5 minutes of your post. Don't give up. Grab a smoke. And join my club..."~David W.Current Project---> Morrowind: The Ultimate GuideMSN HANDLE: davidtwillingham@comcast.netAIM HANDLE: davidprogramerICQ HANDLE: 305-391-399XANGA PROFILE: http://www.xanga.com/home.aspx?user=LostInForeverWebSite updated! Check it out!http://home.comcast.net/~davidtwillingham
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.
Nah, it is the Summer '03 update. (The same one that came with the book) and I know the book couldn't have errors. I wonder what could be wrong...
"If you have spent hours trying to get a piece of code to work and you can't figure it out, post it on the forums. And when they make you look stupid because they reply with the solution within 5 minutes of your post. Don't give up. Grab a smoke. And join my club..."~David W.Current Project---> Morrowind: The Ultimate GuideMSN HANDLE: davidtwillingham@comcast.netAIM HANDLE: davidprogramerICQ HANDLE: 305-391-399XANGA PROFILE: http://www.xanga.com/home.aspx?user=LostInForeverWebSite updated! Check it out!http://home.comcast.net/~davidtwillingham
Quote:Original post by davidprogrammer
I know the book couldn't have errors. I wonder what could be wrong...


[rofl]
hehehe. Seriously. I bought this book not 2 weeks ago. By the way Win32 experience is a must. :P
"If you have spent hours trying to get a piece of code to work and you can't figure it out, post it on the forums. And when they make you look stupid because they reply with the solution within 5 minutes of your post. Don't give up. Grab a smoke. And join my club..."~David W.Current Project---> Morrowind: The Ultimate GuideMSN HANDLE: davidtwillingham@comcast.netAIM HANDLE: davidprogramerICQ HANDLE: 305-391-399XANGA PROFILE: http://www.xanga.com/home.aspx?user=LostInForeverWebSite updated! Check it out!http://home.comcast.net/~davidtwillingham
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.
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?
"If you have spent hours trying to get a piece of code to work and you can't figure it out, post it on the forums. And when they make you look stupid because they reply with the solution within 5 minutes of your post. Don't give up. Grab a smoke. And join my club..."~David W.Current Project---> Morrowind: The Ultimate GuideMSN HANDLE: davidtwillingham@comcast.netAIM HANDLE: davidprogramerICQ HANDLE: 305-391-399XANGA PROFILE: http://www.xanga.com/home.aspx?user=LostInForeverWebSite updated! Check it out!http://home.comcast.net/~davidtwillingham

This topic is closed to new replies.

Advertisement