Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
HW image version of this little stupid thing
#33
(09-13-2023, 03:14 AM)SMcNeill Wrote: Run the above and notice what screen mode our program is in...   then look at the code a little closer...

We're in a SCREEN 0, text-only screen mode, and yet we're still displaying and animating a graphical box across the screen pixel by pixel!!

How the BLEEP is that possible??

It's because QB64 has a completely separate and independent hardware layer, than it has for any of the software layers.  SCREEN 0 is software.  HWscreen is hardware.   The two are 100% independent from each other.

Hardware layers are always the size of the visible screen (640 x 400 pixels in this case), and are always 32-bit color screens.  It doesn't matter if you _COPYIMAGE a 256-color screen into a hardware image, it's automatically converted up to 32-bit colors.  Draw on whatever software screen which you prefer; when you're ready to turn it into a hardware image, just call _COPYIMAGE and let it automatically handle the conversion for you.

Whoa...

OK So..you said that we can use a 256 color image and `_COPYIMAGE` that to a hardware image, except that it didn't work for me...

To get my 256 color image onto a hardware layer I had to:
  1. Create the 256 color image
  2. Copy the 256 color image to a 32 bit image
  3. Copy the 32 bit image to a 33 mode image
Or maybe it does work as you say but the colors of the 256 image for me were all black when I did not do step 2 in-between to get 32->33 ... ?

See below, this does not crash but only renders black. I used the code we were discussing in discord to test and just changed one line (line 35):

`ALIEN_HW& = _COPYIMAGE(ALIEN_32&, 32)` -> `ALIEN_HW& = _COPYIMAGE(ALIEN_SPRITE&, 33)`


Code: (Select All)

OPTION _EXPLICIT

DIM AS INTEGER lim, st, x, y, w, h
DIM AS SINGLE d
DIM AS STRING FGC, BGC, T, M, B, F, ALIEN
DIM AS LONG ALIEN_SPRITE, ALIEN_32, ALIEN_HW, CANVAS

CANVAS& = _NEWIMAGE(320, 200, 32)
SCREEN CANVAS&
_FULLSCREEN _SQUAREPIXELS

d! = 0
lim% = 60
st% = 3
x% = 0
y% = 10
w% = 50
h% = 50

FGC$ = "12": BGC$ = "8"
T$ = "C" + FGC$ + " R10 E5 R20 F5 R10 BL50"
M$ = "D20 BR50 BU20 D20              BL50"
B$ = "D10 E10 U10 R30 D10 F10 U10    BL50"
F$ = "BU20 BF5 P " + BGC$ + "," + FGC$
ALIEN$ = T$ + M$ + B$ + F$

ALIEN_SPRITE& = _NEWIMAGE(w% + 1, h% + 1, 256)
_DEST ALIEN_SPRITE&
PSET (0, 10)
DRAW ALIEN$
_CLEARCOLOR 0, ALIEN_SPRITE&
ALIEN_32& = _NEWIMAGE(w% + 1, h% + 1, 32)
_SOURCE ALIEN_SPRITE&: _DEST ALIEN_32&: _PUTIMAGE
ALIEN_HW& = _COPYIMAGE(ALIEN_SPRITE&, 33)

_DEST CANVAS&
CLS , _RGB32(0, 0, 255)
DO
    x% = x% + st%
    IF x% <= 0 OR x% >= _WIDTH - w% THEN st% = -st%
    _PUTIMAGE (x%, y%), ALIEN_HW&
    _DISPLAY
    _LIMIT 60
    CLS , _RGB32(0, 0, 255)
LOOP UNTIL _KEYHIT = 27

_FREEIMAGE ALIEN_SPRITE&
_FREEIMAGE ALIEN_HW&

SYSTEM
grymmjack (gj!)
GitHubYouTube | Soundcloud | 16colo.rs
Reply


Messages In This Thread
RE: HW image version of this little stupid thing - by grymmjack - 09-13-2023, 09:07 AM



Users browsing this thread: 9 Guest(s)