When using al_set_new_display_flags(ALLEGRO_RESIZABLE), is there a way to do the following:

1) Have a program detect the size of the window as it's being manually changed by the player using the mouse. I understand the actual created display size remains the same, but would like to change certain objects size and position for collision detection to work correctly between the mouse pointer and those objects after the window has been resized by the player, otherwise the collision detection between the mouse pointer and those objects remains in the same position relative to the initially created display, whilst the graphics change size and position as the display window size is manually adjusted. In other words the collision detection happens in the wrong visual place on screen.

2) After initializing al_set_new_display_flags(ALLEGRO_RESIZABLE) and creating the display, is there a way to program the window display size as opposed to the player adjusting it using the mouse. It's just that if a player adjusts the window size, then switches into fullscreen, and then back to resizable, I'd like to know what the previous resizable size was so I can set it back to that size, rather than it be initiated at the actual created display size.

Part of My Next Entry Quoted Below, Which I can't Edit Now, Is BALONEY

which I guess is essential, as if a player manually changed the window size in this way during play and the created display al_create_display(WIDTH, HEIGHT) was to change also, then the game/programming would crash.

So far I've found resizing the window with the mouse (whilst playing the game) when using ALLEGRO_RESIZABLE only shrinks or expands the graphics, which I guess is essential, as if a player manually changed the window size in this way during play and the created display al_create_display(WIDTH, HEIGHT) was to change also, then the game/programming would crash.

So what I'm finding (during play) is that even though the graphics shrink and expand as they should when using the mouse to adjust the window size, the mouse pointer collision detection isn't aligned with the graphics because the mouse pointer still references the created display al_create_display(WIDTH, HEIGHT) which understandably doesn't change as the window is resized. To describe this, if the window gets smaller the collision detection happens to the right of the objects as graphically they are displayed more to the left (the window shrinks along with the displayed graphics within it, but al_create_display(WIDTH, HEIGHT) stays the same). Similarly if the window gets larger the collision detection happens to the left of the objects.

I'm guessing now the features which I'm after don't exist within ALLEGRO. Please note this does not stop my main game from playing at all, but just messes up the various stages where I need to have the mouse effectively click on certain button images.

If access to the ALLEGRO_RESIZABLE window were available as parameters Width and Height, then I guess there would be various ways to compensate. For example if the window was made smaller, the int x = al_get_mouse_state_axis(&state, 0) could be increased proportionally to the window getting smaller effectively making int x collision detect correctly relative to al_create_display(WIDTH, HEIGHT).

With regards to my initial post where I suggested changing the size and positions of various objects, I'm now thinking that would only work if there was a second copy of the objects, one unchanged for the graphics (ALLEGRO_RESIZABLE), and one which does change proportionally to the resized window.

I think the easiest way (because of less work to do) might be the first way, adding or subtracting to the x = al_get_mouse_state_axis(&state, 0) values.

So it seems that for my question 1) I need access to the ALLEGRO_RESIABLE manually adjusted window width and height in the form of parameters, to work with within my programming, and for my question 2) I guess this also is not possible for me to do.

What I find strange too is that you're saying changing the window size affects the mouse position returned, which should not be since mouse starts at top left (0,0).

Is there a way you could either send your game src or make an example that demonstrates the problem. There might just be something simple you need to do.

Also, are you just upscaling your content? Because in that case, the mouse and gui positions won't line up, you'd have to transform your mouse position. I have code for that in my gui api if you need it.

Are you saying if you have an object exactly in the middle of the display which can be collision detected with the mouse pointer, that when in ALLEGRO_RESIZABLE if you manually resize the window (using the mouse) to approximately half the size whilst playing, that your object which is now half the size and still in the middle of the display (like it is for me), still has the collision detection with the mouse pointer working correctly, both being aligned.

For me changing the window size does not affect the mouse position returned. If it did so proportionally to the window size being changed as I've described, that might be the perfect solution.

I've rewritten some of my last post to try and make it a bit clearer, as some of it was not good.

It's not about changing the mouse position but changing the button position. When you scale your graphics your button rectangle changes. My GUI mouse stuff works fine with al_resize_display and with ALLEGRO_EVENT_DISPLAY_RESIZE. Try and show us example code that doesn't work. You can use <code></code> tags.

I'm only doing the following so far. I must be missing something by the looks of it. It's doing something but I need to figure it out. I'm not yet using "ALLEGRO_EVENT_DISPLAY_RESIZE". Do I need to add that in. I'll keep at it.

Now I'm thinking the internal buffer was luckily resizing itself anyway ("internal buffer might not resize itself") without calling the following, and that the buffer resizing hasn't actually been the problem.

I just want to point out once again for anybody new to this thread, that all graphics and all collision detection (apart from mouse), and so therefore the main part of my game all resize and work perfectly. It's only collision detection between the Mouse Pointer and the Various Objects as previously described that are the problem

I've changed it to use al_wait_for_event() but it's still the same. A massive thank you for all your support. It's beer O'Clock for me now

EDIT: Just to clarify can somebody please comment/confirm on the following that I posted earlier in this post:

"Are you saying if you have an object exactly in the middle of the display which can be collision detected with the mouse pointer, that when in ALLEGRO_RESIZABLE if you manually resize the window (using the mouse) to approximately half the size whilst playing, that your object which is now half the size and still in the middle of the display (like it is for me), still has the collision detection with the mouse pointer working correctly, both being aligned." END OF EDIT

I don't know why but that tickled me quite a lot another beer or two and I'll be cross eyed.

Seriously apart from the mouse collision detection problem, ALLEGRO_RESIZABLE works really great and I think it's a really cool feature. I can play my game perfectly, literally any size down to a large postage stamp size.

It's only on screens where the mouse is used to select objects that the issue arises. I could perhaps disable ALLEGRO_RESIZABLE for those screens, but I was hoping for a more complete solution.

EDIT: I'll upload a very short video clip when I get back from work in about 8 to 9 hours from now, showing how the game works perfectly in resizable mode apart from the mouse collision detection on certain screens.

Video Link Description: Mouse pointer collision detection misalignment which is not all that surprising, but is there a way to obtain the changing windows width and height to feed into my program so I can compensate.

Video Link Description: Mouse pointer collision detection misalignment which is not all that surprising, but is there a way to obtain the changing windows width and height to feed into my program so I can compensate.

When you acknowledge the resize event, the al_get_display_* functions should return the actual size of the backbuffer if I am not mistaken, and jmasterx seems to confirm this (and he is a much more trustable source )

I guess you should use that to transfom mouse input accordingly.

It is unlikely that Google shares your distaste for capitalism. - DerezoIf one had the eternity of time, one would do things later. - Johan Halmén

IIRC, Edgar Reynaldo had a system where the button coordinates were a percentage of the screen dimensions.

And you'll get to do it all over again if you switch to OpenGL.

“Throughout history, poverty is the normal condition of man. Advances which permit this norm to be exceeded — here and there, now and then — are the work of an extremely small minority, frequently despised, often condemned, and almost always opposed by all right-thinking people. Whenever this tiny minority is kept from creating, or (as sometimes happens) is driven out of a society, the people then slip back into abject poverty. This is known as "bad luck.”