Sign in to follow this  
jad_salloum

Render Text to Texture [MDX]

Recommended Posts

programmer_tom    214
//sry about text formatting
//create yer texture

hr = m_pd3dDevice->CreateTexture ( (int)( m_pd3dsdBackBuffer->Width * m_fRenderTargetRatio ), // Width
(int)( m_pd3dsdBackBuffer->Height * m_fRenderTargetRatio ), // Height
1, // MipMap levels
D3DUSAGE_RENDERTARGET, // Usage
m_pd3dsdBackBuffer->Format, // Format
D3DPOOL_DEFAULT, // Pool
&m_pTextureRenderTarget, // Word to receive pointer
NULL );



// get surface

LPDIRECT3DSURFACE9 pTextureSurface;
m_pRenderTargetTexture->GetSurfaceLevel ( 0, &pTextureSurface );

//set target to texture

m_pd3dDevice->SetRenderTarget ( 0, pTextureSurface );

//draw your text.

//set target back

m_pd3dDevice->SetRenderTarget ( 0, pBackBuffer );



-programmer_tom

Share this post


Link to post
Share on other sites
jad_salloum    100
thanks for ur help guys but i don't know c++ and i think that i don't need to create a texture so here is what i did and it is giving me error on device.SetRenderTarget(0,surf); help plzzz


Surface backbuffer = device.GetBackBuffer(0, 0, BackBufferType.Mono);
Surface surf = _TArrayButtomBoard.GetSurfaceLevel(0);

// MyTexture=new Texture(device,200,200,1,Usage.RenderTarget,Format.A8B8G8R8,Pool.Default);
device.SetRenderTarget(0,surf);
gameFont.DrawText(null, "CameraYPoz = " + CameraYPoz.ToString(), new Rectangle(45,100,0,0), DrawTextFormat.NoClip, Color.WhiteSmoke);

device.SetRenderTarget(0,backbuffer);

DrawVB(device , VB , _TArrayButtomBoard , -10 , 32 , 0.0f , -10 , -30.5f ,0,0,0);



Share this post


Link to post
Share on other sites
CLoudius    126
Why don't you draw text onto a bitmap and use that as a texture.

How to calculate baselines etc.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdicpp/GDIPlus/usingGDIPlus/usingtextandfonts/obtainingfontmetrics.asp

I have also created a tokenizer and parser so I can use base HTML support.
It will calculate if the word fits on a graphics object or it needs to be drawn on the nextline.

Working tags:
Font
- Family
- Size
- Color
Paragraph
- Align
- Left
- Center
- Right
Bold
Italic
Breakline

Greetz,

Cloudius

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this