Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » A5 / win - minimize display

This thread is locked; no one can reply to it. rss feed Print
A5 / win - minimize display
komons
Member #11,083
June 2009

Hi. I minimize display by ShowWindow( hwnd, SW_MINIMIZE ), and it work but, when I remaximize window, the display is black. Nothing is displaying. Why?

I create display with just ALLEGRO_OPENGL flag. Allegro 5.0.3

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

The back and front buffers have to be resized, so they are probably filled with uninitialized memory or cleared to black.

Does the screen stay black if you redraw and flip the display? There should be an event you can monitor for when the display is resized.

Karadoc ~~
Member #2,749
September 2002
avatar

I had a similar problem. I fixed it like this:

case ALLEGRO_EVENT_DISPLAY_SWITCH_IN:
  dirty = true;
  break;

(dirty my way of signaling that the screen needs to be redrawn.)

-----------

komons
Member #11,083
June 2009

It don't work. It turns out that functions al_get_display_width and al_get_display_height, always return 0, after minimization and restore to oryginal size.

EDIT: I must resize my display when I get ALLEGRO_EVENT_DISPLAY_SWITCH_IN. Now it work.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

That sounds like a bug to me. Shouldn't the window stay the same size whether it is minimized or restored to it's previous size?

Trent Gamblin
Member #261
April 2000
avatar

Windows says windows that are minimized are of 0 size.

jmasterx
Member #11,410
October 2009

I had this problem a while back too. I observed that minimized cause a size of zero, then when restored it was still seen as 0 until I resized it manually. I think the work around I did was to set my game's size to what was reported by al_get_display_... when I got a switched in event.

Trent Gamblin
Member #261
April 2000
avatar

What were you using to determine the size?

jmasterx
Member #11,410
October 2009

I used al_get_display_width and height. Through I think it would be more appropriate if either a resize event was posted after a restore, or that no resize event occurred on minimize. (At least on Windows).

This was the code that was called to change the internal size in the game (what the game used to make calculations) which I called in a switch_in to fix the issue.

  Dimension Allegro5Graphics::getDisplaySize()
  {
    if(al_get_current_display())
    return Dimension(al_get_display_width(
      al_get_current_display()),
      al_get_display_height(al_get_current_display()));
    else
      return Dimension(0,0);
  }

Trent Gamblin
Member #261
April 2000
avatar

Not what I meant. I mean when you restored your window and you saw it as 0, what did you use to see that?

jmasterx
Member #11,410
October 2009

Here is what happened:

Minimize caused a resize event of 0,0 . This set the game to 0,0 too. Then, when I restored I did not receive a resize and therefore the game thought it was 0,0. So there was no way to see that it was 0,0. Allegro was internally correctly updated but did not notify via an event on restore, so the game's logic was still doing 0,0 math even after a restore.

Trent Gamblin
Member #261
April 2000
avatar

Ok I see. Maybe we should have maximize/minimize or iconify/deiconify (same diff) events.

jmasterx
Member #11,410
October 2009

That could work. They could be display events and therefore have the resolution in the event. If that is done, then I think that a resize event should not be sent on minimize (if that is still how 5.0.3 does it). This would allow the user to have control over this if they need it. (Unless asking the user to acknowledge is necessary in which case a resize event could be sent after minimize and restore).

Trent Gamblin
Member #261
April 2000
avatar

Unless it makes more sense to just add a resize event for the restore but then you'd want to acknowledge it and what would that do? Kind of complicates things. Well one argument for getting rid of the resize event on minimize is that we're telling the game to render to a 0x0 window which doesn't really make sense... I wonder what other platforms do on minimize/restore though.

Go to: