Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers AppGameKit Corner / Text Drawing Is Ridiculously Slow - How To Optimize Text Drawings?

Author
Message
JeZxLee
7
Years of Service
User Offline
Joined: 15th Mar 2017
Location: Long Island, New York, United States, Earth
Posted: 17th Oct 2019 16:55
Hi,

I ran my HTML5 game on a Raspberry Pi 3b+ with Raspbian 3 OS and Chromium browser.
I've optimized everything in the HTML5 version except the [About] staff scroll screen.

The staff scroll screen scrolls text from bottom to top like in movie credits.
It's ridiculously slow on RPi.

Is there something I can do to improve staff scroll screen performance?
Is there anyway to save all the texts into images to improve speed?
I create all staff texts once at start of function.
After that I am only modifying each staff text's Y position on the screen.

Anything else that can be done?

You can run the current HTML5 version below:
http://fallenangelsoftware.com/stuff/files/PixelArtist/HTML5/index.html

I am using AppGameKit Classic (also own AppGameKit Studio, but it's not finished so am not using it)
Let me know, thanks!

Jesse
JeZxLee
Fallen Angel Software
Video Game Design Studio
http://www.FallenAngelSoftware.com
JeZxLee
7
Years of Service
User Offline
Joined: 15th Mar 2017
Location: Long Island, New York, United States, Earth
Posted: 17th Oct 2019 17:24
Code is below:
JeZxLee
Fallen Angel Software
Video Game Design Studio
http://www.FallenAngelSoftware.com
JeZxLee
7
Years of Service
User Offline
Joined: 15th Mar 2017
Location: Long Island, New York, United States, Earth
Posted: 17th Oct 2019 18:44
Text drawing has always been "slow" on every engine I have tried...

My solution in the past was to "cache" the text into image textures.
Just wondering if that is possible with AppGameKit Classic?
(I want to draw a text into an image texture)

Let me know, this is the final part of optimizations...

Jesse
JeZxLee
Fallen Angel Software
Video Game Design Studio
http://www.FallenAngelSoftware.com
SFSW
21
Years of Service
User Offline
Joined: 9th Oct 2002
Location:
Posted: 17th Oct 2019 20:57 Edited at: 17th Oct 2019 20:59
Text drawing is indeed resource intensive, especially if you create, delete and recreate with each loop. So your approach of modification only is better in that regard. However, doing many individual text renders/edits can hinder performance, especially on slower/weaker devices.

So yes, your best option is probably to render the text you need to a RenderImage, then use that render image on the surface of your choice... either a single sprite or a plane object. You can then scroll, move, scale, and position the surface as desired to produce the effect(s) you want. So in procedure, it might look something like this:

- Create your render image - CreateRenderImage(ImageIndex,SizeX,SizeY,0,0)
- Set to render image and render text - SetRenderToImage(ImageIndex,0) … CreateText()
- Pass a render of the text to the render image - Render2DFront()
- Set render back to screen and delete the used text indexes - SetRenderToScreen() : DeleteAllText()
- Create the surface you want to render to - CreateObjectPlane(ObjectIndex,SizeX,SizeY)
- Apply your render image to the surface - SetObjectImage(ObjectIndex,ImageIndex,0)
- Then move, scale, position, etc, the surface as desired.

This way, all text generation and settings are done in a single pass and your animation/movement handled at runtime on its own for maximum performance.
PSY
Developer
7
Years of Service
User Offline
Joined: 3rd Jul 2016
Location: Laniakea Supercluster
Posted: 17th Oct 2019 21:33
Another option is to create and delete your texts on the fly ( create them before entering the visible screen, and delete them after they have left the screen ).
This will give you an extreme performance boost.

Also, using a lot of texts will decrease your FPS, even if they are OUTSIDE the screen. Making them invisible will also give you a large FPS boost.

This code generates 1000 texts and hides them outside the screen. Hitting SPACE will toggle visibility. Watch the FPS:




PSY


PSY LABS Games
Coders don't die, they just gosub without return
JeZxLee
7
Years of Service
User Offline
Joined: 15th Mar 2017
Location: Long Island, New York, United States, Earth
Posted: 17th Oct 2019 23:04
Good stuff...

I'll play around with your suggestions in the morning.
I had a bad storm last night and it killed my Internet landline(on limited WiFi).

I have one other issue that I will post last...

Thanks again, I appreciate the help!

-Jesse
JeZxLee
Fallen Angel Software
Video Game Design Studio
http://www.FallenAngelSoftware.com
TomToad
6
Years of Service
User Offline
Joined: 6th Jan 2018
Location:
Posted: 17th Oct 2019 23:17
Tweens might help here. Unload all the work of moving the text onto the engine.
JeZxLee
7
Years of Service
User Offline
Joined: 15th Mar 2017
Location: Long Island, New York, United States, Earth
Posted: 18th Oct 2019 20:57
Hi,

Good performance increase by utilizing "SetTextVisible"...

Still a little slow on the RPi 3b+, will work more on it tomorrow.
Many thanks for everyone's help!

Jesse
JeZxLee
Fallen Angel Software
Video Game Design Studio
http://www.FallenAngelSoftware.com
SFSW
21
Years of Service
User Offline
Joined: 9th Oct 2002
Location:
Posted: 18th Oct 2019 22:37
Glad you were able to improve performance. If performance continues to be below what you want, I would still generally recommend reducing everything down to one entity via a render image and one surface, if you can. Not only can it provide the maximum potential performance, but it's also something that can be modified as needed on demand during runtime with a simple redraw update to the render image while leaving the surface in place and bound to the render image index.

Login to post a reply

Server time is: 2024-04-26 10:03:42
Your offset time is: 2024-04-26 10:03:42