Draw Text really slow
Draw Text really slow
Since we switched from 4.20 to 4.51 displaying text is realllllyyy slow.
Why does pb not use opengl to display text?
Or what else is the reason that its that slow?
We solved it as a workaround by drawing on a picture and display it afterwards. But I cannot understand why I has slowed down that much.
Why does pb not use opengl to display text?
Or what else is the reason that its that slow?
We solved it as a workaround by drawing on a picture and display it afterwards. But I cannot understand why I has slowed down that much.
Re: Draw Text really slow
You can choose OpenGL as subsystem (Maybe it is better for you?)
Belive! C++ version of Puzzle of Mystralia
Bug Planet
<Wrapper>4PB, PB<game>, =QONK=, PetriDish, Movie2Image, PictureManager,...
Bug Planet
<Wrapper>4PB, PB<game>, =QONK=, PetriDish, Movie2Image, PictureManager,...
Re: Draw Text really slow
Where would I find information about subsystems and how to use them?
Searched the documentation but couldn't find anything
Searched the documentation but couldn't find anything
Re: Draw Text really slow
under compiler options just type in the subsystem opengl
Windows 11, Manjaro, Raspberry Pi OS


Re: Draw Text really slow
when I compile the game with this command:
Drawing text is still slow.
Should it work by using DrawText as usual?
Code: Select all
pbcompiler -s "opengl" laby.pbShould it work by using DrawText as usual?
Re: Draw Text really slow
You could try using opengl text functions, I've never used them on linux though.
or just draw text to an img and make a sprite from it
or just draw text to an img and make a sprite from it
Code: Select all
;calculate img size needed to hold the text
timg = CreateImage(#PB_Any,1,1)
StartDrawing(ImageOutput(timg))
DrawingFont(FontID(tf))
width = TextWidth(words)
height = TextHeight(words)
StopDrawing()
FreeImage(timg)
img = CreateImage(#PB_Any,width,height)
StartDrawing(ImageOutput(img))
DrawingFont(FontID(font))
DrawText(0,0,words,color)
StopDrawing()
Windows 11, Manjaro, Raspberry Pi OS


- Didelphodon
- PureBasic Expert

- Posts: 450
- Joined: Sat Dec 18, 2004 11:56 am
- Location: Vienna - Austria
- Contact:
Re: Draw Text really slow
I'm also having this DrawText performance problem but in my case the mentioned workarounds are an absolutely no-go as my data (text) is highly dynamical.
Any ideas for what's the reason behind this performance-issue or furthermore, how it could be solved?
Cheers,
Didel.
Any ideas for what's the reason behind this performance-issue or furthermore, how it could be solved?
Cheers,
Didel.
Go, tell it on the mountains.
Re: Draw Text really slow
if it's to slow to draw text to an image and create a sprite from it dynamically
then create a character array of the font at start up and save the sprites in the array, then just look them up.
If that's not suitable because you need different fonts sizes and colors
you can dynamically create and cache glyphs as required using a map with a structure of the sprite and reference count
keying it with with the character font size color.
then create a character array of the font at start up and save the sprites in the array, then just look them up.
If that's not suitable because you need different fonts sizes and colors
you can dynamically create and cache glyphs as required using a map with a structure of the sprite and reference count
keying it with with the character font size color.
Windows 11, Manjaro, Raspberry Pi OS


- Didelphodon
- PureBasic Expert

- Posts: 450
- Joined: Sat Dec 18, 2004 11:56 am
- Location: Vienna - Austria
- Contact:
Re: Draw Text really slow
Hm, that's kinda ... weird workaround for something that actually shouldn't be an issue at all.idle wrote:if it's to slow to draw text to an image and create a sprite from it dynamically
then create a character array of the font at start up and save the sprites in the array, then just look them up.
If that's not suitable because you need different fonts sizes and colors
you can dynamically create and cache glyphs as required using a map with a structure of the sprite and reference count
keying it with with the character font size color.
Go, tell it on the mountains.
Re: Draw Text really slow
I don't think it's particularly unusual, OpenGL and SDL alone don't support fonts directly.
Windows 11, Manjaro, Raspberry Pi OS


Re: Draw Text really slow
Yes, sprite fonts are the way to go. 
The problem with DrawText being slow is that there is no hardware support
for that function. If you draw each character you need on a sprite and then
display them you'll get way more speed since sprites are hardware accelerated (Sprite3D).
However DirectX 10 offers a great deal of routines to display and modify text really fast
but that's probably not an option for you if you want to stay as compatible as possible to other systems and since this thread is in the Linux sub forum.
OpenGL does have native sprite font support if I remember correctly (so does DirectX if you use the libraries that provide additional functionality),
but it's quite limited. If you draw them on your own you'll have more control.
(Edit: if you're actually drawing on a screen)
The problem with DrawText being slow is that there is no hardware support
for that function. If you draw each character you need on a sprite and then
display them you'll get way more speed since sprites are hardware accelerated (Sprite3D).
However DirectX 10 offers a great deal of routines to display and modify text really fast
but that's probably not an option for you if you want to stay as compatible as possible to other systems and since this thread is in the Linux sub forum.
OpenGL does have native sprite font support if I remember correctly (so does DirectX if you use the libraries that provide additional functionality),
but it's quite limited. If you draw them on your own you'll have more control.
(Edit: if you're actually drawing on a screen)
Blog: Why Does It Suck? (http://whydoesitsuck.com/)
"You can disagree with me as much as you want, but during this talk, by definition, anybody who disagrees is stupid and ugly."
- Linus Torvalds
- Didelphodon
- PureBasic Expert

- Posts: 450
- Joined: Sat Dec 18, 2004 11:56 am
- Location: Vienna - Austria
- Contact:
Re: Draw Text really slow
Ok, maybe some kind of misunderstanding - eventually I didn't make myself clear enough, my excuses for that.
I'm just using the basic 2d-drawing capabilities. What for? For my actual project I need a bunch of special/enhanced controls/gadgets - on Linux, Windows and MacOS as well. So I'm kinda doing a cross-platform-gadgetlibrary, so to say - as a subproject. So no directx, opengl and co.
Cheers,
Didel.
I'm just using the basic 2d-drawing capabilities. What for? For my actual project I need a bunch of special/enhanced controls/gadgets - on Linux, Windows and MacOS as well. So I'm kinda doing a cross-platform-gadgetlibrary, so to say - as a subproject. So no directx, opengl and co.
Cheers,
Didel.
Go, tell it on the mountains.
Re: Draw Text really slow
Well for regular controls the speed of DrawText should be more than sufficient.
When exactly does it start feeling sluggish?
When exactly does it start feeling sluggish?
Blog: Why Does It Suck? (http://whydoesitsuck.com/)
"You can disagree with me as much as you want, but during this talk, by definition, anybody who disagrees is stupid and ugly."
- Linus Torvalds
- Didelphodon
- PureBasic Expert

- Posts: 450
- Joined: Sat Dec 18, 2004 11:56 am
- Location: Vienna - Austria
- Contact:
Re: Draw Text really slow
Any drawing-functions work fast as long as I don't use DrawText. When I include the text-drawing performance drops that massively that the window actually stops responding as it has no time left to handle the waiting messages, at all.
Go, tell it on the mountains.


