2
\$\begingroup\$

I am playing with SharpDX (Direct3D for .NET) without using "Toolkit", already finished with basic rendering 3D models. But now i am wondering how to program/create fonts for game (2D), or how to simple draw variable text to output with Direct3D? (it is not as SharpDX question as common Direct3D question, how to start with game GUIs? And what should i do to program simple GUI's like menu for a game (generally i understand that it's shaders).

\$\endgroup\$

3 Answers 3

1
\$\begingroup\$

You could use a lookup texture for the alphabet. Then draw a quad for every letter and select the right letter by texture coordinates. You don't use transformation matrixes on this of course. This is a simple way to get started.

Advanced font rendering is a complex topic and you might want to use a library like FreeType for that. However, the basic principle stays the same. It just generates the lookup texture for you from font files.

The second part of your question about graphical user interfaces is another story, so I won't explain that in much detail here. Please open another question for this if you have further questions. But basically it is the same, you draw an unprojected quad and texture it with whatever you like your interface to look like. You can then draw text on top of that. Another interesting approach is to use web technology to define your interface, there is a webkit based library called Awesomium of this.

\$\endgroup\$
0
\$\begingroup\$

BMFont is widely used in games industry. It outputs an ASCII or binary file describing the characters' position that you can use to calculate texture coordinates when drawing your text quads.

\$\endgroup\$
0
\$\begingroup\$

If using DirectX11.1 is feasible for you (it would mean restricting support only to Windows 7 and 8) you can pretty much do everything you want with Direct2D. In D2D it all comes down to simple DrawText("text", ...) calls.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .