GLBasic forum

Other languages => GLBasic - de => Topic started by: LukasOK on 2015-Dec-18

Title: Bild stretchen oder vergrößern?
Post by: LukasOK on 2015-Dec-18
Hallo,  =D

Ich möchte noch eine kleine Frage stellen,
Ich versuche (Mobil(z.B.: Handys)) ein Spiel zu strecken oder vielleicht sogar zu verkleinern so halt dem Bildschirm des Gerätes entsprechend. (Das überall das gleiche Bild in der gleichen Größe angezeigt wird.)

Ich hoffe Ihr wisst was ich meine ich versuch es mal in einer Beispiel Skizze zu beschreiben.
(*Das sollten Handys sein(im Bild))
Title: Re: Bild stretchen oder vergrößern?
Post by: Ian Price on 2015-Dec-19
In GLB V14 you can use the command PRESCALER to scale your screen to the desktop size of the device with limited CPU overheads, although I haven't tried this yet myself.
Title: Re: Bild stretchen oder vergrößern?
Post by: spacefractal on 2015-Dec-19
PRESCALER might not work on all platform yet. Alternative you can use CREATESCREEN and USESCREEN as well POLYVECTOR to do the same.

The biggest problem is not scaling, but more screen ratio.
Title: Re: Bild stretchen oder vergrößern?
Post by: LukasOK on 2015-Dec-19
Und wie genau wende ich das an?
Wo soll ich das den setzten?
Title: Re: Bild stretchen oder vergrößern?
Post by: Ian Price on 2015-Dec-20
Look at the PRESCALER example - you use the command once at the start-ish of your progam.


For the POLYVECTOR solution you need to use a virtual screen (use CREATESCREEN to initially set a screen up and USESCREEN to draw your game to every frame) then use the POLYVECTOR to scale and display it to your required dimensions every frame. This solution can be very slow (still real-time), but it depends on how it's used.
Title: Re: Bild stretchen oder vergrößern?
Post by: LukasOK on 2015-Dec-22
And Showscreen?
Can you perhaps a project/CODE send
how do you mean?
Title: Re: Bild stretchen oder vergrößern?
Post by: Kitty Hello on 2015-Dec-23
Prescaler 320,200

While true
Print "scaled",0,0
Showscreen
Wend


Man lernt am Besten in dem man es einfach mal PROBIERT.
Title: Re: Bild stretchen oder vergrößern?
Post by: Schranz0r on 2015-Dec-25
Prescaler 320,200

While true
Print "scaled",0,0
Showscreen
Wend


Man lernt am Besten in dem man es einfach mal PROBIERT.

True Story!
Title: Re: Bild stretchen oder vergrößern?
Post by: LukasOK on 2015-Dec-26
ok es funktioniert soweit aber mit anderen Bildschirmauflösungen nicht, die Größe ist die gleiche aber zum Bespiel Texte verschieben sich aber nach Fenster des Bildschirms zum Beispiel: Ein Text unten ist, verschiebt er sich das nur noch ein halber Text zusehen ist.
Wie soll man das machen?
Title: Re: Bild stretchen oder vergrößern?
Post by: Kitty Hello on 2015-Dec-26
Poste mal Code zum Problem. Ich verstehe es nicht.
Title: Re: Bild stretchen oder vergrößern?
Post by: LukasOK on 2015-Dec-28
Da gibt es leider nicht viel zu posten  ;)
Es hat ja eigentlich super sofort funktioniert.
Der scheiden Teil ist ja eigentlich der:

Prescaler 800,480

While True
Showscreen
Wend


Ich versuch es mal mit Paint(Bilder) zu erklären :D
Also das er es unten Abscheidet ist mit dem bild vielleicht besser als mit einem Text.
Title: Re: Bild stretchen oder vergrößern?
Post by: Ian Price on 2015-Dec-28
PRESCALER doesn't work correctly with screens smaller than the original (<1.0) - so you would need to work out which is the best original resolution to scale up to the most devices.
Title: Re: Bild stretchen oder vergrößern?
Post by: Marmor on 2015-Dec-28
ich finde scalierte bilder nicht toll und würde versuchen die meisten auflösungen mit bildern passend zur screengrösse abzudecken.


Bin ich der einzige der plötzlich an sex denken musste ?
Title: Re: Bild stretchen oder vergrößern?
Post by: Ian Price on 2015-Dec-28
Scaling is never going to fit all circumstances. Sometimes it's better to use different sized assets based on device resolution. There is no "one size fits all"

As for the second statement - umm... dirty minds? ;) :P
Title: Re: Bild stretchen oder vergrößern?
Post by: LukasOK on 2015-Dec-29
how do you mean?
Do you have an example?
Title: Re: Bild stretchen oder vergrößern?
Post by: spacefractal on 2015-Dec-29
Its very depend on the game and how to deal. There is various methods doing that. The screen ratio is also the main issue.

