daily pastebin goal
13%
SHARE
TWEET

Untitled

a guest Jul 13th, 2018 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define STATS_FRAME  0
  2. #define STATS_DEVICE 1
  3. #include <vector>
  4. namespace {
  5. void WideToMultiByte(LPCWSTR string, std::vector<char> *output) {
  6.   const std::ctype<wchar_t> &CType = std::use_facet<std::ctype<wchar_t> >(std::locale());
  7.   std::wstring wstr(string);
  8.   output->clear();
  9.   output->resize(wstr.length() + 1);
  10.   CType._Narrow_s(wstr.data(), wstr.data() + wstr.length(), ' ', &(*output)[0], output->size());
  11. }
  12. void TW_CALL GetStatsCallback(void *value, void *clientData) {
  13.   LPCWSTR wstr = L"";
  14.   switch ((int)clientData) {
  15.     case STATS_FRAME:
  16.       wstr = DXUTGetFrameStats(DXUTIsVsyncEnabled());
  17.       break;
  18.     case STATS_DEVICE:
  19.       wstr = DXUTGetDeviceStats();
  20.       break;
  21.   }
  22.   std::vector<char> str;
  23.   WideToMultiByte(wstr, &str);
  24.   char **destPtr = (char **)value;
  25.   TwCopyCDStringToLibrary(destPtr, &str[0]);
  26. }
  27. }
  28.  
  29.  
  30. TwAddVarCB(bar, "Frame", TW_TYPE_CDSTRING, NULL, GetStatsCallback, (void *)STATS_FRAME, "Help='DX10 frame stats.'");
  31. TwAddVarCB(bar, "Device", TW_TYPE_CDSTRING, NULL, GetStatsCallback, (void *)STATS_DEVICE, "Help='DX10 device stats.'");
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top