Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Hardware images...Talk to me!
#1
How do i use them? Can i use MAPTRIANGLE with them? Does the screen need to be in a special mode? Etc... any guidance would be great as all I get is errors!

Thanks

John
Reply
#2
There was discussion of hardware Steve and Pete? just try a search on Hardware or hardware image or wait til Steve wakes up Smile
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply
#3
You can use Hardware Images by copying image with the second argument 33
Code: (Select All)
HardwareImage& = _CopyImage(NormalImage&, 33)
You can use _MapTriangle with it, and this function led to a series of Minecraft Clone:  Minecraft Clone | QB64
Reply
#4
I use hardware acceleration to add graphics to some of my SCREEN 0 stuff.

https://qb64phoenix.com/forum/showthread.php?tid=3584
https://qb64phoenix.com/forum/showthread.php?tid=3600
https://qb64phoenix.com/forum/showthread.php?tid=3402
https://qb64phoenix.com/forum/showthread.php?tid=3581

Pete
Reply
#5
The basic breakdown over hardware images:

1) Hardware images are basically static images.  Once you make them, you can't change them.

2) The hardware screen is *always* a 32-bit screen of set pixel sizes.  You can't resize it.  If, as Pete mentioned, you're working in a SCREEN 0 text screen, the HARDWARE screen is going to be width * _fontwidth, height * _fontheight in size.  All other screens, it's simply going to match your width and height in pixels of the screen.

3) All you can basically do is put information to the hardware layer.  You don't read it back or alter it or interact with it.  You simply take your finished image (built it in software if you need to draw/write on the screen), copy it to hardware, and then _PUTIMAGE or _MAPTRIANLGE to place it on the screen.

4) Once all your images are in place on the hardware screen, you have to _DISPLAY to render them and draw them.

5) Don't forget to _FreeImage when done with them, like any other image to release that handle.



Code: (Select All)

SCREEN _NEWIMAGE(640,480,32)
fart = _NEWIMAGE(100,100,32) 'a second image
'draw crap on your fart. 
CLS, &HFFFF0000&&, fart 'I'm lazy.  I just made a big red fart

'now at this point, fart is a _SOFTWARE IMAGE.
stinky_fart = _COPYIMAGE(fart, 33) 'this gives us a handle to a hardware image copy of fart

DO
    _PUTIMAGE (x, y), stinky_fart 'this is all it takes.  You don't need to specify a destination as all hardware images go directly to the hardware layer
    _DISPLAY 'and this renders them on the screen.  
LOOP UNTIL done

'free the images once you're done
_FREEIMAGE fart 
_FREEIMAGE stinky_fart

Now there's a lot of stuff left out of that code above such as how x/y might change, or how the loop might become done, but what it focuses on is the steps to create your hardware image, place it on the hardware layer, and then display and free it.

It's the whole shebang of the process drawn out for you step-by-step.  If you have any more questions, feel free to ask, but it really is just that simple of a set-up for basic usage.  Everything else beyond is just adding bells and whistles and shortcuts or minor tweaks to the process.  Wink
Reply
#6
Hi Unseen Machine
a hardware image demo


[Image: image-2025-09-23-010636756.png]

and here the code

Code: (Select All)
DefLng L
DefInt I
Screen _NewImage(800, 600, 32)
_Title " Demo Hardware images:please move mouse, scroll mousewheel, left mousebutton or enter to quit"
L = _NewImage(12, 16, 32)
lWhite = _RGBA32(255, 255, 255, 0)
lBlack = _RGBA32(0, 0, 0, 255)
_Dest L
Color lWhite, lBlack
_PrintString (1, 1), "A"
l2 = _CopyImage(L, 33)
_Dest 0
_FreeImage L
For icount = 1 To 150
    Line (Rnd * 800, Rnd * 600)-(Rnd * 800, Rnd * 600), _RGBA32(Rnd * 255, Rnd * 255, Rnd * 255, 255), BF
Next icount
iK = 1
Do
    _Limit 30
    i2 = _KeyHit
    If _MouseInput Then
        iMx = _MouseX
        iMy = _MouseY
    End If
    If _MouseButton(1) Then i2 = 13
    If _MouseWheel > 0 Then
        If iK < 10 Then iK = iK + 2
    ElseIf _MouseWheel < 0 Then
        If iK > 1 Then iK = iK - 2
    End If
    _PutImage (iMx, iMy)-Step(12 * iK, 16 * iK), l2, 0
Loop Until i2 = 13
_FreeImage l2
End

You can enjoy about mouse buffer that emulates a history movement of mouse's cursor.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  about Hardware Images and _DisplayOrder,Help! qbfans 11 540 02-11-2026, 07:10 AM
Last Post: SMcNeill
  Nth problem with hardware images Ikerkaz 9 470 01-23-2026, 02:58 PM
Last Post: bplus
  Hardware images questions Dav 5 460 12-04-2025, 04:18 PM
Last Post: Pete
  Transparency with Hardware Images NakedApe 8 1,018 07-10-2025, 09:47 AM
Last Post: Pete
  How does QB64 support saving 8bit images? CMR 4 772 04-27-2025, 04:46 PM
Last Post: CMR

Forum Jump:


Users browsing this thread: 1 Guest(s)