Page 1 of 1
[26 Dec 2008] Some questions on graphics and garbage collection
Posted: Sat Jun 13, 2020 5:32 pm
by TheMartian
Note: This is an archived post that was originally sent to the Hollywood mailing list on Fri, 26 Dec 2008 12:06:26 -0000
Hi
Can I ask someone to help me on these two issues, please...?
1) Every now and then while updating a (small) part of the display the section being updated sort of flashes like if the modification takes place in the middle of a screen update. In the old days you could prevent this by waiting for a vertical blank sync signal before making your change. Languages like Blitz had a specific command for this. Is there a trick to achieve the same effect in Hollywood and prevent the flash effect?
2) How does garbage collection work in this case...?
Code: Select all
mylist={}
mylist.mysublist={}
mylist.mysublist[0]="Hello"
mylist=nil
Can I expect Hollywood to remove the momory reserved for the sublist item as well or is it 'orphaned' and only killed when the computer is turned off? In other words, can I get rid of a multilevel table structure by simply setting the top level to nil? It will of course make the sub items inaccessible, but will they still grab some memory? I currently play around with some 5 level structures for a program, and it would be convenient if I could erase a structure in a clean way by just setting the top level to nil.
Merry Christmas to everyone
Jesper
[27 Dec 2008] Re: Some questions on graphics and garbage collection
Posted: Sat Jun 13, 2020 5:32 pm
by airsoftsoftwair
Note: This is an archived post that was originally sent to the Hollywood mailing list on Sat, 27 Dec 2008 10:24:58 +0100
Hi
Can I ask someone to help me on these two issues, please...?
1) Every now and then while updating a (small) part of the display the section being updated sort of flashes like if the modification takes place in the middle of a screen update. In the old days you could prevent this by waiting for a vertical blank sync signal before making your change. Languages like Blitz had a specific command for this. Is there a trick to achieve the same effect in Hollywood and prevent the flash effect?
You could try to use
VWait(). However, the flashes could also be due to coding mistakes, e.g. by drawing over the same area twice. This usually generates flickering. E.g. if you want to move brush 1 from 0:0 to 100:100, you should NOT do the following:
Box(0, 0, 200, 200, #BLACK) ; clear old area DisplayBrush(1, 100, 100) ; draw brush to 100:100
This will generate a flickering display. Instead you should do it in one drawing operation (e.g. by using an off screen brush etc.)
2) How does garbage collection work in this case...?
mylist={} mylist.mysublist={} mylist.mysublist[0]="Hello" mylist=nil
Can I expect Hollywood to remove the momory reserved for the sublist item as well or is it 'orphaned' and only killed when the computer is turned off? In other words, can I get rid of a multilevel table structure by simply setting the top level to nil? It will of course make the sub items inaccessible, but will they still grab some memory? I currently play around with some 5 level structures for a program, and it would be convenient if I could erase a structure in a clean way by just setting the top level to nil.
Yes, it works this way. As soon as a structure becomes inaccessible, it will be freed by the garbage collector automatically during run-time.
[27 Dec 2008] Re: Some questions on graphics and garbage collection
Posted: Sat Jun 13, 2020 5:32 pm
by TheMartian
Note: This is an archived post that was originally sent to the Hollywood mailing list on Sat, 27 Dec 2008 10:24:48 -0000
Thanks
I erase a text by drawing a box and then reprint some other text. So it looks like a 'double draw' error, which causes flashes about every 10th time. I may have to go for writing to a brush and stamp it for every change. One other thing I'll try is to write the old text using the background colour thus erasing it and then write the new text using the foreground colour. I was hoping to avoid the use of brushes to keep things as basic as possible.
regards Jesper
[27 Dec 2008] Re: Re: Some questions on graphics and garbage collection
Posted: Sat Jun 13, 2020 5:32 pm
by airsoftsoftwair
Note: This is an archived post that was originally sent to the Hollywood mailing list on Sat, 27 Dec 2008 11:43:53 +0100
Thanks
I erase a text by drawing a box and then reprint some other text. So it looks like a 'double draw' error, which causes flashes about every 10th time. I may have to go for writing to a brush and stamp it for every change.
Yes, that's the way I'd do it.
One other thing I'll try is to write the old text using the background colour thus erasing it and then write the new text using the foreground colour. I was hoping to avoid the use of brushes to keep things as basic as possible.
There's no need to avoid brushes because they can be drawn very fast. Drawing text is much slower (especially with true type fonts). So you should try to minimize calls to
TextOut(),
Print() etc. if you want the best speed.
[28 Dec 2008] Re: Some questions on graphics and garbage collection
Posted: Sat Jun 13, 2020 5:32 pm
by TheMartian
Note: This is an archived post that was originally sent to the Hollywood mailing list on Sun, 28 Dec 2008 10:18:58 -0000
Hi
Reprinting the old text with the background colour seems to work all right, but in any case I have it working now as originally intended. I had made a 'silly me' mistake in a combined logical test so instead of drawing the borders of my text area in 3D and all that just once to delimit the text area it was redrawing everything each time the text was modified or relocated - which is several separate draw operations, thus triggering the multi draw problem you pointed out. Just doing a
Box() followed by a
TextOut() command seems to happen well within the time interval of a single redraw of the screen. So no flashes any longer.
regards Jesper