Sign in to follow this  

Core files giving me errors

This topic is 4810 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
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;

[b]if(FAILED(m_pSprite->Begin()))[/b]
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
[b] if(FAILED(D3DXCreateFontIndirect(Graphics->GetDeviceCOM(), [/b]&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;
[b] if(FAILED(m_Font->Begin()))[/b]
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), [b] Color)))[/b]
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, [b] 0xFFFFFFFF) + 12;[/b]
}

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
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
Guest Anonymous Poster
hmm.... I am going to try one more time installing DirectX 9.0 summer 03 update (comes with the book). I hope it works -_-.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Ok. I got the core files to work. Now I have errors with dsound.h. 8 of them.
Here are the errors.

dsound.h(305) : error C2146: syntax error : missing ';' before identifier 'dwReserved1'
dsound.h(305) : error C2501: 'DWORD_PTR' : missing storage-class or type specifiers
dsound.h(305) : error C2501: 'dwReserved1' : missing storage-class or type specifiers
dsound.h(306) : error C2146: syntax error : missing ';' before identifier 'dwReserved2'
dsound.h(306) : error C2501: 'DWORD_PTR' : missing storage-class or type specifiers
dsound.h(306) : error C2501: 'dwReserved2' : missing storage-class or type specifiers
strmif.h(1024) : error C2146: syntax error : missing ';' before identifier 'HSEMAPHORE'
strmif.h(1024) : fatal error C1004: unexpected end of file found

It seems that the 2 header files are DirectX headers. Im stumped~

I've tried the Summer '03, Summer '04 and October '04 versions of DiretX 9. And I have also tried DirectX 8.0 and 8.1. I have no idea why this won't work!!!

Share this post


Link to post
Share on other sites
I know I'm really getting annoying to you guys by now. But I don't really know that much about DirectX and when I go through these chapters it will be hard enough to understand them as it is. I reformatted my computer and put Windows 2000 PRO on it. I then put all the system components in (Video drivers, sound drivers and the such) then I updated using Windows Update. Then I copied the book code to my computer and used the Books DirectX version (Summer 03 Update) and it still gives me the error listed in the last post. -_- Is Jim Adams on these forums? Maybe he can help?

edit:
I'm going to upload the error log to my site and then link it. Maybe that will help~ =)

k. I got it uploaded. Here is the link:
https://home.comcast.net/~davidtwillingham/Mapping.plg

edit2:
I got the dsound and strmif errors fixed. Now my ONLY problem is:

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


[Edited by - davidprogrammer on October 14, 2004 3:10:47 AM]

Share this post


Link to post
Share on other sites
You got the SDK installed, so the documentation is there too. Read the interface docs and see what the parameters are supposed to be and fix it accordingly.

I would help you personally, but I only have the first edition, so I don't have the new code.

Share this post


Link to post
Share on other sites
This is what I got in the documentation. I don't see how I could implement it. I guess I might be able to when I get there, but chapter 6 to the end doesn't work, which is a bit of a let-down -_-

DrawText Draws formatted text. This method supports ANSI and Unicode strings.
GetDC Returns a handle to a display device context (DC) that has the font set.
GetDesc Gets a description of the current font object. GetDescW and GetDescA are identical to this method, except that a pointer is returned to a D3DXFONT_DESCW or D3DXFONT_DESCA structure, respectively.
GetDevice Retrieves the Microsoft® Direct3D® device associated with the font object.
GetGlyphData Returns information about the placement and orientation of a glyph in a character cell.
OnLostDevice Releases all references to video memory resources and deletes all stateblocks.
OnResetDevice Should be called after the device has been reset.
PreloadCharacters Loads a series of characters into video memory, to improve the efficiency of rendering to the device.
PreloadGlyphs Loads a series of glyphs into video memory, to improve the efficiency of rendering to the device.
PreloadText Loads formatted text into video memory to improve the efficiency of rendering to the device. This method supports ANSI and Unicode strings.

Share this post


Link to post
Share on other sites
Would it be logical to just take the ID3DXFont from DirectX 8.1 and put it into my current DirectX9.0 Library (overwrite the new one)? Because I am postive this book uses DirectX 9. For that is what came with the book.
error C2039: 'Begin' : is not a member of 'ID3DXFont'
error C2660: 'DrawTextA' : function does not take 5 parameters
error C2039: 'End' : is not a member of 'ID3DXFont'


Check this out. I need to get this down now because I am at the chapter that talks about fonts. But none of the programs work because of the above. Now here is what the books says:

The ID3DXFont object contains seven functions, only three of which we're interested in here.

Those functions are:
ID3DXFont::Begin // this function signifies the beginning of a font-drawing operation.
ID3DXFont::End // this function signifies the end of a font-drawing operation
ID3DXFont::DrawText // this function draws text



How would I go about implementing the current DirectX functions to work with the ::Begin and ::End functions?

And what does this mean?
D3DXCreateFontIndirect(g_pD3DDevice, &Font, &g_pFont);

font\winmain.cpp(138) : error C2664: 'D3DXCreateFontIndirectA' : cannot convert parameter 2 from 'struct tagLOGFONTA *' to 'const struct _D3DXF

Share this post


Link to post
Share on other sites

This topic is 4810 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this