• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
monkeyboi

Can not get my font rendered in DX9

6 posts in this topic

It was a whileI integrated font rendering into my program. At that moment every thing worked fine. After that I implemented other functions like memory leak detection, light, shader encapsulation ect. Couple days ago I realised the text rendering was missing. Till now I have tried all the ways I can think of but nothing could make it work. According to my back up projects, the text seems to be lost after I implementing memory leak detection. But I can not see any side effect that could cause this problem. I also track and set zbuffer, alpha, light, which change nothing in font rendering. So any idea about what could cause this problem? Thanks in advance
[CODE]
// Create default font
m_iFontID = LoadFont("Arial",22,false,false);
assert( m_iFontID == 0 );
[/CODE]
[CODE]
int MyDxRenderer::LoadFont (const char* acFace, int iSize, bool bBold,
bool bItalic)
{
// Find the first unused font location
int iLoc;
for (iLoc = 0; iLoc < m_kFontArray.GetQuantity(); iLoc++)
{
if ( !m_kFontArray[iLoc] )
break;
}
ID3DXFont* pqFont;
DWORD dwWeight = ( bBold ? FW_BOLD : FW_REGULAR );

ms_hResult = D3DXCreateFont(
m_pqDevice, // pDevice
iSize, // Height
0, // Width
dwWeight, // Weight
0, // MipLevels
(DWORD)bItalic, // Italic
DEFAULT_CHARSET, // CharSet
OUT_DEFAULT_PRECIS, // OutputPrecision
ANTIALIASED_QUALITY, // Quality
VARIABLE_PITCH, // PitchAndFamily
acFace, // pFaceName
&pqFont); // ppFont
assert( SUCCEEDED(ms_hResult) );
// Put into the font array
if ( iLoc == m_kFontArray.GetQuantity() )
m_kFontArray.Append(pqFont);
else
m_kFontArray[iLoc] = pqFont;
return iLoc;
}
[/CODE]
[CODE]
m_pkRenderer->ClearBuffers();
if ( m_pkRenderer->BeginScene() )
{
m_pkRenderer->DrawScene(m_pkScene);
DrawFont(70,70,ColourRGBA::WHITE);
/*char acMessage[256];
Vector3f temp = m_pRect->Local.GetTranslate();
sprintf_s(acMessage,256, "X = %f",temp.X());
m_pkRenderer->Draw(100,100,ColourRGBA::WHITE,acMessage);*/
m_pkRenderer->EndScene();
}
m_pkRenderer->DisplayBackBuffer();
[/CODE]
[CODE]
void MyWindowApplication::DrawFont (int iX, int iY, const ColourRGBA& rkColour){
m_iFrameCount++;
m_dCurTime = LumPySystem::GetTime();
if ((m_dCurTime-m_dPreTime)>1)
{
m_iFrame = (int)(m_iFrameCount/(m_dCurTime-m_dPreTime));
m_iFrameCount = 0;
m_dPreTime = m_dCurTime;
}
char acMessage[256];
sprintf_s(acMessage,256, "FPS: %d",m_iFrame);
m_pkRenderer->Draw(iX,iY,rkColour,acMessage);
}
[/CODE]
[CODE]
void MyDxRenderer::Draw (int iX, int iY, const ColourRGBA& rkColour,
const char* acText)
{
/*ms_hResult = m_pqDevice->SetRenderState(D3DRS_LIGHTING,FALSE);
m_pqDevice->SetRenderState(D3DRS_ZENABLE,FALSE);
ms_hResult = m_pqDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,true);
DWORD dwFormat = D3DFVF_XYZW;
ms_hResult = m_pqDevice->SetFVF(dwFormat);*/
assert( acText );
if ( !acText )
return;
RECT kText;
kText.bottom = iY;
kText.top = iY;
kText.left = iX;
kText.right = iX;
D3DCOLOR kColour = D3DCOLOR_COLORVALUE(rkColour.R(),rkColour.G(),rkColour.B(),
rkColour.A());
ms_hResult = m_kFontArray[m_iFontID]->DrawText(
0, // pSprite
acText, // pString
-1, // Count
&kText, // pRect
DT_LEFT | DT_BOTTOM | DT_CALCRECT, // Format
kColour); // Colour
assert( SUCCEEDED(ms_hResult) );
}
[/CODE]

One thing I forgot to mention, in debug model, every function returns OK.
0

Share this post


Link to post
Share on other sites
RECT kText;
kText.bottom = iY;
kText.top = iY;
kText.left = iX;
kText.right = iX;

I few things to try:

- I know you are using DT_CALCRECT, but just try adding a width and height to your right and bottom and see if it displays.

- I would also check rkColour.A() and verify that it is not zero.

Other than that nothing really stuck out to me.
0

Share this post


Link to post
Share on other sites
[quote name='yewbie' timestamp='1347039973' post='4977751']
- I know you are using DT_CALCRECT, but just try adding a width and height to your right and bottom and see if it displays.
[/quote]
Thanks yewbie I get it solved by using
kText.bottom = iY+100;
kText.top = iY;
kText.left = iX;
kText.right = iX+100;

ms_hResult = m_kFontArray[m_iFontID]->DrawText(
0, // pSprite
acText, // pString
-1, // Count
&kText, // pRect
DT_LEFT | DT_BOTTOM , // Format | DT_CALCRECT
kColour);

Really want to know what is the problem of the previous one [img]http://public.gamedev.net//public/style_emoticons/default/huh.png[/img]
1

Share this post


Link to post
Share on other sites
[quote]Determines the width and height of the rectangle. If there are multiple lines of text, DrawText uses the width of the rectangle pointed to by the lpRect parameter and extends the base of the rectangle to bound the last line of text. If the largest word is wider than the rectangle, the width is expanded. If the text is less than the width of the rectangle, the width is reduced. If there is only one line of text, DrawText modifies the right side of the rectangle so that it bounds the last character in the line. In either case, DrawText returns the height of the formatted text but does not draw the text.[/quote]
[url="http://msdn.microsoft.com/en-us/library/windows/desktop/dd162498%28v=vs.85%29.aspx"]http://msdn.microsof...8(v=vs.85).aspx[/url]

Ah i forgot using DT_CALCRECT will return the calculated rect but not actually draw anything!

edit: thats not actually the same function you are using but it works the same Edited by yewbie
0

Share this post


Link to post
Share on other sites
Thank you so much Yewbie This really help me a lot
Yeah I have seen the link. It looks like DrawText is a function embeded in windows development. Reckon the function in DirectX works in the same way coz it is by microsoft as well : )
1

Share this post


Link to post
Share on other sites
[quote name='monkeyboi' timestamp='1347055412' post='4977829']
Thank you so much Yewbie This really help me a lot
[/quote]

No problem, I did a ton of work for directx9 a year or two ago so if you have any questions feel free to PM me (Although I don't check GD every day)
0

Share this post


Link to post
Share on other sites

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  
Followers 0