Skip to main content
GameDev.net gamedev.net
🔒 Locked

VBO Text Rendering

Started by NapharianWolf Feb 15, 2011 at 3:43 PM 3 replies 1.5k views
Original Post
NapharianWolf
NapharianWolf
This is just a curiousity at the moment, as I haven't gotten a performance hit out of it yet, but I'm wondering if my method for rendering text could be improved.

Currently, I have a single texture with a basic set of ascii characters in it that I reference.

I build the string into a VBO such that each character in the string gets 6 vertices, 1 at the start that will be "invisible", 4 for the 2 triangles, 1 at the end that will be "invisible". The invisible triangles are there to seperate each character from the next and to prevent the texture from bleeding everywhere.

There is no kerning, and each character has 1 unit space between it and the last character.


Looks like this (not an actual string here):

First character :
Vertices: 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1
Textures: 0, 0, x, x, x, x, x, x, x, x, 0, 0

Second character:
Vertices: 2, 0, 2, 0, 3, 0, 0, 3, 3, 3, 3, 3
Textures: 0, 0, y, y, y, y, y, y, y, y, 0, 0

and so on...

Is there a better way to do this when using a triangle strip vbo?
V-man
V-man
VBO makes a difference only when you render a lot of triangles. Perhaps >10,000 triangles.
I don't recommend triangle strips. just use triangles.
NapharianWolf
NapharianWolf
Is there a performance difference between triangle strip and triangles when it comes to VBOs?

If i switch to triangles, I use the same number of vertices/color coords/tex coords I am now and I was under the impression that triangle strips generated better performance than triangles. If this isn't the case then i'll switch over, but a lot of the information i've read says to use strips.
V-man
V-man
If you are going to use triangle strips, then you have to make use of degenerate triangles or use primitive restart
GL_NV_primitive_restart
http://www.opengl.org/registry/specs/NV/primitive_restart.txt

otherwise you would have a lot of draw calls. A lot of draw calls is not so bad in GL as it is in D3D, but still, it is good to reduce.
Benchmark strips vs triangles and see what you get.
Krohm
Krohm
Last time I benchmarked tris vs strips was on 6600 GT.
Strips turned out to be faster by a very small margin, about 1-2%[sub][1][/sub], if you believe this number to be trustable. I therefore agree with V-man when he suggests to drop strips. Supporting strip jumping for arbitrary geometry takes more time than just not having the problem to start with.

I haven't done extensive testing after that as discrete PC cards are so powerful that benchmarking vertex transform is no more possible for me.

[size="1"][1] Except when index 64*1024 was used, for which strips turned out to be twice as fast... I believe this was a driver issue, possibly dealing with NV_p_r. If I blanked the index the performance would be in the same range. I tried with a few pixel shaders down to a bare color assign.
Previously "Krohm"

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.