This topic is 3554 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello :) I'm trying to render some scrolling text into my D3D app. I've tried couple of methods to render this text, everything I tried was very time consuming or not working. I've tried with ID3DXFont (and ID3DXSprites for font cache), it's epic slow for big text, reduces my frames 2-3 times. I tried writing to the DC of the texture surface with GDI, but it's too slow and most of the functions are ignoring the alpha component of the color. Now I'm trying to render the text into an offscreen surface into the system memory pool, the size of the surface is as big as the whole line of text I need to scroll, for example 4000x40. I have a texture, on which I want to copy part of that surface (a part thats exactly as big as the texture I'm copying to) and I need to offset that rect every frame. The problem is, the UpdateSurface method returns error and the DX debug output says invalid source rect on this code:
POINT destpoint;
destpoint.x = 0;
destpoint.y = 0;

// the destination rect
RECT rcdest;
rcdest.top = 0;
rcdest.left = 0;
rcdest.right = m_Width;
rcdest.bottom = m_Height;

hr = pd3dDevice->UpdateSurface(m_pOffscreenSurface, &rcdest, pSurface, &destpoint);


Now, if I specify the rcdest to be the size of the offscreen surface, the errors I get: Direct3D9: (ERROR) :pRect doesn't fit inside the surface Direct3D9: (ERROR) :Invalid dest rect specified. UpdateSurface failed That maybe comes from the fact both surfaces must be the same size, which is not my case :( Anyone could help ?

##### Share on other sites
Have you tried rendering the on-screen letters as individual sprites? It worked on those crazy old 8 bit machines... 7.14MHz FTW!

##### Share on other sites
Quote:
 Original post by Predator_MFI've tried couple of methods to render this text, everything I tried was very time consuming or not working. I've tried with ID3DXFont (and ID3DXSprites for font cache), it's epic slow for big text, reduces my frames 2-3 times. I tried writing to the DC of the texture surface with GDI, but it's too slow and most of the functions are ignoring the alpha component of the color.
How much text are you rendering, and what performance difference does this have? Dropping from 10,000 FPS to 3,000 FPS is nothing, but dropping from 60 FPS to 20 FPS is a big deal. ID3DXFont should be plenty fast unless you're doing something silly like rendering a letter at a time (And even then it'll be fine so long as you're doing it with an ID3DXSprite pointer and between a single Begin()..End() pair).

Quote:
 Original post by Predator_MFNow I'm trying to render the text into an offscreen surface into the system memory pool, the size of the surface is as big as the whole line of text I need to scroll, for example 4000x40. I have a texture, on which I want to copy part of that surface (a part thats exactly as big as the texture I'm copying to) and I need to offset that rect every frame. The problem is, the UpdateSurface method returns error and the DX debug output says invalid source rect on this code:*** Source Snippet Removed ***Now, if I specify the rcdest to be the size of the offscreen surface, the errors I get:Direct3D9: (ERROR) :pRect doesn't fit inside the surfaceDirect3D9: (ERROR) :Invalid dest rect specified. UpdateSurface failedThat maybe comes from the fact both surfaces must be the same size, which is not my case :( Anyone could help ?
What if you call IDirect3DSurface9::GetDesc on both surfaces and check the size? I suspect you've got one which is smaller than you think it is.

##### Share on other sites
Racky I get your catchy tone, seriously :D

ID3DXFont is fine for static labels here and there, not fast enough for rendering every frame for text as long as 100 words. FPS drop 100 to 40, 2.4GHz C2D/4MB cache, NVIDIA 8600GT :(

[quote="Evil Steve"]And even then it'll be fine so long as you're doing it with an ID3DXSprite pointer and between a single Begin()..End() pair)[/quote]

This is the code I use to render:
		m_pSprite->Begin( D3DXSPRITE_ALPHABLEND | D3DXSPRITE_SORT_TEXTURE);		m_pFont->DrawText( m_pSprite, m_ParsedText, -1, &rc, m_FontAlign, m_FontColor);		m_pSprite->End();

The "rc" coordinates are changing with the time thus making the text scrolling. The DrawText function is supposed to clip only the part that's inside the rect, but still, nothing changes with DT_NOCLIP, same low performance (and I'm using the latest August 2008 SDK).

About my UpdateSurface problem, yes, I was using rect coordinates bigger than the actual source surface (since GetTextExtentPoint32 returns somehow twice the height of the text), I just fixed it. It works great compared to ID3DXFont, no noticeable performance drop at all

1. 1
Rutin
29
2. 2
3. 3
4. 4
5. 5

• 13
• 13
• 11
• 10
• 13
• ### Forum Statistics

• Total Topics
632959
• Total Posts
3009464
• ### Who's Online (See full list)

There are no registered users currently online

×