GLBasic forum

Main forum => GLBasic - en => Topic started by: S.O.P.M. on 2013-Sep-02

Title: Application that works with every screen resolution
Post by: S.O.P.M. on 2013-Sep-02
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.
Title: Re: Application that works with every screen resolution
Post by: kanonet on 2013-Sep-02
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.
Title: Re: Application that works with every screen resolution
Post by: bigsofty on 2013-Sep-02
Like this?

http://www.glbasic.com/forum/index.php?topic=7145.0
Title: Re: Application that works with every screen resolution
Post by: erico on 2013-Sep-02
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.
Title: Re: Application that works with every screen resolution
Post by: spacefractal on 2013-Sep-02
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.
Title: Re: Application that works with every screen resolution
Post by: S.O.P.M. on 2013-Sep-03
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
Title: Re: Application that works with every screen resolution
Post by: erico on 2013-Sep-03
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.
Title: Re: Application that works with every screen resolution
Post by: finnk on 2013-Sep-04
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:
Title: Re: Application that works with every screen resolution
Post by: S.O.P.M. on 2013-Sep-04
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...
Title: Re: Application that works with every screen resolution
Post by: kanonet on 2013-Sep-04
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.
Title: Re: Application that works with every screen resolution
Post by: S.O.P.M. on 2013-Sep-04
Thank you so much!! This will help me definitively.
Title: Re: Application that works with every screen resolution
Post by: S.O.P.M. on 2013-Sep-05
It works :) On the mobilephone I have to swap width and height for STRECHSPRITE to get a proper image but it's ok.
Title: Re: Application that works with every screen resolution
Post by: MrPlow on 2013-Sep-06
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.
Title: Re: Application that works with every screen resolution
Post by: MrPlow on 2013-Sep-07
I get my screen text print overlaying on top of the previous screen images...do I need to clean the back image or something?
Title: Re: Application that works with every screen resolution
Post by: kanonet on 2013-Sep-07
Yes you might need a CLEARSCREEN after you mounted your screen and before you draw on it.