Skip to main content
GameDev.net gamedev.net
🔒 Locked

text out

Started by duckykim Aug 8, 2001 at 7:22 AM 0 replies 400+ views
Original Post
duckykim
duckykim
hi.... when i print text i am using GetDC but somebody said it is slow. i heard some other way to display faster. tell me how.. waiting for answering. my code is : HDC hdc; backbuffer->GetDC(&hdc); sprintf(imsi, "x:%d, y:%d", x, y ); TextOut(hdc, 100, 100, temp, strlen(temp)); backbuffer->ReleaseDC(hdc);
HardMario
HardMario
Another way to do it is store an array of surfaces with the letters, numbers, and characters that you want in the order that they occur in the ASCII table. Then, what you can do is iterate through the string that you want to print, getting each character's ASCII value and being sure to subtract it by whatever amount your lowest characters value is if the surface array is 0 based. As you do that, you can BltFast (or Blt if it's your poison) each character, and keep adding to an X value (if you are doing your text horizontally) that is used the BltFast. That is how I do it (this is for left justified text, for right I just decrement the XPos instead and start at the top of string to be printed and iterate through it down). Hope this helps!

Edited by - HardMario on August 8, 2001 8:50:31 PM

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.