Equilivent of 'cin' in OpenGL
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
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
-SirKnight
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
McDougal...DUCK McDougal
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.
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.
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement