سؤال

I have lots of text to draw. If I call D3DXFont::DrawText with first parameter being NULL I get terrible performance.

I heard that using D3DXFont with conjunction with D3DXSprites makes things much more faster.

How my application needs to draw strings? It daraws every string with pseudo shadow. It means I draw each string 4 times in black: x + 1, y + 1 x - 1, y + 1 x - 1, y - 1 x + 1, y - 1 and 1 time in actual color. It makes very nice looking always readable strings. I even switched to pixel fonts for faster rendering.

Now call that string with shadow (ShadowString).

Every frame I draw 256 (worst case scenario) of those ShadowStrings on screen.

I would like to know how to use sprites (or any other technique) to speed up drawing of those string as much as possible). Now I'm getting 30 FPS in app. But I target for 120 min. And problem is ONLY that text drawing thing.

هل كانت مفيدة؟

المحلول

Surely, you must profile your application before any optimizations, but truth to be told, D3DXFont/D3DXSprites and "fast" is mutually exclusive concepts. If they do not fit, just don't use them. Use 3rd party libraries or make your own sprite/font renderer.

Recently I've answered about how to do it here: How to draw line and font without D3DX9 in DirectX 9? Also, Google for "sprite font", "sprite batching", "texture atlases", "TTF rendering". It is not very difficult if you are familiar with API (notably vertex buffers and texturing), and there are plenty of examples on web. Don't hesitate to look for D3D11 or OpenGL examples, principles are the same.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top