Temporally blocking window resizing.
nshade

Due to a plethora of technical reasons, when my game runs the opening credits in windowed mode, you shouldn't resize the window. To enforce this, I want to make the window not resizable until the game proper starts. However, I can't seem to flip it on and off at will. Actually I can't seem to turn an option off once I evoke it.

here is code to set up the window.

al_set_new_display_flags(ALLEGRO_WINDOWED);
DisplayWidth = 1366;
DisplayHeight = 768;
DISPLAY = al_create_display(DisplayWidth, DisplayHeight);
al_set_window_position(DISPLAY, 0, 0);

and here is when I want to make it resizable later

//Allow for window resize
al_set_new_display_flags(ALLEGRO_WINDOWED | ALLEGRO_RESIZABLE);
al_resize_display(DISPLAY, al_get_display_width(DISPLAY), al_get_display_height(DISPLAY));

should I be using al_resize_display()? How to you impose new display flags on a currently running display?

bamccaig

I think that al_set_new_display_flags is only used to set flags for a display that you're about to create. Since there's no "see also" links for a function to change flags on the fly I'm assuming to accomplish this you'll need to manage multiple "displays". Or else settle for a game that never resizes (which honestly is most of them in my experience anyway).

Destroying and creating a new display will likely have some kind of a "glitch" appearance to the user, but would probably accomplish what you're asking. You'll have to test it on all of your target platforms to see what it looks like, and how reliable it is.

It might be possible to create two displays, and show/hide them as appropriate. However, it sounds like you might need platform specific code to do this. Unless the API has grown since this. And according to that, having multiple displays killed the performance of one of them.

I don't really know what I'm talking about though. :) Just giving you the best advice I can.

Append:

As mentioned, one solution is to never support resizing. Instead, you have an options screen that allows the user to change resolutions, and when the user applies those settings you'd destroy and create a display again. It's normal for this process to be clunky in all games so we're all used to it.

The other thing to discuss is what about the credit screen is preventing you from resizing it the way the game is. I doubt there's a simple solution to it, but you might as well explain what is different about it so that other great minds here (not mine necessarily) can process it.

Edgar Reynaldo

Using the current mechanism, you would have to destroy and re-create the window to change its resizability.

You can probably use SetWindowLong or some such to change the window properties after getting the HWND from allegro.

You can't change the resizability of a display after creating it. Not with allegro anyway.

https://liballeg.org/a5docs/trunk/display.html#al_set_display_flag

Chris Katko

You can't change the resizability of a display after creating it. Not with allegro anyway.

Is there any good reason A5 doesn't support changing configurations of already created windows?

I mean, fixed resolution and color depth makes sense. But say, a window's title? Clearly there's a case for changing that often.

Erin Maus

But say, a window's title? Clearly there's a case for changing that often.

You can, al_set_window_title.

Edgar Reynaldo

Chris catco you're welcome to add the function to change the window property.

::SetWindowLong(hWnd, GWL_STYLE, GetWindowLong(hWnd, GWL_STYLE)&~WS_SIZEBOX);

Chris Katko

You can, al_set_window_title.

You missed the point. I'm talking about generic window settings, not one, specific, hardcoded function.

Chris catco you're welcome to add the function to change the window property.

To Allegro? I may do that.

Thread #617595. Printed from Allegro.cc