Printing text with direct x

Started by
1 comment, last by OoMMMoO 23 years, 6 months ago
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?
Advertisement
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.
This is my Delphi code for using the GDI to output text to a DirectDraw surface.
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
Steve 'Sly' Williams  Monkey Wrangler  Krome Studios
turbo game development with Borland compilers

This topic is closed to new replies.

Advertisement