• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

Archived

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

Night Elf

DX 9 (2003 summer update) - ID3DXFont

10 posts in this topic

Is anyone using the new ID3DXFont interface? I''m moving my engine to DX 9 and I found a lot of new functions and some missing ones. I don''t understand the new functions completely and I don''s seem to find any tutorials on the Internet that use this new version of the ID3DXFont. (And, as usual, the SDK documentation is useless.) Can anyone explain the following functions?
GetGlyphData()
PreloadCharacters()
PreloadGlyphs()
PreloadText()
I can understand neither what the functions are supposed to do nor their parametters. And what''s all that about glyphs...? I would really appreciate your help. Mariano Ruggiero Lead Programmer ONIRIC GAMES
0

Share this post


Link to post
Share on other sites
Glyphs are the individual figures which get displayed on screen. They are different from characters, since in some languages, multiple characters may combine to form a single glyph, etc.. See GDI documentation on Glyphs for more information.

ID3DXSprite::GetGlyphData lets you get the texture and rectangle for a given glyph in ID3DXFont''s glyph cache. Dunno why you''ll really need to use it.. but if you want it, its there.

PreloadText, PreloadCharacters, and PreloadGlyphs all basically do the same thing, just with different kinds of inputs. These functions force ID3DXFont to load glyphs into its cache. If you don''t preload, then the glyphs are loaded lazily when they are first seen.

xyzzy
0

Share this post


Link to post
Share on other sites
How should I use PreloadCharacters(UINT First, UINT Last), for example? I don''t understand the parameters. Are they ASCII codes?

Could someone explain the parameters of the


GetGlyphData(
UINT Glyph,
LPDIRECT3DTEXTURE9 *ppTexture,
RECT *pBlackBox,
POINT *pCellInc
)


function?

It seems like I could use that function to provide my own texture and make a custom bitmap font. Is that so?
0

Share this post


Link to post
Share on other sites
You could use PreloadCharacters like this:

pFont->PreloadCharacters(''a'', ''z'');
pFont->PreloadCharacters(''A'', ''Z'');
pFont->PreloadCharacters(''0'', ''9'');

GetGlyphData RETURNS you a pointer to the texture ID3DXFont is using to cache the glyph. It does not let you pass one of your own in, or modify the data.

pBlackBox returns the sub-rect of the texture which contains the glyph. (The texture can contain many glyphs.)

pCellInc returns the distance from the origin of the current character to the origin of the next character.

xyzzy
0

Share this post


Link to post
Share on other sites
While we''re on the subject of the summer update to ID3DXFont, do people generally agree that it''s faster to use it now? Or is it still faster to write your own class to draw fonts in Direct3D 9?

I ask because before last summer, I wrote my own class to dynamically create a bitmap of font characters and render them in Direct3D (either using 2D or 3D quads--the same class handles both). It runs pretty fast, and doesn''t bog down the frame rate like ID3DXFont used to. However, I realize that I''ve only got a few years programming in C++ professionally, so my own D3D Font class is probably not as fast as it could be.

How much faster are the new ID3DXFont functions?
0

Share this post


Link to post
Share on other sites
Significantly. Especially if you''re doing multiple draw calls with the same font. You can run through one sprite which will sort things by texture (glyph images) and minimize state changes. It''s especially good for variable-spaced fonts.

It''s easy to use too. Give it a shot and compare timings. I bet you''ll find it''s about as fast as a good by-hand solution.

My spoon is too big.
0

Share this post


Link to post
Share on other sites
quote:
Original post by xyzzy00
GetGlyphData RETURNS you a pointer to the texture ID3DXFont is using to cache the glyph. It does not let you pass one of your own in, or modify the data.

pBlackBox returns the sub-rect of the texture which contains the glyph. (The texture can contain many glyphs.)

pCellInc returns the distance from the origin of the current character to the origin of the next character.


So, would I use it something like this?

LPDIRECT3DTEXTURE9 pTex;
RECT Rect;
POINT CellInc;
pFont->GetGlyphData(''A'', &pTexture, &BlackBox, &CellInc);


Is the first parameter OK?

I still can''t get the CellInc parameter... Could you explain it a bit better?

So, anyway, what could someone use this function for? Why would someone what this info?

Mariano Ruggiero
Lead Programmer
ONIRIC GAMES
0

Share this post


Link to post
Share on other sites
ID3DXFont / ID3DXSprite are probably faster than 99% of programmers could come up with. Drawing 500 lines of text with this interface (and doing nothing else at all) yields a frame rate of about 900fps in debug mode on my GeforceFX 5900 / Athlon XP 2000+.

You could POSSIBLY do something faster, but you probably won''t - and unless portability is a concern, you''re wasting your time.

Actually, if portability is a concern, you should still use D3DXFont for a D3D renderer, because your custom code will probably still not work as well.
0

Share this post


Link to post
Share on other sites
You could use it to prepare the font and then hand the glyph information to you for custom rendering.

Put another way, CellInc is a rendering offset used to render glyphs properly.

Very likely you will not need this function at all.


Stay Casual,

Ken
Drunken Hyena
0

Share this post


Link to post
Share on other sites
quote:
Original post by Night Elf
Is the first parameter OK?


No.. the first parameter is a glyph index.. not a character.. See GetGlyphIndices.

quote:

So, anyway, what could someone use this function for? Why would someone what this info?


In normal use of ID3DXFont, you will never need to use this function. You could use it if you wanted to look at the actual bits for each glyph. Or if you wanted to draw the glyphs yourself, without using ID3DXFont::Draw.

xyzzy
0

Share this post


Link to post
Share on other sites
quote:
Original post by DrunkenHyena
Put another way, CellInc is a rendering offset used to render glyphs properly.


Oh, I see - it''s a distance to use when rendering the glyphs, not a distance within the texture. Now I understand.


Thank you very much, you''ve all been very helpful.



Mariano Ruggiero
Lead Programmer
ONIRIC GAMES
0

Share this post


Link to post
Share on other sites