• Welcome to Overclockers Forums! Join us to reply in threads, receive reduced ads, and to customize your site experience!

Input Function OpenGL?

Overclockers is supported by our readers. When you click a link to make a purchase, we may earn a commission. Learn More.

Jay23

Member
Joined
Jul 2, 2002
Location
Niagara Falls, Canada
Hi all went to msdn and did a search on google etc for Input function on opengl.... like in console window its cin >>, cout <<...
Like in counter-strike u hit "y" on the keyboard and and can start typing.Is there a function for this in OpenGL..
 
Last edited:
OpenGL itself does not have the ability to read input. However, GLUT or things like SDL have the ability to read keystrokes from the keyboard and such. AFAIK, they don't have input mechanisms as sophisticated as those of the C / C++ stanard libraries.
 
well if you use the base that comes from nehegamedev, it sets up a keyhandler and a place to put what to do with each key. i dont know off hand if that is intergrated into opengl of something else, but its a starting place if you want to look at already made code.
 
Yes, you'll probably just want to use GLUT for OpenGL input:

void keyboard(unsigned char key, int x, inty)
{
switch( key )
{ ... }

return;
}



int main( )
{
...

glutKeyboardFunc(keyboard);
...
}

As for output, OpenGL and glut don't really have much of built-in fonts for writing text. (very limited), but a simple thing you can do is to leave the underlying command window there when you compile and doing simple "cout" there. (Don't compile with the -mwindows flag.)

-- Paul
 
Back