drawing on texture problem
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
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.
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 backwardfor(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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement