Allegro display resolution 4x3. Monitor resolution 16x9. How to make the display not stretch to full screen in fullscreen mode? So that there are indents on the sides of the monitor if the formats do not match.
]]>Here's some simple code I use to make an image fit within a rectangle.
The display takes whatever resolution you set it to. You have to scale / pad the image on the display yourself.
]]>
I use scaling. I just don’t understand how to fit a square image into a rectangular one so that it does not stretch to the full screen. If the resolution is true, then I want to use the resolution passed by the width and height parameters. But my image is stretched to full screen and distorted. I want it to be in the center. So that in full screen there are indents on the sides.
]]>Calculate the scale for the width and height and use the minimum value for your scaling.
]]>Possibly you need to, once the switch to fullscreen mode is made, re-create Allegro's display in the 16:9 monitor's native resolution (or at least 16:9 aspect ratio) and then draw your Allegro 4:3 content centered on the screen and scalled appropriately.
What I think might be happening now is that your 4:3 resolution (used by your Allegro program) is actually supported by your monitor and it is the monitor that does the stretching to fullscreen.
Instead of drawing directly on the Allegro display, try drawing all your Allegro game content on a bitmap (that would be 4:3 in aspect ratio - using al_set_target_bitmap https://www.allegro.cc/manual/5/al_set_target_bitmap) and then once drawing is complete simply draw this bitmap on the Allegro display as is (in case of 4:3 windowed mode) or centered and scalled in case of 16:9 native resolution full screen mode. If this explanation makes sense?
Well, after a few days, I still implemented a mechanism for changing the resolution of the display image.
Here is a demo, and here is the source code.
P.S.Please do not swear::)
]]>Why don't you just check the resolution of the monitor and set your allegro display accordingly using allegro?
]]>
Why don't you just check the resolution of the monitor and set your allegro display accordingly using allegro?
Oh, how could that be? I did not even know that Allegro has its own methods of obtaining information about the monitor. I will take advantage of your offer. Thanks!:)
]]>The docs are your friend.
https://liballeg.org/a5docs/trunk/
https://bitbucket.org/bugsquasher/unofficial-allegro-5-binaries/downloads/Allegro525.chm
]]>It's fine to have an algorithmic solution but have you considered just using your graphics drivers to do it?
In Windows, nVidia (and 99% sure AMD) let you set the scaling mode for lower size resolutions.
For nvidia it's under Adjust Desktop Size and Position.
]]>That would be a solution, Chris, but most people just don't deal with driver configuration (or even know it is possible to) and blame the game because it doesn't look nice.
My engine gets monitor resolution or the window size and the desired resolution, then creates a backbuffer with the desired resolution and scales it properly drawing in the correct position. This code calculates the size and offset while this other is the actual rendering.
]]>To be fair, this is driver dependent behavior. Nothing allegro can do about it but adapt.
]]>