performance - How to do OpenGL live text-rendering for a GUI? -
i'm implementing gui built on top of opengl. came problem each gui have -- text rendering. know of several methods of rendering text in opengl, however, i'm wonderin of them best suited gui.
generally in gui have 2 types of text -- static , live. static easy enough -- can render ttf texture , forget it. it's "live" text more bothering me -- imagine console, or live chat in multi-player game.
i thought of several options:
- no special cases -- render , load texture each time text changes, keeping in mind rerender when new text appears, , trying split larger text small parts (like per chat line). still leave hanging in cases score line changes time, or intro text renders "per character" (typewriter style seen in sci-fi games)
- quad-per character -- seems popular solution, prepare texture ascii table , render textured quad character. however, have serious doubts efficiency of such solution. tips how make faster welcome.
- hybrid solutions -- have no idea how implement cleanly
the question hence -- how render text in opengl efficiently?
if helps, i'm coding in stl/boost-heavy c++ , aiming @ gforce 6 , later graphics cards.
edit2: sean barrett released bitmap fonts c/c++ 3d programmers.
edit: code gem that's worth font stash leverages sean barrett's stb_truetype.h.
you can create texture in render characters of font. draw textured quads orthographic projection , proper texture coordinates: approach works when text in language doesn't contain symbols: english. font texture created once @ beginning of application , rendering quads fast.
that's i'm using , believe it's fastest way render text in opengl. @ first, used angelcode's bitmap font generator tool , integrated freetype directly , built big texture containing glyphs @ application launch. tips improve quads rendering speed, used vbo rest of geometry in application.
i'm surprised have doubts quad rendering while don't seem worry performance of generating texture on cpu, uploading it, binding render rectangle it, each frame. changing opengl states bottleneck, not 500 - 1000 quads you'll use text.
also, have @ libraries ftgl library converts whole font polygons (geometric fonts).
Comments
Post a Comment