Sign in to follow this  
lazork357

Fonts

Recommended Posts

lazork357    148
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?

Share this post


Link to post
Share on other sites
tHiSiSbOb    463
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].

Share this post


Link to post
Share on other sites
Krohm    5031
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.

Share this post


Link to post
Share on other sites
lazork357    148
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?)

Share this post


Link to post
Share on other sites
Krohm    5031
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.

Share this post


Link to post
Share on other sites
lazork357    148
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)

Share this post


Link to post
Share on other sites
kburkhart84    3187
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.

Share this post


Link to post
Share on other sites
Krohm    5031
Quote:
Original post by lazork357
If I got that right, I'd better use VAs and lists together.
You got it.
Quote:
Original post by lazork357...I think they're not supported by all graphic cards...
For nVIDIA, they are supported since GeForce1. I think ATi supports them on all 8500 and later GPUs. Just to let you know anyway.

Share this post


Link to post
Share on other sites
lazork357    148
Ok, now I'm trying to use vertex arrays to build my font, but since I'm new to them, here I come with another question that should prove my ignorance about OpenGL.
Is it enough to call glEnableClientState(GL_VERTEX_ARRAY) before building the list, or am I supposed to call it every time I call the list?
I've tried this out myself, and it seems like building the list with GL_VERTEX_ARRAY enabled doesn't require me to enable it ever again, even though I disable it before calling the list.
Yet, I'd like one of you to confirm this.

[Edited by - lazork357 on December 4, 2004 4:41:13 PM]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this