Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Setting widow constraints cross platform?

This thread is locked; no one can reply to it. rss feed Print
Setting widow constraints cross platform?
jmasterx
Member #11,410
October 2009

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
Member #12,491
January 2011
avatar

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);
}

" There are plenty of wonderful ideas in The Bible, but God isn't one of them." - Derezo
"If your body was a business, thought would be like micro-management and emotions would be like macro-management. If you primarily live your life with emotions, then you are prone to error on the details. If you over-think things all the time you tend to lose scope of priorities." - Mark Oates

Tobias Dammers
Member #2,604
August 2002
avatar

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.

---
Me make music: Triofobie
---
"We need Tobias and his awesome trombone, too." - Johan Halmén

jmasterx
Member #11,410
October 2009

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

J-Gamer
Member #12,491
January 2011
avatar

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.

" There are plenty of wonderful ideas in The Bible, but God isn't one of them." - Derezo
"If your body was a business, thought would be like micro-management and emotions would be like macro-management. If you primarily live your life with emotions, then you are prone to error on the details. If you over-think things all the time you tend to lose scope of priorities." - Mark Oates

Go to: