Sign in to follow this  

Updating

This topic is 3117 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

This topic is 3117 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this