Advertisement
Guest User

Untitled

a guest
Feb 1st, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //How we compile HLSL files. Something similar probably exists for FX
  2. D3DX11CompileFromFile(LPCSTRfileName, 0, 0, "v_main", "vs_4_0", 0, 0, 0, &vShaderBlob, &errors, 0);
  3. if (CheckForShaderErrors(errors))
  4.     return;
  5.  
  6. bool Shader::CheckForShaderErrors(ID3D10Blob*const errors) const
  7. {
  8.     if (!errors)
  9.         return false;
  10.  
  11.     const char*const pCompileErrors = static_cast<char*>(errors->GetBufferPointer());
  12.     const size_t bufferSize = errors->GetBufferSize();
  13.  
  14.     Array<TCHAR> wcsErrors(bufferSize);
  15.     size_t outSize;
  16.     mbstowcs_s(&outSize, &wcsErrors.front(), bufferSize, pCompileErrors, bufferSize);
  17.  
  18.     std::wstringstream ss(&wcsErrors.front());
  19.     std::wstring line;
  20.  
  21.     while (std::getline(ss, line, L'\n'))
  22.         LogMgr::Error(L"SHADER") << L"{CTX_SHADER}" << line << LogMgr::Flush();
  23.  
  24.     return true;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement