Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
OMG! OMG! OMG! I found QB64's lost HOLY GRAIL!!
#14
Quote:And since forever and ever and ever ago, I have asked everyone from users to devs to my local priest, *HOW THE BLEEP DO WE USE HARDWARE1*???
I remember answering a few times.

Since my posting rate is bimonthly, I checked every post I ever made ever. 

Here's me telling you about it in 2018:

Quote:Set the destination for a hardware image to 1 and it will be displayed on that screen, I think. I don't remember anything else
https://qb64forum.alephc.xyz/index.php?t...54#msg4354

and how to use it from 2020:

Quote:Most graphic/text commands have to be done on the software layer, so I think it's just there for when you need to sandwich those between hardware images
https://qb64forum.alephc.xyz/index.php?t...#msg121275

Looks like each post was one line long, so maybe not too useful. Now I have a few HARDWARE versions of SOFTWARE graphic commands to handle drawing on the HARDWARE layers

First, I create a palette map: this one is 16 shades of Red, Green, and Blue with full alpha because it was created for transparent gradient overlays:

Code: (Select All)
Sub LoadGradient

    Dim R As _Unsigned _Byte
    Dim G As _Unsigned _Byte
    Dim B As _Unsigned _Byte
    Dim A As _Unsigned _Byte


'Sets image dimensions to store colors. Square root of R*G*B*A. (16*16*16*256)
    ysize = 1024
    xsize = 1024

    Pal = _NewImage(xsize, ysize, 32)
    Dim m As _MEM
    m = _MemImage(Pal)

    _Dest Pal


    For y = 0 To ysize - 256 Step 256

        For x = 0 To xsize - 1

      

'Gradient layout: R changes every pixel, G every 16th pixel, B every 256th pixel,so (0 to 15,0,0), (0 to 15,1,0),(0 to 15,2,0)...(0 to 15, 15, 15)

            R = (x * 17)
            G = (Int(x / 16) Mod 16) * 17
            B = (Int(x / 256) + Int((4 * y) / 256)) * 17




            For h = 255 To 0 Step -1

'You have to place the transparent colors with MEM. If you use PSET, they'll blend with black

                          _MemPut m, m.OFFSET + (x * 4) + ((255 + y - h) * ((xsize) * 4)), _RGBA32(R, G, B, h) As _UNSIGNED LONG
            Next h

        Next x

    Next y


'Part of a global variable that holds all of the gradient data
    Gradient.Image = _CopyImage(Pal, 33)

    _FreeImage Pal



End Sub
Then I can stretch a column over the entire screen  with _Putimage for the gradient overlay effect, or stretch a single pixel to draw filled boxes and use as a replacement for LINE BF.

Code: (Select All)
Sub HDBox (x1, y1, x2, y2, R, G, B, A)


    If A <= 0 Then Exit Sub
    If A > 255 Then A = 255


    'only 16 shades of R, G and B respectively, so those values have to be between 0 and 15. Then it picks out the correct pixel based on the gradients layout

    x = Int(R + 16 * G + 256 * (B Mod 4))
    y = Int((256 - A) + 256 * (Int(B / 4) Mod 4))


  'Draws to HARDWARE1

    _PutImage (x1, y1)-(x2 , y2 ), Gradient.Image, 1, (x, y)-(x, y)


End Sub
Added a few comments and removed unnecessary code so that it's hopefully easy to follow even if they can't be run as is.



[Image: gradient.png]


For text I've recently taken to copying it to a HARDWARE image and then pasting that on HARDWARE1. If I try copying and freeing images every frame then the program crashes, so for now my text command keeps track of what string it has and only copies/frees once.
Reply


Messages In This Thread
RE: OMG! OMG! OMG! I found QB64's lost HOLY GRAIL!! - by Gets - Yesterday, 05:39 PM



Users browsing this thread: 4 Guest(s)