Controlling open gl programs
Hi Mr. Nehe.
I wanted to ask you a few questions, here they are:
1.)
All these games made in openGl run so smoothly. On my PC, (551Mhz P III, 256 Mb RAM), I played Serious Sam ( an openGl game), and it ran pretty well. However, my own programs are very slow. Is there some sort of optimizing technique I''m missing out on? ( I do use display lists, and I could send you my program if you want)
2.)
The method you have used for keyboard controls are a bit faulty. The keystrokes folow the ''keyboard rules'' you set in Windows (Millenium Edition), like repeat rate and repeat delay ( Control panel>>Keyboard ). This is unlike the behaviour in many games. Is there a better way of using keyboard controls?
3.)
How do I implement mouse controls for openGl programs? A tutorial from you on this topic would be **very** helpful.
I am only a few months into programming (one month into game programming), so forgive me for any stupid questions that I may have asked.
Thanks
Sandesh Singh
19 yrs
India
well I may not be mr Nehe, but
1) well thats just the art of programming isnt it? optimising your code
2) you can use libraries such as DirectInput or create your own code, perhaps using asm to access the hardware directly, and not through the windows messaging system.
3) see 2, or use the way you appear to dislike, which is by using the onmousemove-event in your windowproc, and reading the lo and hi param, resulting in the x and y position of the mouse-cursor on the screen. (see msdn)
1) well thats just the art of programming isnt it? optimising your code

2) you can use libraries such as DirectInput or create your own code, perhaps using asm to access the hardware directly, and not through the windows messaging system.
3) see 2, or use the way you appear to dislike, which is by using the onmousemove-event in your windowproc, and reading the lo and hi param, resulting in the x and y position of the mouse-cursor on the screen. (see msdn)
I can help you on the keyboard stuff. Basically, I have a function set up like this, where it tests for certain keys and does the appropriate thing.
And that is how I test for keys. This isn''t the best way, because this must be called every frame in order to work properly. A better way would be to store the keys'' state in a big array and check them whenever you want to. Be sure to include winuser.h and include user32.lib.
"Donkey, if it were me, you''d be dead."
I cna ytpe 300 wrods pre mniute.
[code]void keyboard(){ short up_key = GetAsyncKeyState(VK_UP); short down_key = GetAsyncKeyState(VK_DOWN); short right_key = GetAsyncKeyState(VK_RIGHT); short left_key = GetAsyncKeyState(VK_LEFT); if(up_key != 0)//the up key is pressed { //do whatever you need to right here. } if(down_key != 0) etc.....}[/code]
And that is how I test for keys. This isn''t the best way, because this must be called every frame in order to work properly. A better way would be to store the keys'' state in a big array and check them whenever you want to. Be sure to include winuser.h and include user32.lib.
"Donkey, if it were me, you''d be dead."
I cna ytpe 300 wrods pre mniute.
"Donkey, if it were me, you'd be dead."I cna ytpe 300 wrods pre mniute.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement