can anyone tell me how?
i've never done this before so i'm not sure as what library to use and how to call the command that a key pressed as a instruction rather than input..
i'm writing a OpenGL program in Visio C++
can anyone tell me how?
i've never done this before so i'm not sure as what library to use and how to call the command that a key pressed as a instruction rather than input..
i'm writing a OpenGL program in Visio C++
Zooming in OpenGL and getting keyboar inputs are two different things. You can use whatever GUI (MFC, wxWidgets, Qt, .Net) to capture keyboard events as input. Then, you can call OpenGL functions (glTranslate) to change the zoom and then redraw everything in your scene.
In Win32 you can do something the following to get the state of a key:
#define KEY_DOWN(vKey) (GetAsyncKeyState(vKey) & 0x8000) ? true : false
#define KEY_UP(vKey) (GetAsyncKeyState(vKey) & 0x8000) ? false: true
vKey is an int representing the keys ASCII value.
When you know that the "zoom" key is being pressed, then you can do a translate
glPushMatrix();
glTranslate3f(5.0,0.0,0.0); // moves the camera +5 down the x-axis
...
glPopMatrix();
Realistically you'd use more complex code to do the zoom as this is of course dependant on the view direction. Also you'd have a more complex key state function that would sit in your message loop and hold the state of all the keys your app would use including the mouse position and mouse buttons.