Archived

This topic is now archived and is closed to further replies.

Mythar

DirectX9 Fonts

Recommended Posts

Hello again, got most stuff woring in DX9 for my GUI, so i now need to do Fonts. This is the code from the Project Jedi (Delphi) for d3dx9. Problem is that this code looks nothing like the Font found in the DX9 SDK. Did they get the code wrong ? How do i make fonts in DX9 ? What method should i use to create the font ? Also wonder why DrawText has a ID3DXSprite in it ?
  PID3DXFont = ^ID3DXFont;
  ID3DXFont = interface (IUnknown)
    ['{0B8D1536-9EEC-49b0-A5AD-93CF63AFB7C6}']
    (*** ID3DXFont methods ***)

    function GetDevice(out Device : IDirect3DDevice9) : HResult; stdcall;

    function GetDescA(out Desc : TD3DXFontDescA) : HResult; stdcall;
    function GetDescW(out Desc : TD3DXFontDescW) : HResult; stdcall;

    function GetDC : HDC; stdcall;
    function GetGlyphData(Glyph : Cardinal; out Texture : IDirect3DTexture9; out BlackBox : TRect; out CellInc : TPoint) : HResult; stdcall;

    function PreloadCharacters(First, Last : Cardinal) : HResult; stdcall;
    function PreloadGlyphs(First, Last : Cardinal) : HResult; stdcall;
    function PreloadTextA(_String : PAnsiChar; Count : Integer) : HResult; stdcall;
    function PreloadTextW(_String : PWideChar; Count : Integer) : HResult; stdcall;

    function DrawTextA(Sprite : ID3DXSprite; _String : PAnsiChar; Count : Integer; const Rect : TRect; Format : LongWord; Color : TD3DColor) : Integer; stdcall;
    function DrawTextW(Sprite : ID3DXSprite; _String : PWideChar; Count : Integer; const Rect : TRect; Format : LongWord; Color : TD3DColor) : Integer; stdcall;

    function OnLostDevice : HResult; stdcall;
    function OnResetDevice : HResult; stdcall;
  End;

function D3DXCreateFontA(Device : IDirect3DDevice9; Height : Cardinal; Width : Cardinal; Weight : Cardinal; MipLevels : Cardinal; Italic : Bool; CharSet : LongWord; OutputPrecision : LongWord; Quality : LongWord; PitchAndFamily : LongWord; FaceName : PAnsiChar; out Font : ID3DXFont) : HResult; stdcall; external d3dx9dllname;
function D3DXCreateFontW(Device : IDirect3DDevice9; Height : Cardinal; Width : Cardinal; Weight : Cardinal; MipLevels : Cardinal; Italic : Bool; CharSet : LongWord; OutputPrecision : LongWord; Quality : LongWord; PitchAndFamily : LongWord; FaceName : PWideChar; out Font : ID3DXFont) : HResult; stdcall; external d3dx9dllname;

function D3DXCreateFont(Device : IDirect3DDevice9; Height : Cardinal; Width : Cardinal; Weight : Cardinal; MipLevels : Cardinal; Italic : Bool; CharSet : LongWord; OutputPrecision : LongWord; Quality : LongWord; PitchAndFamily : LongWord; FaceName : {$IFDEF UNICODE}PWideChar{$ELSE}PAnsiChar{$ENDIF}; out Font : ID3DXFont) : HResult; stdcall; external d3dx9dllname name {$IFDEF UNICODE}'D3DXCreateFontW';{$ELSE}'D3DXCreateFontA';{$ENDIF}

function D3DXCreateFontIndirectA(Device : IDirect3DDevice9; const Desc : TD3DXFontDescA; out Font : ID3DXFont) : HResult; stdcall; overload; external d3dx9dllname;
function D3DXCreateFontIndirectA(Device : IDirect3DDevice9; Desc : PD3DXFontDescA; out Font : ID3DXFont) : HResult; stdcall; overload; external d3dx9dllname;
function D3DXCreateFontIndirectW(Device : IDirect3DDevice9; const Desc : TD3DXFontDescW; out Font : ID3DXFont) : HResult; stdcall; overload; external d3dx9dllname;
function D3DXCreateFontIndirectW(Device : IDirect3DDevice9; Desc : PD3DXFontDescW; out Font : ID3DXFont) : HResult; stdcall; overload; external d3dx9dllname;

function D3DXCreateFontIndirect(Device : IDirect3DDevice9; const Desc : {$IFDEF UNICODE}TD3DXFontDescW{$ELSE}TD3DXFontDescA{$ENDIF}; out Font : ID3DXFont) : HResult; stdcall; overload; external d3dx9dllname name {$IFDEF UNICODE}'D3DXCreateFontIndirectW';{$ELSE}'D3DXCreateFontIndirectA';{$ENDIF}
function D3DXCreateFontIndirect(Device : IDirect3DDevice9; Desc : {$IFDEF UNICODE}PD3DXFontDescW{$ELSE}PD3DXFontDescA{$ENDIF}; out Font : ID3DXFont) : HResult; stdcall; overload; external d3dx9dllname name {$IFDEF UNICODE}'D3DXCreateFontIndirectW';{$ELSE}'D3DXCreateFontIndirectA';{$ENDIF}
 
[edited by - Mythar on May 20, 2004 9:29:18 PM]

Share this post


Link to post
Share on other sites
Ok, i overlooked the Summer 2003 update for DX9.

I seems the above code is correct for this DX update.

I did some checking and now Fonts are realy giving me a headage.

What ver. of DX9 should be used for Fonts ?

The current ver. i have installed is :
DirectX 9.0b 4.09.0000.0902

On this ver. the font test works, but when trying to run it on the Summer 2003 update, it dose not.

Dose this meen that the 02-Oct-2003 Summer update dose not surport the former 02-Jun-2003 release of DX9 ?

Also it seems that when i change from the Debug ver. to the non-Debug, it still leaves the d3dx9d.dll in the system, what is the correct dll that should be surported ?

Share this post


Link to post
Share on other sites
Summer Update 2003 has the new Font API. There was an older Font API previous to that, but the new one is much better.

That original Jedi code was correct for Summer Update 2003.

The sprite parameter is part of the new Font API. Font runs through the Sprite API now.

Oct 2 2003 Summer Update? I''m not sure what you''re looking at. The last non-beta SDK release was, um, in summer.

My spoon is too big.

Share this post


Link to post
Share on other sites
quote:
Original post by Mythar
Also it seems that when i change from the Debug ver. to the non-Debug, it still leaves the d3dx9d.dll in the system, what is the correct dll that should be surported ?



Switching between Debu and Release changes which DLL your app uses, it doesn''t delete the other one.



Stay Casual,

Ken
Drunken Hyena

Share this post


Link to post
Share on other sites
The sprite parameter can be nil, then it''ll create one internally. Better is to define one yourself and use that and use ID3DXFont between begin/end calls. Be sure to call begin() on the sprite with alpha, or you''ll get blocks instead of letters.

Share this post


Link to post
Share on other sites