Guest User

Untitled

a guest
Jun 24th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. HRESULT LoadEffect(LPCWSTR pFileName, ID3D10Effect **ppEffect) {
  2. UINT HLSLFlags = D3D10_SHADER_ENABLE_STRICTNESS;
  3. #if defined(DEBUG) | defined(_DEBUG)
  4. HLSLFlags |= D3D10_SHADER_DEBUG;
  5. HLSLFlags |= D3D10_SHADER_SKIP_OPTIMIZATION;
  6. #endif
  7. *ppEffect = NULL;
  8. ID3D10Blob *pErrors = NULL;
  9. HRESULT hr;
  10.  
  11. D3DX10CreateEffectFromFile(pFileName,
  12. NULL, // pDefines
  13. NULL, // pInclude
  14. "fx_4_0",
  15. HLSLFlags,
  16. 0, // FXFlags
  17. DXUTGetD3D10Device(),
  18. NULL, // pEffectPool
  19. NULL, // pPump
  20. ppEffect,
  21. &pErrors,
  22. &hr);
  23.  
  24. if (FAILED(hr)) {
  25. std::wstringstream wss;
  26. if (pErrors == NULL) {
  27. wss << L"Unknown error loading shader: \"" << pFileName << "\".";
  28. } else {
  29. wss << L"Errors loading shader: \"" << pFileName << "\":\n";
  30. wss << (CHAR *)pErrors->GetBufferPointer();
  31. }
  32. OutputDebugString(wss.str().c_str());
  33. MessageBox(NULL, wss.str().c_str(), L"Shader Load Error", MB_ICONERROR | MB_OK);
  34. } else if (pErrors != NULL) {
  35. std::wstringstream wss;
  36. wss << L"Warnings loading shader: \"" << pFileName << "\":\n";
  37. wss << (CHAR *)pErrors->GetBufferPointer();
  38. OutputDebugString(wss.str().c_str());
  39. MessageBox(NULL, wss.str().c_str(), L"Shader Load Warning", MB_ICONEXCLAMATION | MB_OK);
  40. }
  41.  
  42. return hr;
  43. }
Add Comment
Please, Sign In to add comment