View Full Version : Mouse Event Question.
12-14-2010, 09:17 PM
Second Newbie Question of the Day.
So I'm working with processMouseActiveMotion & processMouse.
I'm using a Method that is alike a Spray tool on any regular 'paint'. Paints Random Pixels around an Area.
The Problem is, I'm using ActiveMotion to activate such method, and when I Stop moving the mouse, the tool stops painting, even if the button is still pressed.
I've Tried several things, to no avail.
Am I missing something? What could I do here?
12-14-2010, 10:30 PM
I'm guessing that you're using GLUT and processMouseActiveMotion is the name of your callback.
If that's the case, tell me which glut function is it a callback of. Is it glutMotionFunc or glutMouseFunc?
12-15-2010, 10:23 AM
Oh, yes, sorry. I forgot bout' that.
Here it is:
glutMouseFunc( processMouse );
glutMotionFunc( processMouseActiveMotion );
Now, On processMouse I got this:
if(b==GLUT_LEFT_BUTTON && s==GLUT_DOWN)
And in processMouseActiveMotion I got this:
glDrawPixels(winWidth, winHeight, GL_RGB, GL_UNSIGNED_BYTE, colores);
xoo[i] = x;
yoo[i] = winHeight-y;
glReadPixels(0, 0,winWidth, winHeight, GL_RGB, GL_UNSIGNED_BYTE, colores);
xoo & yoo are arrays that follow the Starting Point and then the Mouse Movements.
pint is a Bresenham Algorithm that in place, calls one called spray That actually paints.
Now, I Imagine that I have to put such method in the processMouse, But When I do, nothing happens.
Thanks in Advance.
12-15-2010, 10:59 AM
12-15-2010, 11:30 AM
No. PassiveMotion is for when you move the mouse and no buttons are pressed right? I need the Opposite. The Mouse is Static yet the Button is pressed.
Now, I can tell it's going to be:
processMouse from glutMouseFunc( processMouse );
But How Do I Implement it?
12-15-2010, 12:49 PM
glutMouseFunc then ?
Do you want to do an action when the button of the mouse is pressed even if you don't move the mouse ? If so, this is the solution.
12-15-2010, 01:38 PM
Usually is logically wrong draw object outside the draw function. I will do something like that.
iHaveToDrawSomething = button1 is pressed;
12-15-2010, 02:22 PM
I was using MouseFunc. And I thought it wasn't working.
It is.... it's just working REALLY slow. =/
I have it like this on MouseFunc
if(boton==GLUT_LEFT_BUTTON && estado==GLUT_DOWN)
and on spray
void spray(int x, int y)
glColor3f(0.0, 0.0, 10.0);
glPointSize(10.0f); // determina el tamano del pixel
sy = (rand() % 25);
sx = (rand() % 25);
It does paint, it just does it REALLY slow. Anyone knows why would that be?
12-15-2010, 02:31 PM
Ah in fact you need a "no event" event :)
Try this : glutIdleFunc
Powered by vBulletin® Version 4.2.2 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.