Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Programmer16

Drop in FPS because of negative #s using ID3DXSprite

This topic is 5277 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

Okay, this is weird. I'm using ID3DXSprite to draw my bitmap font to the screen. I hadn't had any error detection because (I thought) it was working fine. I have it printing out FPS: %.0f\nMouse: (%.0f, %.0f) (My class handles the \n character) I'm using the Zen Programming w/ DX book's code (can't remember the title):
char cChar = pString[iIndex] - 32;
Result = div(cChar, m_iLettersPerRow);
iOffsetX = abs(Result.rem * m_iLetterWidth);
iOffsetY = abs(Result.quot * m_iLetterHeight);
SetRect(&SrcRect, iOffsetX, iOffsetY, iOffsetX + m_iLetterWidth, iOffsetY + m_iLetterHeight);
DstPoint.x = iX + (iIndexB * m_iLetterWidth);
if(pString[iIndex] == '\n')
{
	iIndexB = -1;
	iDstOffset += m_iLetterHeight;
}
else

DstPoint.y = iY + iDstOffset;
HRESULT hResult = m_pSprite->Draw(m_pBitmap, &SrcRect, NULL, NULL, 0, &DstPoint, 0xffffffff);
if(FAILED(hResult))
{
	LogError("Error drawing text (\"%s\") using  Direct3DX sprite.\tHRESULT:%s\n", pString, DXGetErrorDescription9(hResult));
	LogError("%i/%i/%i/%i at %.0f, %.0f\n", SrcRect.left, SrcRect.top, SrcRect.right, SrcRect.bottom, DstPoint.x, DstPoint.y);
	return;
}
Which, before I added the abs(), was giving me negative numbers. My FPS was being printed at about 60, and everything was printing out fine, but when I added error detection, it'd print upto FPS: # and then give me an Invalid Call error. So I printed out the values and they were negative. Now that I added the abs() calls, my FPS is about 650. My question is: why was it printing fine before and why was my FPS dropping almost 600 counts? I understand that its bad to use negative for the source and everything, I just wanted to know why the huge drop. Hopefully you can understand that and thanks! [edited by - Programmer16 on June 3, 2004 3:17:58 PM]

Share this post


Link to post
Share on other sites
Advertisement
60 sounds like a much beeter number for Frame rates than 650, normally the frame refresh rate can''t go any faster than the refresh rate of your monitor.

I''ve used the Zen of Direct 3D book, and although It''s great for teaching a lot of the concepts, I''ve found the authors code to be very buggy. It''s a great experiance for learning DX from all the hours digging thru the SDK to find out why the authors code doesn''t work. This book should really come with a disclaimer

Share this post


Link to post
Share on other sites
Well, am I doing something wrong with my FPS calculations then?
m_fFrameCount += 1.0f;
m_fCurrent = (float)GetTickCount() / 1000.0f;
if(m_fCurrent - m_fPrevious > 1.0f)
{
m_fFps = m_fFrameCount / (m_fCurrent - m_fPrevious);
m_fPrevious = m_fCurrent;
m_fFrameCount = 0;
}

char* GetFpsString(char* pDst)
{
return itoa(m_fFps, pDst, 10);
}


Thanks!

Share this post


Link to post
Share on other sites

  • 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!