Page 1 of 1

Flicker-free update of 32-bit image gadgets

Posted: Wed Feb 16, 2011 4:52 pm
by Trond
With SmartWindowRefresh off there is flickering when updating the image (not so much visible here because only a small portion of the image is non-transparent), with SmartWindowRefresh off there are serious redraw problems (try moving the window out of the screen and back).

Code: Select all

#W = 512
#H = 384

OpenWindow(0, 0, 0, #W, #H, "", #PB_Window_ScreenCentered | #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget)
ImageGadget(0, 10, 10, 200, 200, 0)
OptionGadget(1, 230, 10, 100, 22, "Flicker")
OptionGadget(2, 230, 35, 100, 22, "No refresh")
SetGadgetState(1, 1)

AddWindowTimer(0, 0, 30)
Repeat
  Select WaitWindowEvent()
    Case #PB_Event_Timer  
      CreateImage(0, 200, 200, 32 | #PB_Image_Transparent)
      StartDrawing(ImageOutput(0))
        DrawingMode(#PB_2DDrawing_AllChannels)
        r = Random(255)
        g = Random(255)
        b = Random(255)
        a = 128
        Box(Random(190), Random(190), 32, 32, RGBA(r, g, b, a))
      StopDrawing()
      SetGadgetState(0, ImageID(0))
    Case #PB_Event_Gadget
      Select EventGadget()
        Case 1: SmartWindowRefresh(0, 0)
        Case 2: SmartWindowRefresh(0, 1)
      EndSelect
    Case #PB_Event_CloseWindow
      Break
  EndSelect
ForEver


Re: Flicker-free update of 32-bit image gadgets

Posted: Fri Feb 18, 2011 4:08 pm
by Thorium
It does not flicker on my system.

Re: Flicker-free update of 32-bit image gadgets

Posted: Fri Feb 18, 2011 9:32 pm
by Trond
Are you sure? Also does smart window refresh work? Try this:

Code: Select all

#W = 512
#H = 384

OpenWindow(0, 0, 0, #W, #H, "", #PB_Window_ScreenCentered | #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget)
ImageGadget(0, 10, 10, 200, 200, 0)
OptionGadget(1, 230, 10, 100, 22, "Flicker")
OptionGadget(2, 230, 35, 100, 22, "No refresh")
SetGadgetState(1, 1)

AddWindowTimer(0, 0, 30)
Repeat
  Select WaitWindowEvent()
    Case #PB_Event_Timer  
      CreateImage(0, 200, 200, 32 | #PB_Image_Transparent)
      StartDrawing(ImageOutput(0))
        DrawingMode(#PB_2DDrawing_AllChannels)
        Box(0, 0, 200, 200, RGBA(0, 0, 0, 48))
      StopDrawing()
      SetGadgetState(0, ImageID(0))
    Case #PB_Event_Gadget
      Select EventGadget()
        Case 1: SmartWindowRefresh(0, 0)
        Case 2: SmartWindowRefresh(0, 1)
      EndSelect
    Case #PB_Event_CloseWindow
      Break
  EndSelect
ForEver

Re: Flicker-free update of 32-bit image gadgets

Posted: Sat Feb 19, 2011 1:38 am
by Thorium
Now i see it. But it only flickers every 10-15 seconds. Thats why i dont saw it on the other code with all the movement.