Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PCOPY use with hardware and software images
#1
I'm adding image layers to the library I'm working on. At first I was going to create an image array of multiple screens, draw each individual image to its designated screen (layer) then combine the images together.

TYPE TYPE_SCREENDB
    Image AS LONG
    ClearColor AS _UNSINGED LONG
    ...
    ... Yada, yada yada
    ....
END TYPE

REDIM ScreenDB(0) AS TYPE_SCREENDB

But I got to thinking, QB64 already does all the heavy lifting through the PCOPY statement. So I wrote the little test program below to see how this would work and to my my surprise hardware and software images are preserved and copied ... with a few quirks I'm having a hard time wrapping my head around.

On line 17 I draw a software sprite onto page 0 (the display page). Why is that image not preserved in the loop that follows?

On lines 37 and 38 I draw another software sprite onto page 0 which works. However, if I move these two lines of code to just under the _LIMIT 30 statement the image no longer appears.

At first I thought that perhaps pages 1 and 2 (and above) were not retaining the default _RGBA(0,0,0,0) transparent black color. But that can't be the case since line 30, PCOPY 2,0 , does not wipe out the previous PCOPY 1,0 in line 26 above it.

Does anyone have any insight as to why software images are not persisting as they should?

Code: (Select All)
DIM Sprite AS LONG '  software sprite
DIM HWSprite AS LONG ' hardware sprite

Sprite = _NEWIMAGE(64, 64, 32) '        software sprite
_DEST Sprite '                          draw on software sprite
CIRCLE (31, 31), 31
HWSprite = _COPYIMAGE(Sprite, 33) '      create hardware sprite

SCREEN _NEWIMAGE(640, 480, 32)

' ------------------------------------------------------------
'| Why is this software image not preserved in the loop below |
'| unless I draw it on the last page copied?                  |
' ------------------------------------------------------------

'SCREEN , , 2, 0 '                        draw on page 2 (only when this line active works?)
_PUTIMAGE (300, 300), Sprite '          draw software sprite

' ------------------------------------------------------------

DO
    _LIMIT 30 '                          30 FPS

    SCREEN , , 1, 0 '                    active page 1, display page 0
    _PUTIMAGE (100, 100), HWSprite '    draw hardware sprite on page 1
    PCOPY 1, 0 '                        copy page 1 to page 0

    SCREEN , , 2, 0 '                    active page 2, display page 0
    _PUTIMAGE (200, 200), HWSprite '    draw hardware sprite on page 2
    PCOPY 2, 0 '                        copy page 2 to page 0

    ' ----------------------------------------------------------------------
    '| Why do I need to draw software images last? When the two lines below |
    '| are moved under _LIMIT 30 above the software image is not seen?      |
    ' ----------------------------------------------------------------------

    SCREEN , , 0, 0 '                    active page 0, display page 0
    _PUTIMAGE (220, 220), Sprite '      draw software sprite

    ' ---------------------------------------------------------------------

    _DISPLAY '                          update screen with changes
LOOP UNTIL _KEYDOWN(27)
SYSTEM
New to QB64pe? Visit the QB64 tutorial to get started.
QB64 Tutorial
Reply


Messages In This Thread
PCOPY use with hardware and software images - by TerryRitchie - 08-13-2024, 05:07 PM



Users browsing this thread: 1 Guest(s)