Canvas performance?

BlitzMax Forums/MaxGUI Module/Canvas performance?

Mr. Write Errors Man(Posted 2007) [#1]
Hi,

I had planned to use ordinary 2D graphics for my game, but I just realized that HTMLViews and TextAreas could make some parts of the game a lot easier to code.

How does canvas perform if compared to ordinary 2D graphics? I guess it's slower, but how much slower? Has anyone done any tests? Experiences?

Do canvases have some kind of automatic buffers so that I don't need to redraw them every frame - only when I really need to update their contents?

I read that overlapping canvases can cause some problems? Is that still a real problem?

Any other issues I should be aware of?

And the last question: Is there any way to make a HTMLViewer to display a string (that holds HTML code), or do I need to use temp files or JavaScript code to change HTMLViewer's content?

Thanks!

-AF


Dreamora(Posted 2007) [#2]
Overlapping Canvases will ever cause problems, as canvases are not regular gadgets, they are not meant to be put above others and have other gadgets put above them.

If you need to redraw them its up to you, you will just have to react to the GadgetRepaint event.


Performance is around the regular max2d in windowed mode, fullscreen will always be faster.


HTMLView reads from files but those files can be created as TStream as well and read from there. so an own THTML object or the like where you change parts of it and that updates a TStream source should work without problems.


Mr. Write Errors Man(Posted 2007) [#3]
Thanks for your reply.

Will HTMLview over a Canvas cause problems? So far in my limited tests it has worked ok.

What I mean with Canvas redraw is that for example HTMLView gadget doesn't need to be redrawn every frame by code - it handles it itself. Is Canvas like this too: I can update its contents when I want to, but otherwise it will automatically display its contents? Or do I need to redraw the Canvas everytime I get a GadgetRepaint event? My limited tests would seem to indicate that I only need a Flip in GadgetRepaint, but can I trust that it works in all situations?

I think I will use the JavaScript approach to changing HTMLView content, because it's easier and more flexible than using TStream.

Regular Max2D windowed mode performance sounds good to me.

-AF


Dreamora(Posted 2007) [#4]
It can work but it can break as well. There is no guarantee.
At best you never put any other gadget above a canvas


And using a TStream is highly flexible if you create your own object that handles the "dynamic parts" you can change or that it updates itself and just rewrites the stream to load the HTML from.

Java script will have its problem: its not god, wherefrom shall it know any of the informations? it can't access BM data.


Mr. Write Errors Man(Posted 2007) [#5]
Well, if I can't put a gadget over a Canvas then there's no way I can use HTMLViews. It seems to me like a bug of a system breaking scale.

JavaScript can alter everything the HTMLView contains and you can call JavaScript functions from BM. The needed JavaScript function is one line long - the rest is all done in BM.

-AF


Mr. Write Errors Man(Posted 2007) [#6]
This feels "a bit" like a hack, but since Panels can contain other gadgets and Panels can have a pixmap as a background, I could grab a pixmap of the Canvas' contents and use it as the background for the panel and then hide the Canvas, show the Panel and display the HTMLview on top of the Panel. :)

-AF


skidracer(Posted 2007) [#7]
I just posted some code illustrating children of canvas drawing correctly infront here.


Mr. Write Errors Man(Posted 2007) [#8]
Thanks! :)

-AF