Hi,
You can handle the minimize event and just wait for the restore event.
That does not work because if a window moves over my window the same thing happens. It does not have to be minimized.
Although you may not need to actually do this if there is a better method,
you could try to run a phase locked loop (PLL).
Basically, you measure or calculate the approximate expected period
of the synchronising signal P, and change your algorithm so you only
call SDL_GL_SwapWindow() at time P - E where E is suitably small,
eg 10% of P.
By keeping the timer running, you will measure E’, the time waiting
for SDL_GL_SwapWindow() to return, and if E’ is close to zero,
something is wrong!
So (a) you can ensure you don’t hog the CPU by using a timer to schedule
the Swap call, and (b) you can detect when the signal is abnormal.
Abnormal might not be “window minimised or covered up”: it might
be a resolution change or anything else (dog ate monitor cable …)
This technique is quite general, it can be used to synchronise with
any external periodic event. In my case it was used to synchronise
with mains Alternating Current to control the intensity of lights.
It is also used to lock onto radio signals (Super-heterodyne circuit
I think).
PLL should be used in professional games = simulations to ensure a constant framerate.
To my knowledge it isn’t. Games are a bit tricky because load varies suddenly,
so PLL needs to be combined with load prediction. If you have a sudden change
(a big explosion or whatever) it should be rendered with minimal quality first,
the load measured and the quality pushed up until the load is just enough
to fit in the frame time.
The usual way to handle this problem in simulations is to throw huge amounts
of money at the simulator … hence the small difference between Microsoft
Flight Simulator and an passenger aircraft simulator.
Just for fun: I recall some years ago seeing one of the first 3D movies made,
shown on an IMax screen. This was real footage taken on the International
Space Station. At the beginning a satellite is being deployed an there’s
an accident and the astronaut goes flying off into space, a-la 2001…
Yea, its real footage alright … real footage of a simulated accident.
Later the real footage of the actual deployment including docking of
the space shuttle is shown. [The point: the simulation was itself 3D and
indistinguishable from the real thing … well it fooled me anyhow :]On 06/03/2011, at 6:14 AM, Armin Ronacher wrote:
On 3/5/11 7:11 PM, Sam Lantinga wrote:
–
john skaller
@john_skaller