Skip to main content
gamedev.net
🔒 Locked

Font Engine Problems

Started by Scott Linford Aug 7, 2003 at 5:09 PM 0 replies 250+ views
Original Post
Scott Linford
Scott Linford
Hello everyone. I have created a font engine using bitmaps in DirectX because GDI is slow. The engine works; however, it is even slower than using the GDI method! Here is the code that does the blitting. The characters are loaded in an array of surfaces called text_buffer[191]; ///this function uses DirectX to blit text to the screen//////// void BlitText(char *text, int x, int y, LPDIRECTDRAWSURFACE4 lpdds) { RECT dest_rect, // the destination rectangle source_rect; // the source rectangle dest_rect.top = y; dest_rect.bottom = y+12; // fill in the source rect source_rect.left = 0; source_rect.top = 0; source_rect.right = 12; source_rect.bottom = 12; for ( int index=0 ; text[index] != NULL; index++) { dest_rect.left = x + (11 * index); dest_rect.right = x + (11 * index) + 12; lpdds->Blt(&dest_rect, text_buffer[text[index] - 32], &source_rect,(DDBLT_WAIT | DDBLT_KEYSRC), NULL); // blit } // end for } // end BlitText Thanks for your help.
miodragsm
miodragsm
try this:

int i = 0;
for ( int index=0 ; index < strlen(text); index++)
{
dest_rect.left = x + i;
dest_rect.right = dest_rect.left + 12;
i += 11;

lpdds->Blt(&dest_rect, text_buffer[text[index] - 32], &source_rect,(DDBLT_KEYSRC), NULL); // blit

}

Topic Locked

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

Sign in to reply to this topic.