D3D Font Issue is sometime back with fullscreen toggle
jmasterx

I have been rigorously testing my game. A few months ago I fixed an issue that caused font glyphs to disappear when getting the text width. I have noticed that, if I toggle fullscreen then back to windowed at an unreasonable speed, it sometimes messes up my fonts in the same way as before.

I doubt it would ever happen under normal circumstances, but it probably should never happen at all.

Would anyone, especially Trent, have an idea why it might happen under these circumstances. Would there be a way to ensure it never happens, knowing how I solved it last time?

Thanks

Edit:
After trying it some more, it seems that sometimes just casually going fullscreen like normal causes it.

Edit2: Okay, I made it so that after toggling fullscreen, I rest for about half a second and now the problem happens every time. So it is a timing issue and something needs to be locked or something while it does this.

Edit3: Turns out my code for making a thinner border was causing the problem.

  void Display::initContext( DisplayContext* c )
  {
    if(!(al_get_display_flags(context) & ALLEGRO_FULLSCREEN_WINDOW))
    {
#ifdef _WIN32
      HWND win = al_get_win_window_handle(context);
      SetWindowLong(win, GWL_EXSTYLE,  WS_EX_APPWINDOW|WS_EX_WINDOWEDGE);
      al_resize_display(context,getResolution().getX() + 1,getResolution().getY() + 1);
      al_resize_display(context,getResolution().getX() - 1,getResolution().getY() - 1);
#endif
    }
  }

Which gave me an idea for a function:
al_win_set_window_style();

This could allow developers to have more control over their window. Every resizable application I know does not have a thick border, thus I created this function, but it requires me to resync with Allegro in some weird ways, so I will not use it.

Edit4:

Fixed it with:

  void Display::initContext( DisplayContext* c )
  {
    if(!(al_get_display_flags(context) & ALLEGRO_FULLSCREEN_WINDOW))
    {
#ifdef _WIN32
      HWND win = al_get_win_window_handle(context);
      SetWindowLong(win, GWL_EXSTYLE,  WS_EX_APPWINDOW|WS_EX_WINDOWEDGE);
      SetWindowPos(win,NULL,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
#endif
    }
  }

Thread #610172. Printed from Allegro.cc