Setting widow constraints cross platform?
jmasterx

I'm using Allegro 5.0.4. For my game, which will work for Windows, OSX, and Linux, it will be important for the window never to get any smaller than 320,240.

Is there some way I can use ifdefs and native APU calls to do this myself since Allegro has not yet implemented this feature?

Thanks

J-Gamer

You could have a response to resize events which resizes the screen to 320,240 if it gets smaller trough the bool al_resize_display(ALLEGRO_DISPLAY *display, int width, int height) function.

Example:

if(ev.type==ALLEGRO_DISPLAY_RESIZE)
{
   if(ev.display.width<320 || ev.display.height<240) al_resize_display(ev.display.source,320,240);
}

Tobias Dammers

J-Gamer: Your code would resize the window to 320x240 if the user drags it to 640x230. Not sure if that is desirable - 640x240 would be much more intuitive.

jmasterx

The problem here is the screen can still be resized to smaller then it pops to 320x240.

J-Gamer

J-Gamer: Your code would resize the window to 320x240 if the user drags it to 640x230. Not sure if that is desirable - 640x240 would be much more intuitive.

I wrote that kind of in a hurry... This would be better:

if(ev.type==ALLEGRO_DISPLAY_RESIZE)
{
   if(ev.display.width<320 || ev.display.height<240)
   {
      int new_height = ev.display.height;
      int new_width = ev.display.width;
      if(new_width<320) new_width = 320;
      if(new_height<240) new_height = 240;
      al_resize_display(ev.display.source,new_width,new_height);
   }
}

Better now? >:(

jmasterx said:

The problem here is the screen can still be resized to smaller then it pops to 320x240.

I don't know a fix for that, but I don't see why you would even want the behaviour in the first place.

Thread #608268. Printed from Allegro.cc