PDA

View Full Version : Process keyboard input



vgm2
03-17-2001, 02:42 PM
Hi,
I am new to opengl and I would like some help on how to process keyboard input. I am using Win32 to run my opengl programs. In console application, the code bellow:

int x;
cout<<"\nPlease enter an integer.\n";
cin>>x;

allows the user to interact freely with the program without any predefined cases. I would like to know how to do the same thing in opengl.
Thanks.

Sebaot
03-18-2001, 06:26 AM
Well, "cin" will stop your execution flow wait for input. There are two other slightly similar ways of doing it. Either you use the Win32 event-based model and capture an OnKeyPress-event, or whatever they're named, or you run a console app. and do something like:




if(kbhit()){
char ch;
ch = getch();
switch(ch){
...


From what I understand, you can also use GLUT: http://www.xmission.com/~nate/opengl.html. Or, horror, DirectX's DirectInput.

vgm2
03-18-2001, 08:48 AM
Thanks for your help, I will try to do what you've said.

JoeMac
03-18-2001, 12:36 PM
GetAsynchKeyState() is much faster.
Joe