Archived

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

text in a fullscreen dx app

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

plz redirect this question to another post if its been repeated elsewhere as im sure it has.... how do i display text to a directdraw surface? is the only way to FlipGDIToSurface, and draw text on surface with GDI methods? surely there is a better (dd) way to do things? here in castle camelot we eat ham and jam and spam alot!

Share this post


Link to post
Share on other sites

This is the way I do it. I use GDI to output truetype
text to a DirectDrawBuffer.



LogFont MyLogFont;


Init of LogFont:


ZeroMemory(&MyLogFont, sizeof(LogFont));
strcpy(MyLogFont.lfFaceName, "Arial");
MyLogFont.lfHeight = 14;
MyLogFont.lfQuality = ANTIALIASED_QUALITY;



This is my function for outputting the text to the screen:


void Type(LOGFONT *lgf, int x, int y, int Size, char *szText, byte r, byte g, byte b)
{
lgf->lfHeight = Size;
m_pDDSurface->GetDC(&hdc);
hFont = CreateFontIndirect(lgf);
SelectObject(hdc, hFont);
SetBkMode(hdc, TRANSPARENT);
SetTextColor(hdc, RGB(r,g,b) );
TextOut(hdc, x,y, szText, lstrlen(szText));
DeleteObject(hFont);
m_pDDSurface->ReleaseDC(hdc);
}




For some reason the text is only antialiased in some of
the sizes....
Hope you can use it....

Share this post


Link to post
Share on other sites
GDI is Slow!
but other than using it, the only way around it is to write your own Text rutine, having all the letters in a bitmap (not GDI HBITMAP of course) and blit em to the surface, I am sure there is a tutorial about that here in gamedev somewhere, I have been looking for it for 3 days, still no luck, could anyone point us to it? please?
not that I dont know how to do it myself, but I want to see if there is something I should know before starting to write my routine.

Share this post


Link to post
Share on other sites
I recently wrote a font ceation utility which outputs bitmap fonts in my own format. If anyone is interested, I can write a tutorial on how to convert TTF fonts to a custom format using BMP''s (instead of my own img format), then load them into a DDraw surface. Colors can be changed on the fly with very little performance hit, but the sizes are pretty much fixed. Well, hell. I''ll write a tutorial anyway. I''ll post it in a few days.

Cheers.

Share this post


Link to post
Share on other sites
yeah ok, ill give those tuts a look.

i assumed there would be a default method of outputting strings to the dd surface without creation of ure own font system.

I couldnt find any relevent methods in directdraw, so i decided to leave text up to gdi, even though i know its slower - this is just for a scripted scene though, not a game.

thx for the confirmation.



here in castle camelot we eat ham and jam and spam alot!

Share this post


Link to post
Share on other sites
Look up a program called GameFontGX.

Include the library in your program and displaying text is like this:

  
FontBlit->NoEffectBlit("Text To Output", 0, XLocation, YLocation, FontName, Color);


You''ll have to look at the example to figure out how to use it, but it isn''t difficult.

Share this post


Link to post
Share on other sites
I created my own font implementation, i have a demo of it on my site in the sources section. It is a little out dated from my current rendition of it, but if you are interested, i could upload a newer source for it. The newer one is alot better. If you are intersted email me or something, later-



what we do in life... echoes in eternity...

Share this post


Link to post
Share on other sites