Jump to content
  • Advertisement
Sign in to follow this  
Padschild

Inputting text while in DirectDraw

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

Hey all, Just wanna say that this place is great :) But anyway, I've made a couple of DirectDraw programs, and I also am learning winsock, it's going really well. The next thing that I wanted to try is inputting some text, while in DirectDraw... But.. How am I going to do that? I can't use a text-box or something, right? Do I need to check for a pressed key, and then make a function for my own text-box in directdraw or something ? BTW, I am using c++.. Thanks alot :)

Share this post


Link to post
Share on other sites
Advertisement
That's exactly what you will need to do. You can use the WM_KEYDOWN/WM_CHAR messages to detect key presses. Then you will need a function to display text. In DirectDraw, you can use the GDI text functions (somewhat slow), or you can write your own functions and use a font drawn in a bitmap, treating the letters as sprites, and display the appropriate letter as the keys are pressed.

Share this post


Link to post
Share on other sites
Have you looked into DirectInput? Your other option is handling input via windows, as Dave Hunt has suggested.

Quote:
Then you will need a function to display text.


Not neccesarily, it depends on why he's taking input. He has mentioned text though, and your advice is excellent for that situation.

Share this post


Link to post
Share on other sites
Quote:
Original post by Dave Hunt
In DirectDraw, you can use the GDI text functions (somewhat slow), or you can write your own functions and use a font drawn in a bitmap, treating the letters as sprites, and display the appropriate letter as the keys are pressed.


Hmm.. yes, I know what you mean,.. I think that I need to program some sort of GUI function, that I can create windows as classes, and link textboxes and buttons to it, and then check everything on what is the active textbox / map / button, etc.. and then use the inputs from directinput/windows...

Thx for the answer, just wanted to make sure there wasn't another way :)

But do you suggest I make my own font bitmap, or use GDI text?

Share this post


Link to post
Share on other sites
To start out, I would use the GDI functions, since they already work. You can switch to using your own font routines after you get everything working.

Share this post


Link to post
Share on other sites
Your welcome. And good luck with it!

Just another note, if you decide to use DirectInput, you will want to use buffered mode while collecting user input. Otherwise, you won't have any way of knowing in what order the user pressed the keys. Again, for starting out, you can stick with Windows messages and switch to DirectInput once everything works.

Share this post


Link to post
Share on other sites
I've used the mouse earlier with buffering, with directinput, I will look deeper in how to use the keyboard with directinput..

Thanks for the tips :)

Share this post


Link to post
Share on other sites
I think DirectInput has problems with alternate keyboard layouts (like dvorak), as well. Directinput is good for game-controls, but I made a (very basic) text-input system using DirectInput, and if I were to make another one I'd probably just use window messages.

Share this post


Link to post
Share on other sites
Okay, inputting things works great, but another question I have is, how to use the windows system mouse ?? Because if the user clicks on a text box, it needs to become active, and then the user can type things.. But how do I know the coordinates the user has ?

I am using windowed mode, so if the user change the window's position, I presume I must calculate some things.. But I don't have a clue where to get the info on the coordinates of the mouse..

Anyone know some good tutorial on that ?

Thx,

Padschild

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!