C++/openGL/Mouse

Discuss all aspects of programming here.

Moderator: The Mod Squad

C++/openGL/Mouse

Postby SkReaP » Mon Sep 20, 2004 7:11 am

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!
SkReaP
Brown Belt
Brown Belt
 
Posts: 266
Joined: Wed Feb 11, 2004 3:01 pm
Location: Anyplace with internet

Postby SkReaP » Mon Sep 27, 2004 7:30 am

wow...didn't think my question was that complicated....
:oops: :roll: :lol:

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?
SkReaP
Brown Belt
Brown Belt
 
Posts: 266
Joined: Wed Feb 11, 2004 3:01 pm
Location: Anyplace with internet

Postby ksog23 » Fri Oct 01, 2004 1:59 pm

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.
ksog23
Pilgrim
Pilgrim
 
Posts: 11
Joined: Sat Sep 18, 2004 1:51 am


Return to Programming

Who is online

Users browsing this forum: No registered users and 0 guests

cron