screen_init needs dealt with/room transition flicker

Reporter: RobertBColton  |  Status: closed  |  Last Modified: April 25, 2019, 03:14:28 PM

I've already deduplicated screen_redraw in #1311 but screen_init still needs to go that way.

First of all, I'm not even sure the purpose of screen_init when we already have both EnableDrawing and graphicssystem_initialize. It seems like one of these three should just go away.

Second, at the very least screen_init does not need duplicated for all of the graphics systems and can safely be moved to general. First, somebody will have to write a version that calls the user/generic functions to set the drawing state.

Here's some things screen_init does in ENIGMA that GM doesn't do and need fixed too:

  • Drawing color/alpha/other state should NOT be reset on room transition
  • The previous room drawing should not be cleared until the next draw event
  • <
Ok, I made a test case for the room transition issues:

In the test you can just press spacebar to go to the next room. There are actually more issues than just the flicker, we are also unnecessarily and incorrectly resetting the render state (draw color back to white and alpha back to 1.0).

This is what occurs in GM8.1 and GMSv1.4:

  • window appears but room is black for 1 second
  • "hello! 0" appears in the italic font with a reddish transparent coloring
  • Press spacebar and the image stays the same for 1 second
  • "hello! 1" appears in the italic font with a reddish transparent coloring

This is what occurs in ENIGMA master:

  • window does not appear at all for 1 second
  • "hello! 0" appears in the italic font with a reddish transparent coloring
  • Press spacebar and the room goes black for 1 second
  • "hello! 1" appears in the italic font but white and transparent

I know this is not a regression because ENIGMA has had screen_init for a very long time. We just need to stop calling it during a room transition and once at game start.


Even though the transition flicker has been fixed by #1387, this is staying open until the state cleanup happens. There's no need to have screen_init duplicated in each graphics system.

Finally resolved by #1636 where screen_init has been moved to general. All of the render state is general now. Here is the purpose of each of the above functions now (I dislike the mixed naming conventions, but that's a small issue).

  • EnableDrawing: bridge specific initialization of each graphics system (creating Context etc)
  • screen_init: mainly a room transition helper that initializes generic render state common to all of the graphics systems including viewports
  • graphicssystem_initialize: initializes render states that only apply to a specific graphics system (e.g, GL has scissor test disabled by default where d3d9 has it on, so GL uses this to turn it on where d3d9 does nothing)

NOTE: I should mention that D3D9 does not use graphicssystem_initialize as intended because the managed d3d9 does not automatically restore render states after a device reset. D3D9 solves that problem by always explicitly setting these states in its render state flush.

Please sign in to post comments, or you can view this issue on GitHub.