How to redisplay AFTER glutMotionFunc exits?

I cannot figure out (easy way) how to trigger re-display AFTER the glutMotionFunc exits - by releasing left mouse button.
For testing purposes I use glutPassiveMotionFunc to track mouse thru window,
it does not do anything else for now, just tracks.
Then glutMouseFunc properly detect left button down.
Dragging mouse with (left) button down draws a “zoom circle” via “display list”.
Releasing button exits the glutMotionFunc - leaving the window blank - no “zoom circle”.

**What woudl be most logical way to redraw the “zoom circle” from **
current display list ?

I am going to try to give glutIdleFunc a “single shot” instruction to do so.
Any other “cool” ways to do this ?

glutMotionFunc(OpenGL_mouse_track_active); // track mouse when buton down

glutPassiveMotionFunc(OpenGL_mouse_track_passive); // track mouse on window - run "display"

The simplest way is to stop putting rendering logic inside of those callbacks. Put rendering logic in your display call; the mouse callbacks should instead manipulate data which is used by your display call.

For example, you might have a globally accessible flag that tells the renderer whether to draw the “zoom circle” and how much zoom there is. When you detect that the mouse button is pressed, you say to start drawing the circle. As the mouse is moved while the button is held down, you change how much zoom there is. When you release the button, you say to stop drawing the circle. Or, if you want the circle to still be drawn when you release the button, you use some other input to turn off the circle. What ever logic you like.

The point is that input should not directly be rendering the screen. It should affect how the screen gets rendered, and it should then force a redisplay if it changes something about how the screen gets rendered.

Whenever a change necessitates a redraw, call glutPostRedisplay.

Thanks, but…
See my new post about “display list(s)”.
I have hacked the menus display by NOT using display list hence no glutPostRedisplay`. Each menu runs its own "display " functions directly.

Now I am trying to build and use display list(s) and so far have been
unsuccessful. Posting glutPostRedisplay executes “display” but I am reading empty list, hence no redraw is happening.

So in simpler terms
I code an object ( sorry- but IMHO that is better than “mesh” etc,)
say a circle.
Then I do glFlush() which sometime displays the creation in window.
Not necessarily needed at the time.
Such object is encapsulated in a function.

Then I “add” the function to the “display list” (singular!).
Repeat as necessary for another function (object) to be added to the list.

Then I do glFlush() AGAIN after “end list” .
That also displays the list… not sure why it is needed.

At the end of the "active mouse " function I do
glutPostRedisplay - not sure if “display” gets called then when the active mouse is
still executing over and over due to button being down.

Since the mouse button is still down I rerun the "active mouse " function…
until mouse button goes idle / up.
Basically I need to add scaffolding to visualize all these events to see if the sequence is as expected.
In theory I should need just the glutPostRedisplay at the exit from the active mouse function.
Maybe a single glutPostRedisplay at the idle function when all the mouse functions are done executing.

Event callbacks (mouse, keyboard, timer) should just call glutPostRedisplay if they change something which necessitates a redraw. It doesn’t matter if glutPostRedisplay is called repeatedly; multiple redraw events will be merged.

Rendering is performed in the display callback; nowhere else. If you’re using a double-buffered context (and you should be), the display callback needs to call glutSwapBuffers at the end. This performs an implicit glFlush.