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?
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?
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.
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?
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.
Usually is logically wrong draw object outside the draw function. I will do something like that.
iHaveToDrawSomething = button1 is pressed;
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
[b]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?
Ah in fact you need a “no event” event
Try this : glutIdleFunc