Application that works with every screen resolution

Previous topic - Next topic

S.O.P.M.

Hello,

until now I wrote games and applications for a fixed screen resolution which is quite easy. But now I want to code something that works dependable on several mobile devices whatever the screen's resolution is. The method to scale each element separately during runtime and calculate each position would be very disagreeable for me. The smartest solution I guess would be to have a virtual screen with a fixed size to draw everything on and resize that image to fit the current screen resolution.

Is there a way to do that (without using 3D commands or Inline C++ of course)?

There must be a smart way to accomplish that otherweise GLBasic is not the easiest programming language. Every todays game can work with different resolutions. The possibility to code such thing should be self-evident :/ It's urgent!

Thanks,
S.O.P.M.
Notebook PC Samsung E372 Core i5 @ 2,6 GHz; 4 GB RAM; Win 7 Home Premium

kanonet

Try CREATESCREEN? +manually calculate mouse positions. Thats my 1st guess, but maybe you just want to use the forum search, cause there are many posts about this.
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64

bigsofty

Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

erico

hello S.O.P.M.

Like people said, that subject has been discussed many times and the forum has a lot to say about it.

In general, I use the solution described by Kanonet.

It should be easy to work it out. I had my game almost complete at 320x240 before I decided to look at the scalling routines for android , and because of that, changed gameplay size to 428x240 (in my case it scales better to target phones) and added needed stuff(read coordenates for touch) and it all works fine so far.

spacefractal

Yes this have been discussed in various post.

There is nostandard solution about this one, which depend on the game. A more issue is cropping and borders with screen ratio. It's simply depend on the game. So better doing that by your self.

In my chases, Karma Mima uses one fixed resolution for engine and scaling it (eventuelly with retina). In some screen ratio, the game scroll a bit up too.

In Greedy mouse, I'm used 3 texture size to buildup the screen for various resoulutions. Im not using offscreen, due it's slowed down to much, but calculate it directly.

Ps. 428x240 is very cool choice and seen fit most screens out today.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

S.O.P.M.

Many thanks for the answers so far. Yes, I was already looking for a solution in the forum and found that "Z Project" but it seems to be very unhandy. So much code only for scaling... and it uses Inline what I don't want.
Ok, then I have to see what I can do O_O
Notebook PC Samsung E372 Core i5 @ 2,6 GHz; 4 GB RAM; Win 7 Home Premium

erico

Try the off screen solution first if it fits your app style. That is a very fast solution to implement.
There is the slowdown side of things, but on my case, it made no difference for my phone or caanoo.

finnk

I create things for one resolution, but I do it using functions which will automatically scale it for whatever resolution. This was my second go at this (first one had animation/scaling/lack of culling problems) and both times it took maybe 2-3 days before I could see stuff working on screen. Had to plan it out before seeing the result.

I'm not very good at explaining what I do and am not familiar with common/official terminology, but I made a video about it a long time ago:

S.O.P.M.

I'll see if I can figure out the CREATESCREEN method. First I call CREATESCREEN then USESCREEN and draw my stuff to that virtual screen. But what then? How can I take the image of the virtual screen, resize it and draw it to the actual screen hm...
Notebook PC Samsung E372 Core i5 @ 2,6 GHz; 4 GB RAM; Win 7 Home Premium

kanonet

Createscreen only at program start, not in every loop! Here an example, assuming your Program window has a resolution of 1024x768 and you want to draw on it like a screen that is 800x600:

Code (glbasic) Select
// at program start:
CREATESCREEN 0, 99, 800,600   // create screen No# 0, bind it to sprite No# 99 and give the screen size 800x600


//In program loop:

USESCREEN 0   // use screen No#

// draw your stuff here, like you would do on a 800x600 screen...

USESCREEN -1   // back to backbuffer now you draw to the real screen again!

STRETCHSPRITE 99, 0,0, 1024,768   // stretch the sprite No#99 (this is screen No#0!) to fit the full backbuffer of 1024x768 pixels

SHOWSCREEN   // finally draw everything


I did just write this here, without testing, so i hope there is no mistake in this.
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64

S.O.P.M.

Thank you so much!! This will help me definitively.
Notebook PC Samsung E372 Core i5 @ 2,6 GHz; 4 GB RAM; Win 7 Home Premium

S.O.P.M.

It works :) On the mobilephone I have to swap width and height for STRECHSPRITE to get a proper image but it's ok.
Notebook PC Samsung E372 Core i5 @ 2,6 GHz; 4 GB RAM; Win 7 Home Premium

MrPlow

Great stuff, really useful info.

I feel more of these essential nuggets should be added by those wishing to help promote GLB to the newer users.
Comp:
Speccy-48k, Speccy-128k, Amigas, PCs

MrPlow

I get my screen text print overlaying on top of the previous screen images...do I need to clean the back image or something?
Comp:
Speccy-48k, Speccy-128k, Amigas, PCs

kanonet

Yes you might need a CLEARSCREEN after you mounted your screen and before you draw on it.
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64