| View previous topic :: View next topic |
| Author |
Message |
SkReaP Brown Belt


Joined: 11 Feb 2004 Posts: 266 Location: Anyplace with internet
|
Posted: Mon Sep 20, 2004 7:11 am Post subject: C++/openGL/Mouse |
|
|
I feel kinda stupid asking this, but how do you code for the mouse in C++ (preferably in the .net environment)
I realize this is a pretty general question so I'll try to specify:
say I have a mouse class for a 3 button mouse w/wheel:
class Mouse
{
GLfloat XLocation;
GLfloat YLocaiton;
bool Mbutton1(); //LMB pressed down
bool Mbutton2(); //RMB pressed down
bool Mbutton3(); //MMB pressed down
int MWheel() //0=still, 1=up, 2=down
};
and in my code I want to close my program if someone clicks the RMB, so I have this...
Mouse User;
...
if(User.Mbutton2())
{
exit(0);
}
...
what code would I put in:
bool Mouse::Mbuton2()
{
<<HERE>>
};
also, what headers do I need to include?
thx! |
|
| Back to top |
|
 |
SkReaP Brown Belt


Joined: 11 Feb 2004 Posts: 266 Location: Anyplace with internet
|
Posted: Mon Sep 27, 2004 7:30 am Post subject: |
|
|
wow...didn't think my question was that complicated....
let me tone it down a bit...
Let's say I'm writting a C++ application, and I want the program to exit if I click the RMB, IE:
...
if(RMB())
{
exit(0);
}
...
What goes in function RMB()?
Is that simpler? |
|
| Back to top |
|
 |
ksog23 Pilgrim

Joined: 18 Sep 2004 Posts: 11
|
Posted: Fri Oct 01, 2004 1:59 pm Post subject: |
|
|
you should probably create 3 private bool variables for each button, and return each one whenever the Mbutton() is called
example
private bool button1;
bool Mbutton1()
{
return button1;
}
somewhere in your program you'll probably need to initialize and set the value for button also. |
|
| Back to top |
|
 |
|