Jump to content
  • Advertisement

Archived

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

BeanDog

Input a string?

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

Is there someone out there who has written a string-input deal for DirectDraw? Like cin, but with a IDIRECTDRAWSURFACE7 object. You know what I mean? You call it, they type something in, the function returns it. Anybody?

Share this post


Link to post
Share on other sites
Advertisement
quote:
Original post by BeanDog

Is there someone out there who has written a string-input deal for DirectDraw? Like cin, but with a IDIRECTDRAWSURFACE7 object. You know what I mean? You call it, they type something in, the function returns it.

Anybody?


Well, cin is just a standard wrapper object for the part of the console input system that the operating system provides. Therefore it isn''t handling moving the cursor when you type, moving onto the next line, etc etc. This means that, to do a windows version, you have to handle all this yourself. Hence the popularity of MFC, etc Is it not practical to use a Windows edit box on such a surface? I have never tried it myself, but I expect that if you knew what you were doing, that would be the fastest way.
Otherwise, you''re gonna need to implement letter drawing functions, a list/stack/array of characters to hold your input, some way to grab that input (DirectInput, for example) and a way of matching up the input to a letter to add to your string. If you are going to do it yourself, I recommend you start with fixed width characters and only upper or lower case until you get the hang of it

Share this post


Link to post
Share on other sites
Surely someone has run into this. I mean, don''t you all have some game where the user can type in an alias? Seems like a simple enough task.

Share this post


Link to post
Share on other sites
Your problem seems to be that cin uses stdout, which one can hardly see in graphics mode under DirectDraw

I''ve created a small DirectInput library which supports quake-like key binding - and - cursored text input. The library can be initialized with just 2 function calls, so this shouldn''t be the problem.
The text the user is typing is placed in an char * array, you just have to call an update() function (meaning your program keeps running, allowing you to draw the text onto the ddraw surface). Since the lib uses buffered mode, you won''t lose keystrokes even if the app runs very choppy

If you''d like to give it a try,
www.lunaticsystems.de/truefx
(a simple example app demonstrating string input is included, the lib is free and full-source, full english documentation)

-Markus-

P.S. Wow. Finally became a ''dedicated'' with this message :D

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!