C++找不到文件

C++ File Not Found

本文关键字:文件 找不到 C++      更新时间:2023-10-16

早上好, 我正在使用DX11编写游戏引擎。我的问题是找不到帮助程序文件。可执行文件的路径为C:UsersaPlutonicCoderDocumentsVisual Studio 2017ProjectsGameEngineDebugGraphicsEngine.exe。帮助程序文件的路径为C:UsersaPlutonicCoderDocumentsVisual Studio 2017ProjectsGameEngineDebugColor Filescolor.psC:UsersaPlutonicCoderDocumentsVisual Studio 2017ProjectsGameEngineDebugColor Filescolor.vs。相关代码为:

bool ColorShaderclass::InitializeShader(ID3D11Device* deviceContext, HWND hwnd, LPCSTR vsFileName, LPCSTR psFileName)
{
HRESULT hresult;
ID3DBlob* errorMessage;
ID3DBlob* vertexShaderBuffer;
ID3DBlob* pixelShaderBuffer;
D3D11_INPUT_ELEMENT_DESC polygonLayout[2];
unsigned int noElements;
D3D11_BUFFER_DESC matrixBufferDesc;
errorMessage = 0;
vertexShaderBuffer = 0;
pixelShaderBuffer = 0;
hresult = D3DX11CompileFromFile(vsFileName, NULL, NULL, "ColorVertexShader", "vs_5_0", D3D10_SHADER_ENABLE_STRICTNESS, 0, NULL, &vertexShaderBuffer, &errorMessage, NULL);
if (FAILED(hresult))
{
if (errorMessage)
OutputShaderErrorMessage(errorMessage, hwnd, vsFileName);
else
MessageBox(hwnd, vsFileName, "Missing Shader File", MB_OK);
return false;
}

hresult = D3DX11CompileFromFile(psFileName, NULL, NULL, "ColorPixelShader", "ps_5_0", D3D10_SHADER_ENABLE_STRICTNESS, 0, NULL, &pixelShaderBuffer, &errorMessage, NULL);
if (FAILED(hresult))
{
if(errorMessage)
OutputShaderErrorMessage(errorMessage, hwnd, psFileName);
else
MessageBox(hwnd, vsFileName, "Missing Shader File", MB_OK);
return false;
}
bool ColorShaderclass::Initialize(ID3D11Device* device, HWND hwnd)
{
return InitializeShader(device, hwnd, ".../Color Files/color.vs", ".../Color Files/color.ps");
}

请帮助我。文件在那里并且存在,但弹出消息框。提前谢谢你

你可以试试这个:

InitializeShader(device, hwnd, Path::GetFullPath("Color Files/color.vs"), Path::GetFullPath("Color Files/color.ps"));