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

CD3DFont question..

Started by aker_jus Dec 27, 2002 at 4:21 PM 3 replies 300+ views
Original Post
aker_jus
aker_jus
I am going to use a customized version of CD3DFont for my simple engine. CD3DFont uses 2 triangles (list) for EVERY letter, am I correct here? If so, is it possible to render 2 triangles for the whole string? That would save a lot of FPS. Thanks.
GraphicsWare|RenderTechhttp://www.graphicsware.com3D Graphics & Solutions
IFooBar
IFooBar
GDI is only used at the beginning to create teh font texture. You can load in a pre-made texture if you dont want to use GDI. But having fonts produced on the fly is very useful if you ask me. Using two triangles per string would either require you to make a uniques texture for each string, (like what mittens said) which I dont thing you''ll be willing to do. Or you''ll have to make a texture at run-time which would require the use of GDI functions. But I think with DirectX9 using GDI is not that bad, cause the path that dx takes to the GDI stuff has been fixed or something, Im not sure about this.

in short. use the triangle list (or strip)


:::Al:::
[Triple Buffer V2.0] - Resource leak imminent. Memory status: Fragile
[size=2]aliak.net
aker_jus
aker_jus
I see, thanks, I will alter the existing CD3DFont to use strips, they should be faster, right?
GraphicsWare|RenderTechhttp://www.graphicsware.com3D Graphics & Solutions
aker_jus
aker_jus
I changed the code to render the text using strips. Here is the vertex layout:

*pVertices++ = CreateTLVertex(Vec3(pos.x + 0 - 0.5f, pos.y + 0 - 0.5f, 0.0f), color, tx1, ty1);
*pVertices++ = CreateTLVertex(Vec3(pos.x + w - 0.5f, pos.y + 0 - 0.5f, 0.0f), color, tx2, ty1);
*pVertices++ = CreateTLVertex(Vec3(pos.x + 0 - 0.5f, pos.y + h - 0.5f, 0.0f), color, tx1, ty2);
*pVertices++ = CreateTLVertex(Vec3(pos.x + w - 0.5f, pos.y + h - 0.5f, 0.0f), color, tx2, ty2);

(the 0.0f is the Z, not the rhw, the rhw is 1.0f)
The problem is when I use the \n. There is something wrong with the texture coordinates, that mess up the last character of the first line with the first character of the second line.. Can u get the picture?

Anyway, my render code is:
nTri += 2;
dev.Drawprimitive(D3DPT_TRIANGLESTRIP, 0, nTri * 3); //*3 seems to work... maybe the error is here?

Thanks a lot
GraphicsWare|RenderTechhttp://www.graphicsware.com3D Graphics & Solutions

Topic Locked

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

Sign in to reply to this topic.