Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > General Coding > Coding Tutorials
You last visited: Today at 07:42

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



cSilentFont v1.1 (silentchris LPD3DXFONT class)

Discussion on cSilentFont v1.1 (silentchris LPD3DXFONT class) within the Coding Tutorials forum part of the General Coding category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Apr 2011
Posts: 59
Received Thanks: 112
cSilentFont v1.1 (silentchris LPD3DXFONT class)

Code:
"cSilentFont" is a C++ class coded by silentchris.
All credits goes to silentchris and the MSDN (Microsoft).
Please credit silentchris if you use this class.

"cSilentFont" got made to make LPD3DXFONT-using easier and let it render faster.
It`s recommend to use the PreloadText function to get the highest performance
out of your LPD3DXFONT. Make sure that you only call it once for each static string.

################################################
## The 3 different drawfunctions:
################################################
1. [DrawText()]

   - Is basically left aligned without any extras.

   - Flags
	   - 1. "T_CENTER" will make the font center aligned.
	   - 2. "T_RIGHT"  will make the font right aligned.
	   - 3. "T_SHADOW" will add a shadow around the font.

   - Examples
	   - Left		: pFont->DrawText( 10, 10, 0xFFFFFFFF, NULL				, "Text" );
	   - Left (Shadow)	: pFont->DrawText( 10, 10, 0xFFFFFFFF, T_SHADOW			, "Text" );
	   - Center		: pFont->DrawText( 10, 10, 0xFFFFFFFF, T_CENTER			, "Text" );
	   - Center (Shadow): pFont->DrawText( 10, 10, 0xFFFFFFFF, T_CENTER|T_SHADOW, "Text" );
	   - Right		: pFont->DrawText( 10, 10, 0xFFFFFFFF, T_RIGHT			, "Text" );
	   - Right (Shadow)	: pFont->DrawText( 10, 10, 0xFFFFFFFF, T_RIGHT|T_SHADOW	, "Text" );

2. [DrawTextMaxLen()]

   - Will draw a left aligned text with choosable MAX-LEN.

   - Can be shadowed or non-shadowed.

   - Examples
	   - Normal: pFont->DrawTextMaxLen( 10, 10, 5, 0xFFFFFFFF, FALSE, "Text" );
	   - Shadow: pFont->DrawTextMaxLen( 10, 10, 5, 0xFFFFFFFF, TRUE , "Text" );

3. [DrawTextAutoScrolling()]

   - Will draw text which will scroll from the right to the left over and over
	 again inside the selected field.

   - You can set the speed.

   - You`ll need to add a buffer as we want it to be different for each call.

   - Examples
	   - Normal: pFont->DrawTextAutoScrolling( 10, 10, 100, 1, &buf, 0xFFFFFFFF, FALSE, "Text" );
	   - Shadow: pFont->DrawTextAutoScrolling( 10, 10, 100, 1, &buf, 0xFFFFFFFF, TRUE , "Text" );

################################################
## How to use:
################################################
1. Add this on the top of any file:
   C_SilentFont *pFont;

2. Call this once inside your Present/Endscene:
   pFont = new C_SilentFont( pDevice, "Arial", 14, FW_SEMIBOLD, FALSE );

	  Parameter 1: Your D3D Device
	  Parameter 2: The name of your font
	  Parameter 3: The size of your font
	  Parameter 4: The Weight of your font
	  Parameter 5: You want your font Italic?!

3. Before your drawing call this every frame:
   pFont->InitVolatileResources( );

4. DRAW!

5. After your drawing call this every frame:
   pFont->FreeVolatileResources( );

6. Thats it :)

################################################
## All Functions listed:
################################################
C_SilentFont( LPDIRECT3DDEVICE9 pd3dDevice, TCHAR* strFontName, INT dwFontSize, UINT dwFontFlags, BOOL Italic );
~C_SilentFont( );
LPDIRECT3DDEVICE9 GetDevice( );
LPD3DXSPRITE GetSprite( );
LPD3DXFONT GetFont( );
CHAR *GetName( );
INT GetTextLenght( CHAR *str );
INT GetTextHeight( );
UINT GetFlags( );
BOOL GetItalic( );
HRESULT PreloadText( CHAR *dwText );
HRESULT InitVolatileResources( );
HRESULT FreeVolatileResources( );
HRESULT DrawText( INT x, INT y, DWORD dwColor, DWORD dwFlags, const char *fmt, ... );
HRESULT DrawTextMaxLen( INT x, INT y, INT w, DWORD dwColor, BOOL shadowed, const char *fmt, ... );
HRESULT DrawTextAutoScrolling( INT x, INT y, INT w, INT speed, INT *pos_buf, DWORD dwColor, BOOL shadowed, const char *fmt, ... );


################################################
## Changelog:
################################################
[ v1.1 ] - Code is alot smaller now. Added Multi-Flags.
[ v1.0 ] - First Version
Sharing is caring

Download:
Attached Files
File Type: zip cSilentFont_v1.1.zip (3.7 KB, 49 views)
SILENTChris is offline  
Thanks
6 Users
Old 07/24/2011, 14:51   #2
 
Raz9r's Avatar
 
elite*gold: 297
Join Date: Dec 2010
Posts: 1,129
Received Thanks: 1,687
Chris ich liebe dich <3
Raz9r is offline  
Thanks
1 User
Old 08/01/2011, 06:39   #3
 
elite*gold: 0
Join Date: Apr 2011
Posts: 59
Received Thanks: 112
haha
SILENTChris is offline  
Reply


Similar Threads Similar Threads
cSilentFont v1.0 (silentchris LPD3DXFONT class)
07/24/2011 - Coding Tutorials - 1 Replies
"cSilentFont" is a C++ class coded and shared by silentchris. All credits goes to silentchris and the MSDN (microsoft). Please credit silentchris if you use this class. "cSilentFont" got made to make LPD3DXFONT-using easier and let it render faster. It`s recommend to use the PreloadText function to get the highest performance out of your LPD3DXFONT. Make sure that you only call it once for each static string. With "cSilentFont" you are able to draw fonts in alot different styles:
SILENTCHRIS D3D *Updated*
04/26/2011 - WarRock Hacks, Bots, Cheats & Exploits - 3 Replies
http://www.abload.de/img/hack5x4v.png Download > Click Virustotal > Click
SILENTChris D3D *update*
08/08/2010 - WarRock Hacks, Bots, Cheats & Exploits - 27 Replies
SILENTChris D3D *update* Funktion: big.png - Bilder und Fotos kostenlos auf ImageBanana hochladen Download Link: File-Upload.net - SILENTChris-D3D.rar :) Have Fun



All times are GMT +2. The time now is 07:42.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.