09-13-2023, 03:14 AM
(09-12-2023, 10:58 PM)grymmjack Wrote: It's stunning that the documentation does not have a good example of hardware image use.
@SMcNeill
And a few more questions:
Do hardware images have to be 32bit? If so make sure that gets added to the docs.
I recalled a previous time when I was doing something and @a740g told me how I could still have all the benefits of pixel art and indexed palette (256 colors) but then simply `_PUTIMAGE` the 256 color image to the 32bit canvas, etc.
Mode 33 also needs more prominent mentions I think. It's an odd thing that no one would really consider.
Maybe add a hardware image example in `_COPYIMAGE` and `_PUTIMAGE`, call out mode `33` and also create a separate section in the wiki for hardware images which has SOS tutorials.
Thanks all!
Hardware images are unusual little beasts, just from the fact that they exist wholly inside their own little display layer. With this odd trait in mind, let's take a look at something unusual which we can do:
Code: (Select All)
SCREEN 0 'I'm going to use a text only screen
tempHWscreen = _NEWIMAGE(64, 40, 32)
_DEST tempHWscreen
CLS , &HFFFF0000 'just color that little 64x40 block of screen RED
HWscreen = _COPYIMAGE(tempHWscreen, 33)
_FREEIMAGE tempHWscreen
xdirection = 1: ydirection = 1
DO
CLS
FOR i = 0 TO 16
COLOR i, 8 - INT(i / 2)
PRINT "Screen 0 Colors! This is COLOR "; i, 8 - INT(i / 2)
NEXT
x = x + xdirection: y = y + ydirection
IF x < 0 OR x > 640 THEN xdirection = -xdirection
IF y < 0 OR y > 400 THEN ydirection = -ydirection
_PUTIMAGE (x, y), HWscreen
_DISPLAY
_LIMIT 100
LOOP UNTIL _KEYHIT
SYSTEM
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.