Several Questions

Started by
7 comments, last by firegod666 16 years, 11 months ago
1) How can I draw text into a texture, but without using sprites? Using ID3DXFont won't help because it only draws it to the device. 2) In almost each 3D game I've noticed effects that were built from animated thick semitransparent lines. Here's an example: When you click on some player you see a nice semitransparent colorfull "snake" (curved tube) circling the player. I'm just curious how this is implemented, since it doesn't seem to be made of particles, and it looks too good to be a mesh, and its definately not a line list (unless there is a way to make lines appear thick??). 3) Which of the supporting tools (libraries/utilities) that Direct3D provides, are actually used in professional game development? I'm mainly talking about D3DX (Mesh Support, Math Support, Texture Support, Effects...) and DXUT. Thanks for replies to any question...
Advertisement
Quote:Original post by UriKiller
3) Which of the supporting tools (libraries/utilities) that Direct3D provides, are actually used in professional game development? I'm mainly talking about D3DX (Mesh Support, Math Support, Texture Support, Effects...) and DXUT.

I'll let somebody else tackle your first two questions, but this one is asked here all the time. And the answer is 'all of them' -- they are definitely good enough libraries for production use. Many of us have done so, and they tend to be well optimized. Unless you're EXTREMELY hardcore, these libraries are at least as good as what you would write 'by hand'. So don't reinvent the wheel. :)

Quote:Original post by UriKiller
1) How can I draw text into a texture, but without using sprites? Using ID3DXFont won't help because it only draws it to the device.
People will likely point many different possibilities but a few time ago I did took a look at FreeType. Getting it to work isn't exactly easy but it's used by professional app (Warcraft3 comes to mind) so I guess it would be an overkill solution.
Quote:Original post by UriKiller
2) In almost each 3D game I've noticed effects that were built from animated thick semitransparent lines. Here's an example: When you click on some player you see a nice semitransparent colorfull "snake" (curved tube) circling the player.
I'm just curious how this is implemented, since it doesn't seem to be made of particles, and it looks too good to be a mesh, and its definately not a line list (unless there is a way to make lines appear thick??).
Maybe they just scale the model (or expand it along the normal) and get the effect using a stenciling technique.

Previously "Krohm"

1. I've never tried it, but couldn't you set the texture as the device's render-target before using ID3DXFont?

2. Typically, the overlaid interface is drawn using transformed-and-lit geometry. For example, when the user clicks a player, the player's position is manually projected into screen space, and a new quad positioned accordingly on screen. This new quad may be textured with a translucent ring on a transparent background. After sending this quad to the graphics device, the effect is that of a billboarded ring as you'd like.

3. Professional games make varying use of external libraries. Many developers suffer strongly from NIH and will refuse to use third-party materials, but official libraries like D3DX and DXUT are used almost exclusively.

Admiral
Ring3 Circus - Diary of a programmer, journal of a hacker.
The problem with setting the texture as the device's render-target before using ID3DXFont, is that I would like to draw the text not at the render time. It should be done without starting a rendering pipeline (calling Clear,Begin/EndScene...).
I am just trying to understand how text can be displayed on the screen but not directly by using ID3DXFont. If there is no way of doing this, then how is all the text (dynamic text, that can't just be premade images) of the GUI displayed in all the 3D games/applications?
Quote:Original post by UriKiller
1) How can I draw text into a texture, but without using sprites? Using ID3DXFont won't help because it only draws it to the device.



Hi UriKiller,

I have the exact same problem and need and after 2 days searching the web I'm no nearer a solution. I need to write text to a texture on the side of an object. Not at rendertime but periodically as the text needs to change. I can do it in DX7 using but the move to DX9 has killed my old method. So far I have this:-----

hr = D3DXCreateTextureFromFileEx( g_d3dDevice, "bluechip.bmp",0,0,D3DX_DEFAULT,D3DUSAGE_DYNAMIC,D3DFMT_UNKNOWN,D3DPOOL_SYSTEMMEM,D3DX_DEFAULT,D3DX_DEFAULT, 0xFF000000,NULL,NULL,&systex);


creating a system texture that loads a blue bit map to a texture.
then......

HDC hdc;
IDirect3DSurface9 *sur;

IDirect3DBaseTexture9 *tex = (IDirect3DBaseTexture9 *)Texture_on_mesh;

systex->GetSurfaceLevel(0,&sur);
sur->GetDC(&hdc);

SetTextColor(hdc, MAKE_RGB(255,255,255));
SelectObject(hdc,hfont);
if(ExtTextOut(hdc,0,0,0,NULL,L"Hello",10,NULL)==0)
return;
sur->ReleaseDC(hdc);
g_d3dDevice->UpdateTexture(systex, tex);

The object is loaded with the DXUT mesh functions and has a red bitmap on it
to start with so I would see a change when the new blue one was applied.

Problem I have is the UpdateTexture does swap the red for the blue one but
there is no text on it, so all the exttextout stuff didn't work even though it returned no errors and looked like it worked.

Are there any DX9 experts out there who can tell us both how to do this task of outputing text to a texture on an mesh object not at render time.





Quote:Original post by UriKiller
The problem with setting the texture as the device's render-target before using ID3DXFont, is that I would like to draw the text not at the render time. It should be done without starting a rendering pipeline (calling Clear,Begin/EndScene...).
I am just trying to understand how text can be displayed on the screen but not directly by using ID3DXFont. If there is no way of doing this, then how is all the text (dynamic text, that can't just be premade images) of the GUI displayed in all the 3D games/applications?


I'm using C# for my DirectX 9 applications but I think this is the same logic.

As you said. Waiting to a render method so you can render the text may not fit your needs. I'm developing a drawing application which needs to draw a sprite (as your text in your case) over a drawing area (RenderTarjet texture) when the user clicks on the drawing area, so I can't wait the render loop to begin. I need to do it immediately.

My solution was to change the render target just as you were suggested by TheAdmiral. Don't worry about waiting for a Render loop to begin. Just change the RenderTarget on your device and you'll be able to paint over your texture with no problems:

//Set your devices render target to your expected texture's surface.

//Don't do a Clear() or you'd erase your texture's original content

//device.BeginScene()

//draw your text here with a sprite if you like

//device.EndScene()

//you don't need to do a Present()

//Set your devices render target back to the original rendertarget.


This is what I'm doing in my drawing application and works nice. The only problem is that your destination texture must be a RenderTarjet texture and in my experience they give some problems with old video cards.

Hope this helps.
Quote:Original post by UriKiller
2) In almost each 3D game I've noticed effects that were built from animated thick semitransparent lines. Here's an example: When you click on some player you see a nice semitransparent colorfull "snake" (curved tube) circling the player.
I'm just curious how this is implemented, since it doesn't seem to be made of particles, and it looks too good to be a mesh, and its definately not a line list (unless there is a way to make lines appear thick??).
The way I implemented it was with line lists.

You could do it purely GPU based using D3D10's GS, but I had to do it using D3D9 and a CPU algorithm. Basically modify the stencil shadow algorithm - you can determine the sillhouette edges by doing a dot-product of the two face normals sharing an edge against the view direction. If one side is positive and the other side is negative you've got a sillhouette edge, so add it to a line list buffer for rendering...

hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

Quote:Original post by UriKiller
1) How can I draw text into a texture, but without using sprites? Using ID3DXFont won't help because it only draws it to the device.




Just to let you know the method I posted does work great. I only thought it wasnt working. turns out the font was so small and the texture so big I never noticed it working...DOH!

This topic is closed to new replies.

Advertisement