View Full Version : glut mouse and arrow movement for borland 5?
12-08-2002, 04:37 PM
Ive been looking for and cant find simple things like move forward or backwards or looking around with the mouse for some time and cant find much on the web, so if any one knows these commands could they please
reply with the full thing from int mouse or keyboard onwards. or if any one knows of a site/s that have a tutorial on it please tell.
12-08-2002, 04:59 PM
It's actually quite simple to implement mouselook. Check this out, it should go in your main loop if this is a game.
//MouseLook is boolean
SetCursorPos(wr.right / 2, wr.bottom / 2);
Heading -= ((wr.right / 2) - MPos.x) + Sensitivity;
LookUp += ((wr.bottom / 2) - MPos.y) + Sensitivity
Heading would be which way you're looking, and LookUp would be how far up or down you'd look. Simple, no?
12-09-2002, 03:31 PM
just wondering would you or any one else happened to know the walk commands. using the arrow keys?
12-10-2002, 05:25 AM
You'll have to implement walking yourself using things like glTranslate, glRotate, or gluLookAt. Use the glut special keyboard callback function to check for keyboard events for the arrow keys.
12-10-2002, 04:06 PM
just a reminder i am a real newby to opengl
I think ive got all that coded in,
but just wondering what header or libary file/s are used to do the mouse movement thing in that one above ^^ because when i went to compile it on the command line thing with borland.
i typed "bcc32 bcc1.cpp glut32.lib" i m definently missing something there if any one knows the answers please tell
oh and how do you do this glut special keyboard call back.
sorry im lack of knowledge is annoying hey.
[This message has been edited by Damage_inc (edited 12-10-2002).]
12-11-2002, 05:57 AM
If you look in the glut header, you will find a line that looks like so:
extern void APIENTRY glutSpecialFunc(void (*func)(int key, int x, int y));
What that is telling you is that glutSpecialFunc takes a pointer to a function that looks like so:
void AnyName(int key, int x, int y); // variable names can be different as long as they remain ints
You'll also find the following in the glut header:
#define GLUT_KEY_LEFT 100
#define GLUT_KEY_UP 101
#define GLUT_KEY_RIGHT 102
#define GLUT_KEY_DOWN 103
Now, to use that knowledge, you would do something like so...
void SpecialKeys(int key, int x, int y);
// do normal glut stuff
// before glutMainLoop add this line
void SpecialKeys(int key, int x, int y)
// turn right
// move forward
// move backward
Now, to actually do the movement depends a lot on how you are setting up your app, and is going to require a bit of math on your part.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.