Jump to content
  • Advertisement
Sign in to follow this  
dave99

how do i display integers using drawtext

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

ok im new to directx and i have figured out how to use drawtext but i need to display integers from time to time. This helps me with error detection. any help would be greatly welcome. currently i use something like this but this is only good for displaying text and not integers. void display_text(int left,int top,int right,int bottom,LPCWSTR tmessage) { D3DXCreateFont( pd3ddevice, font_size, 0, FW_BOLD, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, TEXT("Arial"), &m_font ); LPCWSTR image_path=tmessage; RECT rct; rct.left=left; rct.top=top; rct.right=rct.left+right; rct.bottom=rct.top+ bottom; //Draw some text pd3ddevice->BeginScene(); m_font->DrawText(NULL, tmessage, -1, &rct, 0, fontColor ); pd3ddevice->EndScene(); if(m_font!= NULL) m_font->Release(); }

Share this post


Link to post
Share on other sites
Advertisement
If you convert the integers into text, you can display them just as easily as anything else:

std::wstringstream ss;
ss << 6;
display_text(ss.c_str());


You can even arbitrarily format numbers and text together.

Share this post


Link to post
Share on other sites
or...

WCHAR buffer[512];
swprintf_s(buffer, 512, L"The answer to everything is %d", 42);

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!