2
\$\begingroup\$

My aim is to make a simple 2D platformer, the idea is that it will be a base resolution of 480x270 (16:9) which can scale x2, x4(1920x1080) or go full screen.

I basically do:

graphics.PreferredBackBufferWidth = 480; graphics.PreferredBackBufferHeight = 270;

and call methods do double or x4 them and then call graphics.ApplyChanges() which work well, I assume any 1x1 pixels from 1x resolution now appear as 2x2 or 4x4.

However in full screen the image is just stretched to whatever fits, how can I make it "letterboxed"?

\$\endgroup\$
5
  • 1
    \$\begingroup\$ You should check out Monogame.Extended on Github! It has several ViewportAdapters that you can use instead of Monogame's default one that have this functionality baked in. github.com/craftworkgames/Monogame.Extended \$\endgroup\$
    – Pip
    May 30, 2016 at 17:27
  • \$\begingroup\$ I forgot to mention that I am playing around with that too. I am making a BoxingViewportAdapter which works well windowed but full screen it goes back to square. \$\endgroup\$
    – lozzajp
    May 30, 2016 at 17:28
  • \$\begingroup\$ @lozzajp Are you saying you want the BoxingViewportAdapter to be able to have black bars on all sides to keep the image at a perfect 2x / 4x pixel scale? We don't currently have that feature in MonoGame.Extended but I've seen it before and it might be a nice addition. \$\endgroup\$ May 31, 2016 at 11:40
  • \$\begingroup\$ @craftworkgames I think I need to dig deeper and learn more basics then I would love to contribute towards extended. (If you recall my efforts to help with documentation wasn't worth much). For now what exactly is BoxingViewportAdapter suppose to do? From reading the source and docs I find it is suppose to letterbox as I require. It just only works in windowed? \$\endgroup\$
    – lozzajp
    May 31, 2016 at 15:07
  • \$\begingroup\$ If it's not working in full screen, that's a bug and we need to fix it. I would appreciate it if you raised an issue with some code. \$\endgroup\$ May 31, 2016 at 21:09

1 Answer 1

0
\$\begingroup\$

Turns out a MonoGame bug was causing most of my issues, which I (inadvertently) helped fix.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .