What is Text object?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
Sasha264
Party member
Posts: 131
Joined: Mon Sep 08, 2014 7:57 am

What is Text object?

Post by Sasha264 »

Hello folks! :awesome:

Here is an opportunity to create Text objects https://love2d.org/wiki/love.graphics.newText
instead of drawing text every frame with https://love2d.org/wiki/love.graphics.printf
Used it a dozen times and it really improves performance.

But I don't understand what exactly a Text object is?
Pixel buffer like canvas? Set of glyphs and coordinates? Or something else?

Is it ok to store hundreds of paged text with Text object, created for every "page"?
As far as I see with https://love2d.org/wiki/love.graphics.getStats
it does not increase vram consumption, but maybe here is some other issues?
Attachments
text-objects.png
text-objects.png (710.79 KiB) Viewed 4968 times
bobbyjones
Party member
Posts: 730
Joined: Sat Apr 26, 2014 7:46 pm

Re: What is Text object?

Post by bobbyjones »

I believe it is like a sprite batch or mesh of sorts that batch the calls so that all of the text is drawn only once
User avatar
Sasha264
Party member
Posts: 131
Joined: Mon Sep 08, 2014 7:57 am

Re: What is Text object?

Post by Sasha264 »

Thanks! That's a good idea! I will believe it that too :3
User avatar
ivan
Party member
Posts: 1911
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: What is Text object?

Post by ivan »

I don't know much about the inner workings of Love2D but I suspect that the text object is a vertex buffer with UV information mapped with the rasterized font texture (spaced/kerned accordingly). It probably does consume a little bit of VRAM.
User avatar
Sasha264
Party member
Posts: 131
Joined: Mon Sep 08, 2014 7:57 am

Re: What is Text object?

Post by Sasha264 »

ivan wrote: Wed Aug 28, 2019 5:58 am
Thanks! :cool:
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 59 guests