Advertisement

keyboard implementation????

Started by December 08, 2004 10:09 AM
1 comment, last by nife 19 years, 11 months ago
Hi! I've looked at the tutorials and I was wondering if there's any tutorial or article of how to use the keyboard in your OpenGL program? I've experimented with putting some text on the screen. Now I want this text to be like a menu. If someone could help me out how to implement keyboard selection or mouse selection. I would be very thankful. Thanks!
Well I just want to join so I can get som help.
Actually, OpenGL has nothing to do with your keyboard or mouse. If you want to use your keyboard or mouse for user input, you have to use for example Direct Input or SDL's functions. If you're going for cross-platform development I'd go for SDL.

Building your own control system with menus and buttons can be easy to very complex. A simple implementation would call a special function on a mouse click. This function would then check coordinates of the mouse click and check if there is a control under it.

Controls can be put in a list. If you're using C++ you can use inheritance and virtual functions to put all controls in a shared list...

Hope you got some ideas on how to implement menus, buttons and other stuff...

/skanatic
Advertisement
Mouse picking with OpenGL is slower than calculating it yourself. And just to clarify OpenGL a bit: it is JUST a graphics library, DirectX is a collecting of many things, among others a graphics library. Therefore you have to make everything yourself if you use OpenGL, which is also a good lesson. There is other corss-platform libraries, like the sound library OpenAL (much like OpenGL with states etc).
To use mouse picking, normally you would use matrix math (for 3D), which (I believe) is what OpenGL does for you with it's own functions.
Killers don't end up in jailThey end up on a high-score!

This topic is closed to new replies.

Advertisement