Jump to content
  • Advertisement
Sign in to follow this  
streamer

drawing on texture problem

This topic is 4888 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

This is fairly simple question...I think soo. I have a texture, and in a front of texture always are drawn some messages through font based procedure. Well this is a big drawback for performance because in every single frame first the texture is displayed, and in a next step lot of loops are called for text drawing (in few colors) in a front of it. Can I draw a text ON texture, because then I need just to blit it on the screen, and save some performance, without text draw callings? And how can it be done? Thanx in advance

Share this post


Link to post
Share on other sites
Advertisement
Are you using D3DXFont to draw the text? How are you drawing the text you're talking about? This must not be a bottlenek anyway.

Share this post


Link to post
Share on other sites
Quote:
Original post by Lestat3D
Are you using D3DXFont to draw the text? How are you drawing the text you're talking about? This must not be a bottlenek anyway.


Yes I'm using ID3DXFont* interface.
This is a source of text drawing routine. If a word is started with & or @ then word is drawed with another color.


// draw backward
for(int l = SETTINGS.OUTPUT.m_iCurrentLine-1; l>SETTINGS.OUTPUT.m_iCurrentLine-13; l--)
{
// paranoia? :)
if(l < 0) break;

// copy string
lstrcpy( szMsg, SETTINGS.OUTPUT.m_chOutput[l] );
nNextLine -= 14; rct.top = nNextLine; rct.bottom = rct.top + 20;
rct.left = 25;
rct.right = m_d3dsdBackBuffer.Width - 20;

int rec_msg_count = 0;

while(1)
{
// loop throug words
TCHAR rec_word[256];
// next word...
sscanf(szMsg+rec_msg_count,"%s", rec_word);

int rec_word_length = strlen(rec_word);
rec_msg_count += rec_word_length+1;

// end of string
if(rec_msg_count > strlen(szMsg)+1) break;

// in case first char is '&' or '@' change word color
if(rec_word[0] == '&')
{
m_pD3DXFont->DrawTextA(&rec_word[1], -1, &rct, DT_CALCRECT, 0); //Calculate the size of the rect needed
m_pD3DXFont->DrawTextA(&rec_word[1], -1, &rct, DT_LEFT, fontColorGreen); //Draw the text
rct.left = rct.right+3;
}
else if(rec_word[0] == '@')
{
m_pD3DXFont->DrawTextA(&rec_word[1], -1, &rct, DT_CALCRECT, 0); //Calculate the size of the rect needed
m_pD3DXFont->DrawTextA(&rec_word[1], -1, &rct, DT_LEFT, fontColorYellow); //Draw the text
rct.left = rct.right+3;
}
else
{
// default color
m_pD3DXFont->DrawTextA(rec_word, -1, &rct, DT_CALCRECT, 0); //Calculate the size of the rect needed
m_pD3DXFont->DrawTextA(rec_word, -1, &rct, DT_LEFT, fontColor); //Draw the text
rct.left = rct.right+3;
}
}



This is why is so slow a draw of text, because in every frame there is a call to this procedure. That's why I need some help for draw on texture.

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!