Jump to content
  • Advertisement

Archived

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

dirkduck

OpenGL Equilivent of 'cin' in OpenGL

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

Im just wondering, what is the equilivant of the cin command in OpenGL? In other words, how can you ask the user for input in OpenGL? thanks McDougal...DUCK McDougal

Share this post


Link to post
Share on other sites
Advertisement
Uh......why would there be a cin in opengl in the first place? Opengl is a 3D GRAPHICS API. Nothing more, nothing less. You should probably read more about what opengl is. Here are some starter places: http://nehe.gamedev.net , http://www.opengl.org

-SirKnight

Share this post


Link to post
Share on other sites
sorry, I guess I wasnt really clear, what I meant was the equilivent of cin in WinMain (windows API) while using OpenGL. Does that make any sence?

McDougal...DUCK McDougal

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
With glGetInput(deviceId, optA, optB). You should find his declaration in gli.h.
If you are programming under Windows is better to use DirectGL instead of OpenGL: DirectGL is an implementation from Microsoft and work faster than OpenGL.

Share this post


Link to post
Share on other sites
As for getting text input, do you want people to be able to type a string of text, or do you just want to react to certain keypresses - like, if they hit "UP," move the world towards the camera?

If it''s the latter, the easiest thing to do would be to just make an array of bools (bool key[256]) and, on WM_KEYDOWN, set key[wParam] = true and on WM_KEYUP set key[wParam] = false. Then, each frame, check if keys[Whatever key you want] == true.

If it''s the former, then you''ll have to write your own function, in which case, on WM_KEYDOWN, add wParam to the next character in a string, and end when the user hits Enter (again, check the value of wParam). You''ll also have to output the text somehow. The best way to do that would be using textured Quads.

I assume the Anonymous Poster is referring to DirectInput, which is another way of ketting keyboard, mouse, and joystick/gamepad input. It is faster than using Windows messages (the easy way I mentioned).

If you didn''t understand anything I just said, then I think it would be a good idea if you didn''t program OpenGL for a while, and learned some more about C++ in Console Mode. I suggest you write your own cin and cout functions (using getch() and putch()) for the console so you have a better idea of how strings work, for one thing. I made the same mistake you''re making; I went straight from "Hello World" to OpenGL, got completely confused, and then actually learned the language and got a firmer grasp of the logic behind it. Now I''m finally venturing (more cautiously) into OpenGL, again. I know it''s easier to wow your friends with pretty pictures (OpenGL) than it is with a mathematical expression parser (what I just finished coding in console mode), but you''ll learn a lot more writing the expression parser - or whatever other algorithm you want to write in console mode. The beauty of the console is, it''s a simple environment to experiment with logic in.

Share this post


Link to post
Share on other sites
Thanks for the replys everyone. Actually, I already have the single key presses and such, and i am comfortable with those. thanks for the info though, maybe ill attempt my own function on it.

McDougal...DUCK McDougal

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!