- in Greedy Mouse did not suffer the issue and just scaled to uses around 12-13 tiles across, and then fill out the screen.
- In Karma Miwa, there was various screen ratio issues and quite annoying here. So here im did some camera panning to make sure its was playable on a 4:3 screen as well on a 16:9 screen.
- Alternative you could also add a Super Gameboy like border around the playfield and just use one scaling. This is seen in example Snake Slider for iOS and also works pretty nice in that game.

Im thinks its the last option you want to do. Until then checkout the code im gave in the codesnippet as well PRESCALER.

Also PRESCALER might not DOWNSCALING correctly? Its was more designed to UPSCALING graphics, also best for retro games.
Title: Re: Bild stretchen oder vergrößern?
Post by: LukasOK on 2015-Dec-29
Then what is probably best for smartphones?
Title: Re: Bild stretchen oder vergrößern?
Post by: Ian Price on 2015-Dec-30
The "Prescaler" option can't cope with screens smaller than you initially state in project options.
The virtual scaling solution causes slow-down and like all scaling systems, can look nasty when scaled too high up or down. This will be true of the "prescaler" option too.

You may need a number of sets of assets (graphics) to cope with different sized screens - eg small assets for small screens (phones) and huge assets for tablets with retina displays. Not only do you have to recreate the images for these resolutions, you also have to ensure that your code adapts to positioning these assets.

So you get to choose - easy work, but possibly messy results or perfect results but with an awful lot more work involved. Of course you can meet the options somewhere in-between...
Title: Re: Bild stretchen oder vergrößern?
Post by: LukasOK on 2016-Jan-01
Englisch/English:
I know that there is more work but I find it nice when everything is the same size.
But how do I do that?

Deutsch/German:
ich weiß dass es mehr arbeit wird ich find es aber schöner wenn alles die gleiche größe hat.
Aber wie mache ich das?
Title: Re: Bild stretchen oder vergrößern?
Post by: Ian Price on 2016-Jan-01
Here's a rundown of what you would do to create a virtual screen scaling system.

Firstly you have to get the screen resolution of your target device with GETDESKTOPSIZE w,h

Then you need to work out what the maximum size of your game (maintaining aspect raitio) based on the device resolution and your game screen. Eg if your game screen is 320x240 and your target device is 640x480 then you can scale your game screen by 2 (2x320=640, 2x240=480). If the device resoolution is 800x480 (2x320=640, leaving an empty space of 160 pixels), then you still scale by 2, but have black borders where there is no gamescreen.

Here's a short example of how to create a virtual screen and scale it.

Code: GLBasic [Select]
GLOBAL scale%=2
GLOBAL game_width%=320
GLOBAL game_height%=240

// Create a virtual screen
CREATESCREEN 1,999,game_width, game_height

SETSCREEN 1024,768,0

// Repeat until ESC pressed
WHILE TRUE

// Draw stuff to the virtual screen
USESCREEN 1

 PRINT "PRESS SPACE",20,20

 // Press SPACE to create new image
 IF KEY(57)

  FOR n=0 TO 50
   DRAWRECT RND(320),RND(240),RND(64),RND(64),RGB(RND(255),RND(255), RND(255))
  NEXT
 
 ENDIF
 
// All drawing now done on the main screen
USESCREEN -1
 
 SMOOTHSHADING FALSE
 
 STARTPOLY 999
  POLYVECTOR game_width*scale,0, game_width,0
  POLYVECTOR 0,0, 0,0
  POLYVECTOR 0,game_height*scale, 0,game_height
  POLYVECTOR game_width*scale,game_height*scale, game_width,game_height
 ENDPOLY


 DRAWSPRITE 999,650,10
 
SHOWSCREEN

WEND
 


Change the "scale" value to make the scled image larger/smaller. Change the game_width and game_height to make the game screen larger/smaller.

You can add an OFFSET value in the POLYVECTOR section to have your screen in the middle of a larger screen if required.

Hope that helps. :)
Title: Re: Bild stretchen oder vergrößern?
Post by: LukasOK on 2016-Jan-03
Englisch/English
Do not be 2 Details?
Normal size and screen size?

Deutsch/german
Muss es nicht 2 Angaben geben?
Normale größe und Bildschirm größe?
Title: Re: Bild stretchen oder vergrößern?
Post by: Ian Price on 2016-Jan-03
Eh?

Are you asking why there are two screens being shown? That's to demonstrate that the larger, scaled version is based on the small original version.

I haven't taken into account the actual screen-size (desktop size) in that demo. I don't know what your original game screen size is or your desktop size. I thought that was enough to show you how to scale a POLYVECTOR virtual screen.

If that's not what you're asking then you need to rephrase, I'm afraid.