I had to refresh my brain on using hardware acceleration, so I built up the hybrid buttons a bit more...
In other news, @SMcNeill
That's neat! It is something I had thought about for a demo, but I realized it's too much to code for just that purpose, alone. Now I know just how much too much was!
I did manage to piss it off a bit. I clicked the KB2 key. The keyboard color changed but then all hell broke loose in memory, going from 96MB to over 1300MB before I hit End Task to shut it down. Memory leak?
Pete
Code: (Select All)
Overlay = _NewImage(_Width * _FontWidth, _Height * _FontHeight, 32)
ReDim Shared x(0), y(0), button$(0)
Dim Shared BHybFg, BHybBg1, BHybBg2, BHybBdr1, BHybBdr2, Bg
Bg = 5: BHybBg1 = 6: BHybFg = 6: BHybBg2 = 7: BHybBdr1 = 0: BHybBdr2 = 255
Palette 5, 63 ' Bright white.
Palette 6, 56 ' Dark grey.
Color 0, 5 ' Bright white background.
Cls
a$ = " Activate ": button_maker a$, 7, 51
a$ = " Search ": button_maker a$, 7, 66
a$ = " Pause ": button_maker a$, 12, 51
a$ = " Reset ": button_maker a$, 12, 66
nob = 4
Do
_Limit 30
For i = 1 To nob
j = Len(button$(i))
_Dest Overlay
Line (8 * (x(i) - 1), 16 * (y(i) - 1) + 7)-((j + 2) * 8 + 8 * (x(i) - 1), 16 * 2 + 16 * (y(i) - 1) + 7), _RGB32(BHybBdr1, BHybBdr1, BHybBdr1), B
Line (8 * (x(i) - 1) + 8, 16 * (y(i) - 1) + 15)-((j + 1) * 8 + 8 * (x(i) - 1), y(i) * 16 + 15), _RGB32(BHybBdr2, BHybBdr2, BHybBdr2), B
Overlay_Hardware = _CopyImage(Overlay, 33)
_PutImage (0, 0), Overlay_Hardware
_Dest 0
_FreeImage Overlay_Hardware
Next
_Display
Loop Until Len(InKey$)
End
Sub button_maker (button$, y, x)
Static nob
nob = nob + 1
Dim b(15) As String * 1
b(0) = Chr$(0)
b(1) = "Ú"
b(2) = "Ä"
b(3) = "¿"
b(4) = "³"
b(5) = "À"
b(6) = "Ù"
b(7) = "Ã"
b(8) = "´"
b(9) = "Ä"
b(10) = "Â"
b(11) = "Á"
b(12) = "Þ"
b(13) = "Ý"
b(15) = "ß"
b(14) = "Ü"
j = Len(button$)
i = nob
ReDim _Preserve x(i), y(i), button$(i)
y(i) = y: x(i) = x
button$(i) = String$(j, 0)
Mid$(button$(i), 1 + (j - Len(_Trim$(button$))) / 2) = button$
Locate y(i), x(i): Color BHybBg1, Bg: Print String$(j + 2, b(14))
Locate , x(i): Color Bg, BHybBg1: Print String$(j + 2, b(0))
Locate , x(i): Color BHybBg1, Bg: Print String$(j + 2, b(15));
Locate y(i) + 1, x(i) + 1: Color BHybFg, BHybBg2: Print button$;
End Sub
In other news, @SMcNeill
That's neat! It is something I had thought about for a demo, but I realized it's too much to code for just that purpose, alone. Now I know just how much too much was!
I did manage to piss it off a bit. I clicked the KB2 key. The keyboard color changed but then all hell broke loose in memory, going from 96MB to over 1300MB before I hit End Task to shut it down. Memory leak?
Pete