Tuesday, November 8, 2011

dwFlags - optional signs, such as D architectural rendering FONT_BOLD

l strFontName - the name of the font used
l dwHeight - font height
l dwFlags - optional signs, such as D architectural rendering FONT_BOLD, Darchitectural renderingFONT_ITALIC, Darchitectural renderingFONT_ZENABLE and so on.
Get CDarchitectural renderingFont for like,architectural rendering the need to be initialized in sequence, such as:
Font = new CDarchitectural renderingFont ("Times New Roman", 16, 0); / / instantiate
Font-> InitDeviceObjects (Device);
Font-> RestoreDeviceObjects ();

9.2.2 draw the text
Use CDarchitectural renderingFont object rendering text as follows:
HRESULT CDarchitectural renderingFont:: DrawText (FLOAT x, FLOAT y, DWORD dwColor,
const TCHAR * strText, DWORD dwFlags = 0L);

l x - the x coordinate of the screen
l y - y coordinate of the screen
l dwColor - text color
l strText - String to draw
l dwFlags - optional rendering flag, the value of 0 or below: Darchitectural renderingFONT_CENTERED, Darchitectural renderingFONT_TWOSIDED, Darchitectural renderingFONT_FILTERED.
For example:
Font-> DrawText (20, 20, 0xff000000, "Hello, World");
Resource Cleanup
Delete CDarchitectural renderingFont on as before, need to make some clearance work:
Font-> InvalidateDeviceObjects ();
Font-> DeleteDeviceObjects ();
delete Font;

9.3 The function Darchitectural renderingXCreateText
This function is used to create architectural rendering text Mesh, the prototype is as follows:
HRESULT WINAPI Darchitectural renderingXCreateText (LPDIRECTarchitectural renderingDEVICE9 pDevice, HDC hDC, LPCTSTR pText, FLOAT Deviation, FLOAT Extrusion, LPDarchitectural renderingXMESH * ppMesh, LPDarchitectural renderingXBUFFER * ppAdjacency, LPGLYPHMETRICSFLOAT pGlyphMetrics);

l pDevice-Darchitectural rendering Device
l hDC - device context handle to the font description
l pText - the string to be rendered
l Deviation-TrueType font of a property, the value can not be less than 0. If 0, the default font is used
l Extrusion - the depth of the font, relative to the Z axis
l ppMesh - returned as a pointer to the generated Mesh
l ppAdjacency - return adjacency information. If you do not need this information, you can use NULL pointer
l pGlyphMetrics - structure GLYPHMETRICSFLOAT array,architectural rendering returns contour matrix data. If you do not need the data, you can set this parameter to NULL
Here's an example of how to use this function to create architectural rendering text Mesh object.
/ / Obtain a handle to a device context.HDC hdc = CreateCompatibleDC (0); / / Fill out a LOGFONT structure that describes the font "s properties.LOGFONT lf; ZeroMemory (& lf, sizeof (LOGFONT)); lf.lfHeight = 25; / / in logical unitslf.lfWidth = 12; / / in logical unitslf.lfWeight = 500; / / boldness, range 0 (light) - 1000 (bold) lf.lfItalic = false; lf.lfUnderline = false; lf. lfStrikeOut = false; lf.lfCharSet = DEFAULT_CHARSET; strcpy (lf.lfFaceName, "Times New Roman"); / / font style / / Create a font and select that font with the device context.HFONT hFont; HFONT hFontOld; hFont = CreateFontIndirect (& lf); hFontOld = (HFONT) SelectObject (hdc, hFont); / / Create the architectural rendering mesh of text.IDarchitectural renderingXMesh * Text = 0; Darchitectural renderingXCreateText (_device, hdc, "Directarchitectural rendering", 0.001f, 0.4f, & Text, 0 , 0); / / Reselect the old font, and free resources.SelectObject (hdc, hFontOld); DeleteObject (hFont); DeleteDC (hdc);
At this time, Mesh has been for like. Finally, you can render directly DrawSubset method:

No comments:

Post a Comment