Well if I understand you correctly, then what I would do is have a thread running at a given fps or as fast as possible, that would update all entities. Then have the opengl thread run at the given FPS.
That depends entirely on how many entities need to be updated and what is involved in updating entities. If there is too much involved in updating entities, then rendering framerate will suffer. If the updating requires no rendering or opengl functions and the updating takes a lot of time, then multithreading is superior.
In summary, if the updating entities takes a while and doesn’t have to use opengl for anything, then properly handled multi-threading may be necessary. However, the actual determination of whether it is needed depends on more information.
Absolutely, having worker threads that handle slow operations can be usefull in certain cases (But would not make the update rate indipentant of the FPS).
My argument was against moving the entire update loop to another thread.
Yeah, if you can’t guarantee a fixed FPS and need a fixed logic rate, run your logic loop in it’s own thread, and it can push out the ‘latest update’ to the render thread after every new logic frame.
Of course, if you can limit FPS to a certain value (60 is the correct value :P) then that’s what you should do.
Yep, in fact not just entities, but anything that runs off the update(), aka isn’t rendering.
But you can put both in one loop (thread) if you just limit the FPS, and that is the recommended way.
Yeah, I could limit it to 60. But what if people want to play at higher fps, should I just like add a setting in the game’s config like "max-fps: ", and put a comment above it that says it could break things?
Yeah, [icode]count % n == 0[/icode] works fine too, and then you don’t have to reset to zero. (actually better since it calls update() on frame 0)
Only if the render rate is faster than the logic rate.
EDIT: That made more sense in my head. Whichever call is in the if statement is the one which will be slower. So if logic is to be 30, and fps is 60, then logic should be every other frame.