Archived

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

Font Engine Problems

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

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.

Share this post


Link to post
Share on other sites
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

}

Share this post


Link to post
Share on other sites