Printing text with direct x
What is the easiest way I could print the frames per second of my program in the left hand corner of the screen? can someone show me the code?
unless you want to use the (slowww) GDI function TextOut(), you need to write some sort of bitmap-font drawing engine
www.mr-gamemaker.com has a nice article on doing this, check it out.
www.mr-gamemaker.com has a nice article on doing this, check it out.
This is my Delphi code for using the GDI to output text to a DirectDraw surface.
This is great for debugging purposes since it is so simple. Using a bitmap font is a bit more difficult but is basically just a series of blits from the font bitmap to the destination surface, one for each character in the string.
Steve 'Sly' Williams
Tools Developer
Krome Studios
Edited by - Sly on October 18, 2000 1:45:35 AM
var DC: HDC;begin FSurface.GetDC(DC) try Windows.SetBkMode(DC, Windows.TRANSPARENT); Windows.SetTextColor(DC, FFont.Color); Windows.SelectObject(DC, FFont.Handle); Windows.TextOut(DC, X, Y, PChar(Str), Length(Str)); finally FSurface.ReleaseDC(DC); end;end;
This is great for debugging purposes since it is so simple. Using a bitmap font is a bit more difficult but is basically just a series of blits from the font bitmap to the destination surface, one for each character in the string.
Steve 'Sly' Williams
Tools Developer
Krome Studios
Edited by - Sly on October 18, 2000 1:45:35 AM
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement