GLBasic forum

Main forum => GLBasic - en => Topic started by: Gary on 2015-Aug-26

Title: Cutting part of a screen out and redrawing in a different position
Post by: Gary on 2015-Aug-26
I am wondering if there is an easy way for GLB to do the following

I have a display that is currently drawn as a single screen of 1024 wide and 1526 high to display over 2 screens within windows. I now need to draw it as a screen 2048 wide and 768 high with the screen that starts at 1024,0 being what was drawn as the top screen.

Can I use my existing draw routine and then create a sprite for each of the halves of the screens and then redraw in the new positions?

its something like this I'm after


current screen layout
----------
-        -
-    x   -
-        -
----------
-        -
-    y   -
-        -
----------

new screen layout
-------------------
-        --       -
-   y    --   x   -
-        --       -
-------------------

Title: Re: Cutting part of a screen out and redrawing in a different position
Post by: Ian Price on 2015-Aug-26
How is the original screen/image constructed - is it one big bitmap or lots of bitmaps that make up the scene or is it tiled?

You can use POLYVECTOR to redraw the part of the screen image that was at the bottom and drawit to the right of the upper part of the image easily. Or Viewport. Or tiles.

Title: Re: Cutting part of a screen out and redrawing in a different position
Post by: Gary on 2015-Aug-27
its a png background with loads of of other pngs laid on top of it
Title: Re: Cutting part of a screen out and redrawing in a different position
Post by: Gary on 2015-Aug-28
I thought something like this would do it

Code: (glbasic) [Select]
GRABSPRITE 301,0,0,1024,768 // grab the top half of the screen
GRABSPRITE 302,0,768,1024,768 // grab the bottom half of the screen
SETSCREEN 2048,768,FALSE // create a screen 2 screens wide and 1 screen high
DRAWSPRITE 301,1024,0 // draw the top half on the right
DRAWSPRITE 302,0,0 //draw the bottom half on the left

it kind of works but it gives the bottom half of the screen on both sides (with a bit of graphics clipping at the top of the left side half) and it is constantly flickering
Title: Re: Cutting part of a screen out and redrawing in a different position
Post by: spacefractal on 2015-Aug-28
im thinks SDL not supporting this correctly?
Title: Re: Cutting part of a screen out and redrawing in a different position
Post by: Gary on 2015-Aug-28
I took out the setscreen and that removed the flickering, I now set that at start up depending on a flag at build time.

I am rendering everything to a sprite set as screen 1 (sprite number 70) so that I can resize it depending on the output screen size. I have checked that the sprite is being generated properly by using savesprite and it is as per the attached image

This is only going to run on a windows based computer so I know GRABSPRITE does not work on some mobile platforms

Looks like I might have to rewrite all the draw routines if SDL is broken :(

Thanks for the advice

Title: Re: Cutting part of a screen out and redrawing in a different position
Post by: Gary on 2015-Aug-28
this is what is actually displaying now, the right side is being animated properly but the left side for some reason is staying static and also its showing the wrong artwork (reel symbols are different to the right side ones)
Title: Re: Cutting part of a screen out and redrawing in a different position
Post by: Gary on 2015-Aug-28
scrap that. its me forgetting my code from 4 years ago

incase anyone else has a similar issue then this worked for me

Code: (glbasic) [Select]
USESCREEN 1
DRAWSPRITE 70,0,0
GRABSPRITE 801,0,-768,1024,768
GRABSPRITE 802,0,0,1024,768
USESCREEN 2
DRAWSPRITE 801,1024,0
DRAWSPRITE 802,0,0
USESCREEN -1
DRAWSPRITE 999,0,0

with the following set up for the 2 screens

CREATESCREEN 2,999,2048,768
CREATESCREEN 1,70,1024,1536