LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Redraw 2d Picture without flashing

I use a 2D picture indicator to display a large grid of rectangles representing state in a grid of wells that my machine is working with. I would like to be able to update it rapidly as the state of any particular well changes, but it appears that the only refresh mode LabVIEW supports is to redraw the whole picture. And it seems to insist on drawing the background white, first. That means that a rapid series of updates results in a rapid series of flashes on the screen and very inefficient redrawing. Unusable. If

Is there a way to do better? Is there a way to get the LabVIEW picture to draw over its former state without drawing the background first? Is there a way to update only a part of the picture, physically?

0 Kudos
Message 1 of 11
(4,170 Views)

Check the help file for a picture control.

 

Did you right click the control and and uncheck "Erase First" on the menu?

0 Kudos
Message 2 of 11
(4,149 Views)

@Joymaker wrote:

I use a 2D picture indicator to display a large grid of rectangles representing state in a grid of wells that my machine is working with. I would like to be able to update it rapidly as the state of any particular well changes, but it appears that the only refresh mode LabVIEW supports is to redraw the whole picture. And it seems to insist on drawing the background white, first. That means that a rapid series of updates results in a rapid series of flashes on the screen and very inefficient redrawing. Unusable. If

Is there a way to do better? Is there a way to get the LabVIEW picture to draw over its former state without drawing the background first? Is there a way to update only a part of the picture, physically?


could you post some code and an example picture?

 

0 Kudos
Message 3 of 11
(4,135 Views)

Thanks, RavensFan, that led to considerable improvement. But not all that I need. My strategy is to draw a "layer" as a series of colored rectangles, and then to update them one by one with fresh, single Draw Rectangle.vi operations updating the value of the 2D Picture indicator as my chemistry proceeds.

But then, as the indicator redraws, I see the old state flickering momentarily underneath the new. The old colors and the old text (lowercase) flashes just before the new color and uppercase text takes over.


It appears that we're dealing with a display list. As if a new Draw Rectangle.vi

operation adds a command to the end of a list of commands that are freshly executed at each update, rather than modifying an offscreen pixel map and then updating that to the screen. And therefore, the more of these I do, the more cumbersome each successive update becomes.

Does anybody know if this is accurate? Because I have a placed a breakpoint in every place in my code that could possibly draw to the picture, and I'm not catching anything in my code that could be drawing the old state.

0 Kudos
Message 4 of 11
(4,093 Views)

In run mode right-click the picture indicator and choose 'Smooth Updates', or in edit mode you can find the option under the 'Advanced' pull-out menu.

0 Kudos
Message 5 of 11
(4,087 Views)

Asteroids.gif

Along with the erase first and the smooth updates you can try deferring panel updates while you calculate things. Also you should make sure that nothing is floating infront of the 2d picture control or LabVIEW is going to have a hard time as now it has to figure out how to render the floating object as well as the picture itself. Following these combinations I have redrawn 2d picture controls in excess of 60 fps.

 

I turned the game clock up so the physics in this gif look a little choppy but the idea was to show that that you can update in excess of 90fps with no flashing. As a side note asteroids is hard to play at 2x the speed. 

Message 6 of 11
(4,066 Views)

Is your asteroids game available somewhere?

0 Kudos
Message 7 of 11
(4,000 Views)

Not currently. Where do you think the best place to add it would be?

0 Kudos
Message 8 of 11
(3,876 Views)

@əʞɐſ wrote:

Not currently. Where do you think the best place to add it would be?


Probably here:

https://forums.ni.com/t5/Example-Programs/tkb-p/3039

 

I do have a faint recollection of a game specific forum, but can't seem to find it (after looking briefly).

0 Kudos
Message 9 of 11
(3,854 Views)

As regards your "Asteroids" game (which looks awesome, BTW) as a submission...

 

I had to search under my own profile, and it was about ten years ago, but I posted both a "Staroids" and a "Tank" game (neither of which were my creations, and I could only find creator info on one of them).  Not sure if the forums were reorganized over the intervening years, but they appear to be under:

Community Home>Code and Documents>Code Exchange>Example Program Drafts

 

If you search for "Staroids", make sure you tell the search engine that you intended to spell it that way... it wants to autocorrect it.

 

Dave

David Boyd
Sr. Test Engineer
Abbott Labs
(lapsed) Certified LabVIEW Developer
0 Kudos
Message 10 of 11
(1,386 Views)