Archived

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

Draw Text in IDirectDrawSurface

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

i have a problem to put a text in my ddraw game. i know in vb there is DrawText in DirectDrawSurface, is it the same with IDirectDrawSurface in VC++?? because when i look in msnd, i can''t find DrawText in IDirectDrawSurface ?? is it different between DirectDrawSurface in vb and IDirectDrawSurface in vc++?? and how can i put a text in the surface?? i hope there''s someone can help me!! thanx!

Share this post


Link to post
Share on other sites
you ''could'' use the win GDI text function, although i can''t remeber what it is. what you do is get a DC from the direct draw surface you want to draw text onto, then set the font color and background and then call the function. i don''t have a copy of the code around but it shouldn''t be too hard to find a prototype for it.

Share this post


Link to post
Share on other sites
Yep, IDirectDrawSurface7::GetDC, the GDI's TextOut function, and IDirectDrawSurface7::ReleaseDC. Note that this method isn't the best around...

You might consider writing your own text renderer. Place the characters (e.g. 16x16 pixels) as part of a larger texture, organised into rows and columns in a way you want. Then, to draw the text, you can loop through every character of the given string, pluck out a rectangle from the font texture, and draw that character at the next location.

[edited by - Alimonster on November 7, 2003 7:07:26 AM]

Share this post


Link to post
Share on other sites