Fonts

Started by
10 comments, last by lazork357 19 years, 4 months ago
I read somewhere in this forum that Bitmap Fonts (NeHE's Lesson 13) are an extremely slow way to write text. Is this true? I can't see why they should be slower than creating my own bitmap. The only difference I see between the two methods is the way the texture is created; but even though Bitmap Fonts use CreateFont() to create the bitmap, instead of loading it from a file, the result seems exactly the same to me. In both ways the strings are printed calling a list which contains two triangles mapped whith a 256x256 texture. So, before I start implementing fonts in my app, can you tell me if Bitmap Fonts are really slower?
Advertisement
I am not sure about the answer to this, but I can tell you how to get one...Write a simple bench using the NeHe code. Sorry that that's all I can give you [sad].
----------------------------------------------------"Plant a tree. Remove a Bush" -A bumper sticker I saw.
Quote:Original post by lazork357
So, before I start implementing fonts in my app, can you tell me if Bitmap Fonts are really slower?

They are, because normally bitmap fonts are done using DrawPixel calls. The other method, the texture-mapped-quads approach is faster because it can be easily put in server memory and offers some advancements such as transparency and full featured texture pipe.

I don't know about the demo being referenced in particular but it's pretty important to keep clear the distinction between texture fonts and bitmap fonts.

Previously "Krohm"

So I guess I was right.
If there are no DrawPixel calls but just some glVertex3f, it should give no speed problem.
Perhaps what NeHe is referring to as Bitmap Fonts is not what Bitmap Fonts really are. I'll be giving it a try anyway.
BTW, does it make any difference building the gl lists containing the characters using VertexArrays rather than passing the vertices one by one?
(I know vertex arrays are faster, but is this true even if they are used in a List?)
Quote:Original post by lazork357
If there are no DrawPixel calls but just some glVertex3f, it should give no speed problem.

Partially true considering the average application load and system horsepower but we all know how much batching helps performance. More on this later...

Quote:Original post by lazork357
BTW, does it make any difference building the gl lists containing the characters using VertexArrays rather than passing the vertices one by one?
(I know vertex arrays are faster, but is this true even if they are used in a List?)

The origin of the speedup lies in two factors.
1- Assembly level problems. Calling a func 100 times causes the CPU to stall. The JMP/CALL assembly instruction is pretty slow. How this affects you? It obviously takes more time to make 100 Vertex calls than a single call which pulls all the vertices at once. Vertex arrays buys you heavy saving here.
It should be noted that in todays systems, you're likely to not see any improvement using (standard) vertex arrays. This is because CPU and GPU work is often carried out in parallel ways. Vertex arrays are MUCH better when CPU limited. This means your app needs to be quite complex to show the difference between immediate mode and batched arrays.
As a reference, the first time I used arrays on my P133 I got a 100% improvement. The same program on my Athlon1800 shows no visible improvement from enably VAs against immmediate mode.
2- Server side memory. You can get this by using display lists (which also provide very good batching) or specific interfaces such as texture objects and vertex buffers. The point here is that data is not transferredfrom CPU to GPU (or at least, it is trasferred faster).

All this words to say some simple facts:
- Vertex arrays ARE faster, but only if you are CPU limited or, more generally 'batch limited'. They save on calls. With some tricks they also save on badwidth requirements (see display lists, ARB_VBO).
- Display lists are faster because they can be sent to the driver with a single call. A display list can have thousands of calls inside. That's a big saving but has the same limitations considered above. More interesting the fact display lists and their data are stored in server side memory, thus they are effectively faster even when not CPU limited.

Previously "Krohm"

I just wanted to thank you for your exhaustive reply.
If I got that right, I'd better use VAs and lists together.
About VBO, even though I'm not sure about what they really are, I won't be using them because I think they're not supported by all graphic cards (and I need my game to run smoothly on old PCs as well)
I never have really used vertex objects or arrays or anything like that with vertices. Mainly this is because they mostly require extensions that don't work on all cards. Display lists do work on all cards, or if nothing else, can't hurt, even if it doesn't work like it should due to lack of memory. I use display lists for 2d and 3d fonts, just like in the NEHE tutorials, and I haven't noticed any real penalties to speed. Another advantage to display lists is that you can use one list, change the color or scaling, even the texture itself, as long as just the vertices are in the list, and you still get the added speed. Like if you have a static enemy in an RPG. RPG games tend to have the same enemies later in stronger versions but a different color, even with the same texture and model. This is a perfect example of the displaylist. As long as the model is static.(just like the characters in a font). This is not to say that vertex lists don't help, they help alot, maybe even better than Displists, but the benefits of the lists is more to my tastes.


Are you saying that VAs are not supported by all cards?
Quote:Original post by lazork357
Are you saying that VAs are not supported by all cards?


if he is he's wrong!
thanks kaysik for confirming my hypothesis.

This topic is closed to new replies.

Advertisement