PDA

View Full Version : how to get user input



beginner620824
02-19-2003, 07:53 AM
I am a real beginner. I am reading a sample code in a book. The sample draws some points and the book says the user can use certain keys(it doesn't mention which keys) to rotate the angle to view these points. But the parameter(rotation angle) to call the rotate function is a variable which has not been declared anywhere(so the program cannot run). If it is as the book says, the variable should be related to a user input. How and where to declare this variable? and how related it to the user input ?e.g.
if(a key is hit)
{
the rotation agle++;
}
The platform is VC++, console application.

Thank you

Liuya

nexusone
02-19-2003, 08:45 AM
This is called an example code, the auther of the book expects you know how to program with VC.

With an understanding for VC, this bit of code becomes clear on the usage.

When he speaks of key's in which the user will press, he is talking in relative terms. The key can be any key in which you as the programmr wants to use.

You maybe want to look at some full program code.
nehe.gamedev.net has some good tutoring programs on how to program with openGL.


Originally posted by beginner620824:
I am a real beginner. I am reading a sample code in a book. The sample draws some points and the book says the user can use certain keys(it doesn't mention which keys) to rotate the angle to view these points. But the parameter(rotation angle) to call the rotate function is a variable which has not been declared anywhere(so the program cannot run). If it is as the book says, the variable should be related to a user input. How and where to declare this variable? and how related it to the user input ?e.g.
if(a key is hit)
{
the rotation agle++;
}
The platform is VC++, console application.

Thank you

Liuya

beginner620824
02-20-2003, 04:52 AM
yes, thanks.
In fact later that night i found nehe.gamedev.net which is really helpful. It answered most of my questoins.

Deiussum
02-20-2003, 08:05 AM
No offense, but if you need to ask a question like this, you really should learn a little bit more about programming in C/C++ before getting into OpenGL. Trying to learn how to program at the same time you trying to learn the OpenGL API is going to result in giving you endless headaches.

ghettotek
02-21-2003, 01:41 AM
just a quick note to (MacOS...[not sure if its the same for other OSes]) beginners dealing with keyboard input. in most cases, especially when dealing with any type of 3D gaming or anything of that sort, testing keys received from a keyDown event will greatly limit the "fluidness" (is that a word? =P) of your keyboard input, since you will only be getting 1 keyDown event for each key pressed. what most people want to do is see if a key (and most likely, multiple keys [are]) is being held (say, the arrow keys for movement). a great trick (which i just learned recently, being a beginner myself) is to create a boolean array (BOOL) which will store each keys current status. then you handle both keyDown and keyUp events to set the corresponding boolean value in the array. then, when you want to check to see if a key is being pressed, you just do if(keyArray[keyCode]==TRUE)