techiew / DirectXHook

DirectX 11/12 hook including a simple overlay framework.
181 stars 23 forks source link

Can't compile successfully #3

Closed inoobkk closed 3 years ago

inoobkk commented 3 years ago

Visual studio version: 2017 error: X3000 unrecognized identifier 'R'. It happens in Shaders.hlsl any solution?

techiew commented 3 years ago

Okay, so that part of the code is really hacky...

The contents of Shaders.hlsl is supposed to be interpreted as a string to the shaderData variable in Renderer.cpp while using the "R" stuff to be able to keep HLSL syntax highlighting inside the editor.

It seems your editor doesn't like how this is done, for some reason.

The quickest way to fix it would be to just copy & paste everything in Shaders.hlsl as a string into "const char* shaderData" in Renderer.cpp. But I think you should just be able to remove the R""( stuff at the beginning and end of Shaders.hlsl and it should work no?

inoobkk commented 3 years ago

Thanks, it works.

inoobkk commented 3 years ago

I get another problem now, which is "X3501 main entry point not found". I also notice the following codes(Renderer.cpp at line 104) have specified the entrypoint. ComPtr vertexShaderBlob = LoadShader(shaderData, "vs_5_0", "VS").Get(); ComPtr pixelShaderTexturesBlob = LoadShader(shaderData, "ps_5_0", "PSTex").Get(); ComPtr pixelShaderBlob = LoadShader(shaderData, "ps_5_0", "PS").Get();

techiew commented 3 years ago

Okay that is weird. I assume it's complaining about the VS, PSTex and PS functions not being found in the shaderData string. I need more info or you could try experimenting with shaderData to see if the string needs to be handled some other way. You could try printing shaderData to see if it is correct.

Edit: I just googled the error code, I think your IDE is trying to compile the .hlsl file or doing some kind of checking, which throws a compile time error. You need to exclude the .hlsl file from the build or something similar to avoid getting this error (if using Visual Studio, right click the file and click exclude from build). Easiest thing to do would be to delete the .hlsl file, but then you would need to put the contents directly into shaderData or somewhere else.

If I didn't explain it well enough then there seems to be alot of resources on this problem if you google "x3501 main entry point not found".

inoobkk commented 3 years ago

It works by excluding the .hlsl file from build. Thanks, you helped me a lot.