Screen scaling on the fly

BlitzMax Forums/BlitzMax Programming/Screen scaling on the fly

Mineth(Posted 2009) [#1]
Hello,

I have a game with a 320x240 screen resolution (due graphic sizes). However, I want to scale the screen twice on the fly (50 FPS) - if it's possible - to 640x480 and draw stuff like the HUD and text on that.

Is it reliably doable with pixmaps or anything alike (maybe other libraries)?

Mineth


ImaginaryHuman(Posted 2009) [#2]
You won't get that speed using pixmaps in realtime.

You could double the size of the pixmaps first, THEN turn them into images and just draw normal images.

Otherwise it gets more complicated - projection matrix, render to texture, etc


TaskMaster(Posted 2009) [#3]
I don't really understand exactly what you are doing? You have graphics that are for a 320x240 screen, but you want it to show as 640x480?

Could you just take your graphics into a paint program (like Gimp) resize them up to double their size and make your game at 640x480?


EOF(Posted 2009) [#4]
You can use SetScale 2.0,2.0 if your graphics are TImages (and not TPixmaps)


GfK(Posted 2009) [#5]
Otherwise it gets more complicated - projection matrix

There are a couple of examples of projection matrices dotted around these forums. They're dead easy to implement.


ImaginaryHuman(Posted 2009) [#6]
It might be `dead easy` using prewritten code but it's not easy for everyone to understand.


GfK(Posted 2009) [#7]
It might be `dead easy` using prewritten code but it's not easy for everyone to understand.
You don't need to understand it. It just works.

If he wants to understand it then he can ask the person who wrote it (which was Yan, I think).


*(Posted 2009) [#8]
why cant you just use LoadImage to load the pixmap then scale it and draw it to screen. You just need to render to top left and then grab it and then scale it and whack it back to the screen


MGE(Posted 2009) [#9]
You'll have to scale each object on the fly. Easy and should have minimal performance hit. Projection matrix would scale the entire screen unless you reallllyyyyy dig in. Just scale each object, should work well.


Ryan Burnside(Posted 2009) [#10]
I planned to do something like this myself some time ago but if you are going the per image scaling route, keep in mind that using scale does not affect your screen coordinate resolution.

This is one problem with the aforementioned method, you have to double or triple your movement code's results to keep in spirit with lower screen resolution. Just because you are drawing at 2x the normal scale does NOT mean that you are using coordinates from that scale size. So what would normally be point (32,32) would now be point (64,64). You have to account for this which is really a pain when you are computing things dynamically or want multiple scale options for a project.

I guess my comment didn't help much but there is certainly no *easy* way to make a convincing low res game. You either have to work with a projection matrix or you have to scale and adjust movement positions so you don't get fractional resolution with drawing. It would be nice to see some code, I'd be interested in it myself.