c++ - How do you fix a program from freezing when you move the window in SDL2? -


i'm making small game friend , 1 problem when drag window around, freezes , program stops until let go. searched simple solution found out happens everything. also, screws delta time since acts long frame. there way either have program continue running while move or if that's complicated, fix delta time? thanks?

your application "freezing" because has winmain loop similar this:

while (true)  {     if(peekmessage(&msg,null,0,0,pm_remove))     {         translatemessage(&msg);         dispatchmessage(&msg);     }     else     {        tickgame();     } } 

so instead of ticking processing wm_move message . 1 simple work around call games tick function within move message, or perhaps makes sense pause game when first move message , unpause if haven't gotten 1 second or two. is, people going dragging window while playing, unlikely.

to answer second question, typically games (physics engines especially) use fixed time step stabilize simulation, read more fixed time step here.


Popular posts from this blog