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

Drawing Rotated Text

Started by Tuisto Sep 12, 2010 at 2:29 PM 3 replies 750+ views
Original Post
Tuisto
Tuisto
Hey,

i am trying to draw rotated text. I was searching now for like 20 minutes for a tutorial how to draw rotated text. I can only draw non-rotated text for now.

Here's my drawing function for non-rotated text:

void DispText( LPCWSTR lpText, long lXPos, long lYPos, D3DCOLOR color, bool bBold, bool bItalic, LPDIRECT3DDEVICE9 Device ){	LPD3DXFONT lpFont;	RECT rect;	UINT unWeight;	rect.left = lXPos;	rect.right = 800;	rect.top = lYPos;	rect.bottom = rect.top + 25;	        if( bBold == true )            unWeight = FW_BOLD;	else	    unWeight = FW_NORMAL;	D3DXCreateFont( Device, 		        20, 0, 			unWeight, 0, bItalic, 			DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, 			DEFAULT_PITCH | FF_DONTCARE, 			TEXT("Courier New"), 			&lpFont );	lpFont->DrawText( NULL, lpText, -1, ▭,  0, color );	lpFont->Release();	lpFont = NULL;}



Can I modify that function or do I need to make a new one?

Thanks
Tuisto
Tuisto
Tuisto
These solutions didn't work for me. I tried to use the DrawText function of LPD3DXFONT to write directly in a sprite but it doesn't render the text.

D3DXVECTOR2 spriteCenter  = D3DXVECTOR2( 0.0f , 0.0f );D3DXVECTOR2 spriteTrans   = D3DXVECTOR2( lXPos , lYPos );D3DXVECTOR2 spriteScaling = D3DXVECTOR2( 1.0f , 1.0f );float fSpriteRot = 90;D3DXCreateSprite( Device, &lpSprite );D3DXMatrixTransformation2D( &spriteMat, NULL, 0.0, &spriteScaling, &spriteCenter, fSpriteRot, &spriteTrans );lpSprite->SetTransform( &spriteMat );lpFont->DrawText( lpSprite, lpText, -1, ▭,  0, color );lpSprite->Begin( D3DXSPRITE_ALPHABLEND );lpSprite->Draw( NULL, NULL, NULL, NULL, NULL );pSprite->End();lpFont->Release();lpFont = NULL;lpSprite->Release();lpSprite = NULL;


This is just the most important section of the code. Is there anything I forgot? The MSDN doesn't help.
Tuisto
Tuisto
The Problem does still exist :(.

Is there any possibility to write the text on a texture?
Or has someone else a solution for post number 3?

EDIT:

I've found a sample for 2D Text in the sample folder of the DX SDK. I'm gonna take a look at it.

Topic Locked

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

Sign in to reply to this topic.