3.10 Handling mode switches

As you might know, Hollywood offers a hotkey to switch between windowed and fullscreen mode. Whenever the user presses ALT+RETURN or COMMAND+RETURN Hollywood will automatically switch modes between windowed and fullscreen. This behaviour is enabled by default. It can be disabled by setting the ModeTag to False in the @DISPLAY preprocessor command.

When using Hollywood's inbuilt display driver, mode switches are handled automatically by Hollywood and there is nothing your script needs to do. This is different with GL Galore. With GL Galore you will have to reinitialize your GL context after a mode switch. This is necessary because the old GL context will be destroyed when Hollywood switches modes. Thus, all current GL states will be lost in a mode switch. This also includes textures and display lists that your script has allocated. After a mode switch your script's GL context will be replaced by a vanilla GL context that is identical to the one your script is started with.

In order to support mode switches with GL Galore, you have to install a listener on the ModeSwitch tag using InstallEventHandler(). Whenever this event handler triggers, you will have to reinitialize your GL context and set all states to the desired values. Normally, you just have to run your initialization code, that sets up your GL context at the beginning of the script, again whenever the ModeSwitch event triggers. If this is too much hassle for you, you can also just disable automatic mode switching.

Please note that it's not necessary to handle mode switches manually in case you're not using the OpenGL API directly. Hardware brushes allocated by GL Galore will be automatically transferred to the new GL context by GL Galore so you don't have to do anything about them. It is only necessary when programming OpenGL directly.


Show TOC