• ### Announcements

#### Archived

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

# I have an idea, but will It slow my cpu down?

## Recommended Posts

Programmer16    2321
Ok this idea is for my font engine. My idea is to have a surface named g_pFontSurface. When I''m ready I do the math and copy the correct letters to a temporary surface, named pTempFont. Then I save that surface to a bmp file named Speech.bmp and finally I load that to my texture and paint the texture to my message box. My question is will this slow a computer down really bad?

##### Share on other sites
Nik02    4348
The file saving is very slow. Why don''t you copy the data directly from your font surface to your texture?

-Nik

##### Share on other sites
Programmer16    2321
Ok, how would I go about copying from a surface to a texture? I''m using DirectX 8. I, of course, use the IDirect3DSurface8 and IDirect3DTexture8 objects. I have a CSurface class that I made, and I am going to make a CTexture class once I get this figured out.

##### Share on other sites
Ataru    133
This might help, have your font image as src, and just create a nxn texture called dst. You can extract the surface using get surface, and then use update surface to copy individual letters as needed.

This is DX9, I belive DX8 uses CopyRect instead of UpdateSurface, but it's pretty much the same. Hope this helps.

IDirect3DSurface9 *srcSurface;IDirect3DSurface9 *dstSurface;textures[srcTexture]->GetSurfaceLevel(0,&srcSurface);textures[dstTexture]->GetSurfaceLevel(0,&dstSurface);hr =  m_pd3dDevice->UpdateSurface(srcSurface,srcRect,dstSurface,dst);

[edited by - ataru on October 9, 2003 11:43:44 AM]

##### Share on other sites
Nik02    4348
D3DXLoadSurfaceFromSurface works better with sys->sys copies.

-Nik

##### Share on other sites
Ataru    133
Better in what way? Is it faster, or is it simply more robust?

##### Share on other sites
Nik02    4348
More robust, and UpdateTexture doesn''t work on either of my machines on sys->sys copies, but LoadSurf...() does.
I have GFFX5900 and GF2MX400, if that''s relevant.
Besides, the function is optimized to do direct scanline copies if the src and dest are of same format.

Kind rgds,
Nik