How to remove text output/text object

Find quick help here to get you started with Hollywood
Post Reply
User avatar
Clyde
Posts: 348
Joined: Sun Feb 14, 2010 12:38 pm
Location: Dresden / Germany

How to remove text output/text object

Post by Clyde »

Hey there!

I can't use layers as I use sprites (and unfortunately it seems I can't use both at the same time :-( ). Now, I want to plot some text to the screen and remove it later. How would I do that?

I can use TextOut() but Undo(#TEXTOUT) just works with layers (and isn't that convienent if I have more then one textout).

Then I tried CreateTextObject() / DisplayTextObject() and I hoped calling FreeTextObject() would not just free memory but also delete the text object from the screen, but this does not happen. Or in other words: When would I use FreeTextObject()? In the doc it is said: "To reduce memory consumption, you should free text objects when you do not need them any longer." I do not need it any longer when I don't want to display it. But how am I able to do it?

Thanks!
Currently using: Hollywood 9 with Windows IDE and Hollywood 9 with Visual Studio Code and hw4vsc
User avatar
emeck
Posts: 169
Joined: Fri Apr 03, 2015 3:17 pm

Re: How to remove text output/text object

Post by emeck »

@Clyde

Hi. Have you tried creating a TextObject and then using it to create a sprite? That way you should be able to display it and move or remove it as a sprite.
PowerBook 5.2 MorphOS 3.15
PowerBook 5.8 MorphOS 3.15
Amiga 1200 BPPC/BVision AOS4.1 FE
User avatar
Clyde
Posts: 348
Joined: Sun Feb 14, 2010 12:38 pm
Location: Dresden / Germany

Re: How to remove text output/text object

Post by Clyde »

Hey emeck,

that is a nice idea, I didn't think about that. Indeed this can help me in some situations.

But what about an FPS counter, showing the current FPS every second? How will this impact performance (guess only Andreas can tell).

Still, as we have RemoveSprite() and RemoveLayer() functions it would be handy to have a RemoveTextObject() function, too.
Currently using: Hollywood 9 with Windows IDE and Hollywood 9 with Visual Studio Code and hw4vsc
User avatar
jPV
Posts: 603
Joined: Sat Mar 26, 2016 10:44 am
Location: RNO
Contact:

Re: How to remove text output/text object

Post by jPV »

If you use layers, then DisplayTextObject() creates a new layer, which can be removed like any other layer.

But if you don't use layers, then everything you draw on the display will stay there until you clear it manually somehow. This is the same no matter what functions you use to draw there (text functions, brushes, draw functions, etc).

You have to think what's the best way in your case to clear what you've drawn there. Cls() will clear whole screen and then you have to redraw everything you need there, except the bgpic if you have defined that. But you can also just clear/update the area you need, it might be faster in many cases. It pretty much depends what kind of stuff you do on screen and will the underlying graphics be static or does there happen changes etc.

You can also make performance tests for different approaches, use StartTimer/GetTimer around a long for/next loop that does your draw/clear stuff and see what's the best for you :)
User avatar
Allanon
Posts: 732
Joined: Sun Feb 14, 2010 7:53 pm
Location: Italy
Contact:

Re: How to remove text output/text object

Post by Allanon »

I agree with jPV, you can define an are of your display : you can clear it with the Box() command and update it with the TextOut().

An alternative method I've used in some project is to update the fps counter into a brush: you create a brush, use the SelectBrush() / EndSelect to clear an put your text in, and then you can easily draw this brush where you want with DislayBrush().

This last method, in some situations, may be more flexible, think for example if you want to update the frame counter every 20 frames, using the "brush method" you can plot continuosly the created brush until it is refreshed while using the TextOut() at each frame (I think) it could decrease performances.

In some situation, for debugging purposes, I've also used the first method but into a tiny separare display so I can control the refresh rate and adjust it to my needs while the main display still refresh at it's own rate.
Post Reply