Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Hardware Acceleration and Uses
#6
Even IF you can't (for some odd reason) create those images once, you can still clean up the code and processes a TON with just some simple changes.

Examine the code in the post above, which I copied from your link.

Then, compare to this simple set of changes:
Code: (Select All)
Overlay_Hardware = _CopyImage(overlay, 33)
For k = i2 To i3
j = Len(button$(k)): a$ = " " + button$(k) + " "
_PutImage (0, 0), Overlay_Hardware
If HtmlBtn = k And lb = 0 Then
HTMLBHover = fb_gfx_hyb_hw(j * 8, 2 * 16, 200, 200, 200, -8, -7, -1, Mid$(a$, 1, j))
_PutImage ((x(k) - 1) * 8, (y(k) - 1) * 16 + 8), HTMLBHover
_FreeImage HTMLBHover
Else
If lb = 0 And b_hover = k Then
HTMLBHover = fb_gfx_hyb_hw(j * 8, 2 * 16, 200, 200, 200, -8, -7, -1, Mid$(a$, 1, j))
_PutImage ((x(k) - 1) * 8, (y(k) - 1) * 16 + 8), HTMLBHover
_FreeImage HTMLBHover
ElseIf Abs(lb) = 1 And b_hover = k Then
HTMLBPress = fb_gfx_hyb_hw(j * 8, 2 * 16, 200, 200, 200, -1, -1, -1, Mid$(a$, 1, j))
_PutImage ((x(k) - 1) * 8, (y(k) - 1) * 16 + 8), HTMLBPress
_FreeImage HTMLBPress
Else
HTMLBStatic = fb_gfx_hyb_hw(j * 8, 2 * 16, 170, 170, 170, -9, -9, -1, Mid$(a$, 1, j))
_PutImage ((x(k) - 1) * 8, (y(k) - 1) * 16 + 8), HTMLBStatic
_FreeImage HTMLBStatic
End If
End If
Next
_FreeImage Overlay_Hardware

The overlay doesn't change inside the loop, so there's no reason to create it and free it constantly. At most, create it ONCE before the loop, free it after the loop.

Then you're creating three software images. Copying them to hardware images. Freeing the three software images. Using ONE hardware image based on those IF statements. And then freeing all those hardware images.

I've changed it so you.. Create 1 software, copy it, free it, display the hardware, free it.

That's only using ONE image without ever even having to deal with the other two at all... And, since we're not copying and freeing the overlay, we're now basically making ONE hardware image in the loop instead of FOUR.

I think you can see where even a small change to things, such as this, would *really* affect your CPU usage.
Reply


Messages In This Thread
Hardware Acceleration and Uses - by Pete - 02-18-2025, 04:57 PM
RE: Hardware Acceleration and Uses - by SMcNeill - 02-18-2025, 05:42 PM
RE: Hardware Acceleration and Uses - by a740g - 02-18-2025, 05:47 PM
RE: Hardware Acceleration and Uses - by Pete - 02-18-2025, 10:35 PM
RE: Hardware Acceleration and Uses - by SMcNeill - 02-18-2025, 11:23 PM
RE: Hardware Acceleration and Uses - by SMcNeill - 02-18-2025, 11:36 PM
RE: Hardware Acceleration and Uses - by Pete - 02-18-2025, 11:45 PM
RE: Hardware Acceleration and Uses - by SMcNeill - 02-19-2025, 06:06 AM
RE: Hardware Acceleration and Uses - by SMcNeill - 02-19-2025, 06:42 AM
RE: Hardware Acceleration and Uses - by SMcNeill - 02-19-2025, 06:58 AM
RE: Hardware Acceleration and Uses - by SMcNeill - 02-19-2025, 07:06 AM
RE: Hardware Acceleration and Uses - by Pete - 02-19-2025, 12:05 PM
RE: Hardware Acceleration and Uses - by SMcNeill - 02-19-2025, 02:28 PM
RE: Hardware Acceleration and Uses - by SMcNeill - 02-19-2025, 02:16 PM
RE: Hardware Acceleration and Uses - by Pete - 02-19-2025, 06:00 PM
RE: Hardware Acceleration and Uses - by SMcNeill - 02-19-2025, 07:54 PM
RE: Hardware Acceleration and Uses - by Pete - 02-19-2025, 08:52 PM
RE: Hardware Acceleration and Uses - by SMcNeill - 02-20-2025, 04:23 PM
RE: Hardware Acceleration and Uses - by Pete - Yesterday, 02:28 AM
RE: Hardware Acceleration and Uses - by SMcNeill - Yesterday, 03:13 AM



Users browsing this thread: 12 Guest(s)