Hello
I have an app in which I have projected some (3d pengl) stuff, e.g. a cube which the user can drag(/translate) around with the mouse.
so on WM_MOUSEMOVE I call ToMouse(M) (when the buttoon is also pressed)
which translates the selection to the mousecoordinates M.
The 'problem' is that it takes some time to translate,re-render and re-print some info, so when continously dragging the cube around its constantly 'left' behind' the cursor a small bit, depending on how fast you move the mouse, and it 'catches up' with when it holds still. (like a trail)
Now im not sure what to do here.
I cant block the mouse from moving on those cases, it becomes shocky.
Should I not do it on every WM_MOUSMOVE ? how the determine which then ??
to be clear, I want the point on the cube that is clicked the first time, to always be exactly under the mouse while dragging, fixing the two toghether, giving a real solid dragging apearance.
I can see that the coordinates M can differ from ones that I get later in the ToMouse function re-calling GetCursorPos.
thanx
Set a flag when the mouse button is down, and clear it when the button is released (use WM_xBUTTONDOWN and WM_xBUTTONUP messages). Then, in your render loop, check the mouse position with GetCursorPos each frame; if the button-down flag is set, use that position to move the cube.
Quote:Original post by ApochPiQ
Set a flag when the mouse button is down, and clear it when the button is released (use WM_xBUTTONDOWN and WM_xBUTTONUP messages). Then, in your render loop, check the mouse position with GetCursorPos each frame; if the button-down flag is set, use that position to move the cube.
actually, things are a bit different.
I do use a flag to see whether mousebutton is down.
However, Im not using a renderloop, but update only on changes (mainly WM_PAINT, and explicit calls whenever the user does something)
so i have
case WM_MOUSEMOVE && mousedown / dragging
{
GetCursorPos (&m)
MoveStuffToM (m)
RenderUpdate ()
return
}
If the RenderUpdate takes some time, a GetCursorPos call after that results in different coordinates. so now I figure, that in the time that it took multiple(??) more move-messages have been sent.
Should I somehow check for that ? remove those from the queue?
I have now tried the following:
case WM_MOUSEMOVE && mousedown / dragging
{
GetCursorPos (&m)
MoveStuffToM (m)
RenderUpdate () ; lengthy...
while (PeekMessage (&msg, hWnd, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_REMOVE) != 0)
;
return
}
It seems a little better, but i cant be sure :).
It doesnt fix it though.
And i was wondering, does this make sense at all ? :D
case WM_MOUSEMOVE && mousedown / dragging
{
GetCursorPos (&m)
MoveStuffToM (m)
RenderUpdate () ; lengthy...
while (PeekMessage (&msg, hWnd, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_REMOVE) != 0)
;
return
}
It seems a little better, but i cant be sure :).
It doesnt fix it though.
And i was wondering, does this make sense at all ? :D
What exactly does your RenderUpdate() function do? I suspect you might get better results if you call InvalidateRect() at that point instead, and let the paint handler take its lengthy time once the corresponding WM_PAINT arrives.
Quote:Original post by ApochPiQ
What exactly does your RenderUpdate() function do? I suspect you might get better results if you call InvalidateRect() at that point instead, and let the paint handler take its lengthy time once the corresponding WM_PAINT arrives.
it just renders everything.
the render call is also placed at WM_PAINT, as I said.
So invalidating would just be one more intermediate step, getting to this function.
Mousemoving doesnt generate WM_PAINT, so I call directly.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement