Scaling from a small resolution to a large resolution

Blitz3D Forums/Blitz3D Programming/Scaling from a small resolution to a large resolution

Kiyoshi(Posted 2017) [#1]
Hey there everyone, I've got a question. I've been working on a simple exploration game, and all is going well. However, there's an effect I'm trying to achieve, and can't figure out how to do it.

Messing around with the code, I tried setting the resolution to 320x240 fullscreen, and I liked how it makes the program look, all pixelated and blurred. Its very reminiscent of an old DOS game I used to play. However, that resolution isn't supported with fullscreen on newer machines; I was using an old laptop at the time. So I figured I'd find a way to work around it.

My question is this: How would I render a scene at 320x240, then efficiently blow up the image to display on a larger resolution (1920x1080)?

Thanks for taking the time to read this,
-Kii


RustyKristi(Posted 2017) [#2]
I think you're looking for virtual resolution, which is available on some blitzmax frameworks.

I have not found any blitz3d equivalent yet but I think doing a search you should be able to get some information or links, or wait for the guys on follow up solution.


RemiD(Posted 2017) [#3]
I already explained a way to achieve what you want :
->create a a "screen mesh" (=rectangle mesh made of 4 vertices 2 triangles) and shape it in a way that it takes the entire screen (you can modify its shape (vertices positions) depending on the resolution chosen by the user)
->create a 512x256 "screen texture" (because a texture must have its width, height with a "power of 2" value (2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192) else there will be distortions)
->set the u,v coords of each vertex so that the screen mesh will only be colored bh the 320x240 area of the texture
->apply the texture on the screen mesh
->each time you render your scene, copyrect the resulting 320x240 image from the backbuffer to the screen texture (from 0,0 to 320,240)
->whatever the graphics window width,height, the screen mesh will stretch the 320x240 texture so that it fills all the area of the cameraviewport...

This will produces what you want...
an example on how to create a screen mesh and a screen texture :
http://www.blitzbasic.com/codearcs/codearcs.php?code=3256

good luck!


Kiyoshi(Posted 2017) [#4]
Thanks for replying, you two.

@RemiD - I've already tried this method. However, no matter how I resize the screen mesh, the pixels always turn out blurred. I want the pixels to be sharp. Is there a way to work around that?


RemiD(Posted 2017) [#5]

the pixels always turn out blurred. I want the pixels to be sharp. Is there a way to work around that?


yes you have to disable the bilinear filtering of textures : http://rd-stuff.fr/disable-bilinear-filtering-of-textures-201612021732.zip

however you understand that the pixels of your initial render will be scaled up and therefore each texel will be made of several pixels...


RemiD(Posted 2017) [#6]
You have to understand the difference between the graphics window width,height, and the area were you draw 3d (after a renderworld, set with cameraviewport) and the area were you draw 2d (after text, drawimage)

So in your case, you want to have a graphics window of the width,height of the desktop or of the width,height that the user choose for fullscreen, and then you want to have "render area" width,height, that is 320width240height, where you render your game and copyrect the resulting image on the "screen texture", and then you want to have a "zoom area" width,height, where you render the "screen mesh", with the wanted cameraviewport, and the appropriate vertices u,v so that the "zoom area" is filled with the textured screen mesh.

Since you can have a "zoom area" width,height, different than the graphics window width,height, and since the initial width,height is 320width240height, i suggest to allow a "zoom area" which keeps this ratio (4/3) to prevent distortions of the texels...


Kiyoshi(Posted 2017) [#7]
Yes, I understand the difference. I'll be keeping the 4:3 aspect ratio by having a zoom area as you suggested. Thank you for your help, I really appreciate it! I'm curious, am I allowed to distribute the .dll you provided above with my program?


RemiD(Posted 2017) [#8]

am I allowed to distribute the .dll you provided above with my program?


@Kiyoshi>>yes (this is not my dll but it was apparently created by "Tom" and distributed for free, see : http://www.blitzbasic.com/Community/posts.php?topic=40848 )