Jump to content
  • Advertisement
Sign in to follow this  
jad_salloum

Render Text to Texture [MDX]

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
//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
You might need to use the MeasureString method of Font to determine the resultant texture size...

Share this post


Link to post
Share on other sites
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
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
thank God it worked , the render to texture worked finally , i didn't thought that it is that easy :)

[Edited by - jad_salloum on April 1, 2006 5:31:44 AM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!