Sign in to follow this  

how do i display integers using drawtext

Recommended Posts

dave99    100
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.right=rct.left+right; 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
Zipster    2365
If you convert the integers into text, you can display them just as easily as anything else:

std::wstringstream ss;
ss << 6;

You can even arbitrarily format numbers and text together.

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