Author Topic: Cutting part of a screen out and redrawing in a different position  (Read 2547 times)

Offline Gary

  • Dr. Type
  • ****
  • Posts: 313
    • View Profile
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   -
-        --       -
-------------------


Offline Ian Price

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 4143
  • On the shoulders of giants.
    • View Profile
    • My Apps
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.

I came. I saw. I played.

Offline Gary

  • Dr. Type
  • ****
  • Posts: 313
    • View Profile
its a png background with loads of of other pngs laid on top of it

Offline Gary

  • Dr. Type
  • ****
  • Posts: 313
    • View Profile
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

Offline spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3604
    • View Profile
    • Space Fractal
im thinks SDL not supporting this correctly?
Greedy Mouse - Karma Miwa - Spot Race - CatchOut - Android Extras - is on a vacation trip, home before end of few days in jan.

Offline Gary

  • Dr. Type
  • ****
  • Posts: 313
    • View Profile
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


Offline Gary

  • Dr. Type
  • ****
  • Posts: 313
    • View Profile
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)

Offline Gary

  • Dr. Type
  • ****
  • Posts: 313
    • View Profile
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