On screen text

Started by
15 comments, last by TheHermit 21 years, 4 months ago
I havent had much luck with multiple streams either, I have the same problem as you. Is it possible that multiple streams only work with vertex shaders and/ or functions that require multiple vertex sets (such as tweening)??

I do it the old-fashioned (and slow way)... I lock the VB and iterate through each of the quads verticies setting texture coordinates as i go along. The xyz components never need to be touched...



[edited by - Entz on December 16, 2002 3:05:16 PM]
Cheers,~Entz-=-=-=-=-=-=-=-=-=-=-=-=-=-http:www.leviathan3d.com (under construction)
Advertisement
quote:Original post by Entz
Is it possible that multiple streams only work with vertex shaders and/ or functions that require multiple vertex sets (such as tweening)??

multiple streams should work with fixed function pipeline, but you need to create fvf from a declarator manually.
quote:
I do it the old-fashioned (and slow way)... I lock the VB and iterate through each of the quads verticies setting texture coordinates as i go along. The xyz components never need to be touched...

that only works for fixed-width fonts.
quote:Original post by niyaw
that only works for fixed-width fonts.


True. I figured using two different font classes: one for debugging (framerate, console, profiling, that sort of thing), and one for ''real'' on-screen text. The debug font has one priority: being fast. It has to be fast so that when using it you get a close approximation of speeds and framerates as they would be when you''re not using it, like in the release build.

The other font would need to be able to take on different font widths and precise positions, etcetera, but for debugging, this is not so important.

Hence, I use monospace fonts for debugging. It has another advantage: Not only does a monospace font ensure you don''t have to recalculate vertices every frame, it also vertically aligns your text properly, which is ideal real-time for profiling tables and such.

quote:Original post by niyaw

multiple streams should work with fixed function pipeline, but you need to create fvf from a declarator manually.


You have an example of a fvf that would work for say Stream0 = XYZ and Stream1=UV???

quote:
that only works for fixed-width fonts.


Yup, never said it didnt. You could always update the XYZ components with a bias value based on the font/character width during runtime, but I found that to be a waste..

My font engine uses a fixed x/y offset for the font (stored at design time). This looks good 90% of the time. It really comes down to the fonts you choose. Also, remember I am using a 'pre-rendered' font bitmap not an arbitrary windows font, this gives you a more little control (but less flexibility)..

I can post an example font file (w/ size declaration) if you wish...

Of course you should always do what you think is right for your engine! Someone asked how I do it, an this is it, no one said it was the right way



[edited by - Entz on December 17, 2002 1:44:54 PM]
Cheers,~Entz-=-=-=-=-=-=-=-=-=-=-=-=-=-http:www.leviathan3d.com (under construction)
Niyaw, I compiled and ran your new fontdemo. It compiled without any trouble this time. I did modify the d3dapp framework slightly so that it didn''t lock down at 60fps in full screen mode. The d3dapp framework selects the first mode available for the device at whatever resolution you choose and the first mode enumerated by d3dapp includes a screen refresh of 60htz.

Anyway, your text draws 30 or 40% faster than mine at the same resolution and color depth. I will see if I can use your font engine for now.
CD3DFont creates a quad for every letter during every draw right? That is the main reason it is so slow, I would say.

I am thinking, if you are ok with all your letters being equal sized, just have them on a bitmap and using one static quad to render each letter only index the texture based on your letter.

Or, if you want variable sized letters, create a quad for each letter and let them all remain across draw calls. Perhaps an even simpler one, though maybe it will actually add overhead, is to use a sprite to draw the letters.

I think I will mess around with these to see what kind of fps I get.

I''m going to see if I can figure out what kind of hit fps takes from Niyaw''s font, though. :D If it isn''t too bad then I will use his, heh. No use reinventing the wheel...again.
Niyaw, I noticed you changed the d3dapp code slightly in your fontdemo so that now screen refresh is 120 in fullscreen. That locks fullscreen fps at 120. Try this instead:

if( m_bWindowed )
{
m_d3dpp.BackBufferWidth = m_rcWindowClient.right - m_rcWindowClient.left;
m_d3dpp.BackBufferHeight = m_rcWindowClient.bottom - m_rcWindowClient.top;
m_d3dpp.BackBufferFormat = pAdapterInfo->d3ddmDesktop.Format;
}
else
{
m_d3dpp.BackBufferWidth = pModeInfo->Width;
m_d3dpp.BackBufferHeight = pModeInfo->Height;
m_d3dpp.BackBufferFormat = pModeInfo->Format;
m_d3dpp.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
//m_d3dpp.FullScreen_RefreshRateInHz = 120;
}

This topic is closed to new replies.

Advertisement