STRETCHSPRITE problem

Previous topic - Next topic

planetm

I'm sure this will be easy for somebody to solve. I was trying to use a routine from elsewhere on the forum to scale my game to run on different resolutions using CREATESCREEN and STRETCHSPRITE, but I can't get it to work correctly when testing on windows.

Here's a quick example:

Code (glbasic) Select
// --------------------------------- //
// Project: testzoom
// Start: Friday, July 06, 2012
// IDE Version: 10.283

// SETSCREEN 800,480,0 //original scale - works fine
// SETSCREEN 1024,768,0 // scaling up - works fine
// SETSCREEN 640,480,0 //scaling down - doesn't work
SETSCREEN 320,240,0 //scaling down - doesn't work

ALLOWESCAPE TRUE
GLOBAL xres,yres
GETSCREENSIZE xres,yres

CREATESCREEN 1,100,800,480

USESCREEN 1
CLEARSCREEN RGB(0,0,255)
DRAWRECT 100,100,600,280,RGB(255,0,0)

USESCREEN -1
CLEARSCREEN RGB(0,0,0)
STRETCHSPRITE 100,0,0,xres,yres

SHOWSCREEN

MOUSEWAIT

END


CREATESCREEN uses 800,480 and this should then be scaled to the screensize using STRETCHSPRITE. It's working for for higher resolutions (e.g. 1024,768), but produces strange results at lower resolutions (e.g. 640,480).

Please could somebody point out the (probably) glaringly obvious mistake!

Thank you.

Gary

640 x 480 is not the same aspect ratio as 800 x 480 so the screen would look squashed. Is that the issue you are seeing?

planetm

I've attached three images showing what I see, it's not related to the aspect ratio. The first image is at 800x480 and looks fine, the other two show how it looks at 640x480 and 320x240.

[attachment deleted by admin]

Slydog

#3
I ran your program at all four resolutions, and all four look fine on my computer.
I don't get the weird cut offs you are experiencing.

Try putting this line right after the 'GETSCREENSIZE' command, to verify it is at least returning the correct values.
(on my setup, they did):
Code (glbasic) Select
DEBUG "res: [" + xres + ", " + yres + "]\n"

[Edit] It's funny on your screen shots that the visible red/blue rectangles are the same ratio as the new screen size vs the 800x480 screen size.  I'm predicting that a new screen size of 400x480 will cut the rectangles directly in half, with the right half of the screen being black.  800x240 will do the same but top to bottom, not left to right.  Still have no idea why tho!
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

Ian Price

I didn't get the cut-offs either - all four resolutions displayed full, if aspect ratially incorrect, images.
I came. I saw. I played.

spacefractal

#5
Which graphics card are you using? Its look like a driver issue, also create screen did not used higher resolutions, then the default resolution and hence it's cutted the rect.

So checkout the resolution used.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

Hemlos

Works fine here.

You might want to try updating your video drivers?

edit:
You beat me to it space :P
Bing ChatGpt is pretty smart :O

Slydog

Quote from: spacefractal on 2012-Jul-06
also create screen did not used higher resolution tan the default resolution and hence it's cutter the rect.

Good point.

Try a 'SAVESPRITE' command right after your 'USESCREEN -1' command to see the sprite GLBasic created.
I'm guessing it should still be 800x480, but only the current screen size area has been written to it, the remainder black, as in your screen shots.
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

MrTAToad

Is the latest version of GLBasic being used ?

planetm

Thanks for all the responses. I am using the latest build of glbasic. I'm glad that the code works for everybody else, so I've not made a silly mistake!

I guess it is a driver issue, I'll look into it. My target platform is android anyway, so I'll keep working at my native resolution and hopefully the scaling code will work when I compile it for Android.

I'll post again if I solve it.