Jump to content

  • Log In with Google      Sign In   
  • Create Account

D3DX11CompileFromFile doesn't work


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
12 replies to this topic

#1 proanim   Members   -  Reputation: 446

Like
0Likes
Like

Posted 15 October 2012 - 02:24 PM

I have been trying to make simple colored triangle, and everyting worked fine until i got to the point render a triangle with color shader. Why is it that D3DX11CompileFromFile function can't find the shader file even if it is placed in the project and in same folder as the exe file.

The program compiles without any errors or warning.

Also why is it that half of the program is messed up with LPCSTR and LPCWSTR conflicts when using #define UNICODE?

Sponsor:

#2 MJP   Moderators   -  Reputation: 11742

Like
0Likes
Like

Posted 15 October 2012 - 02:41 PM

When you debug in Visual Studio, the working directory is set to the directory that the project is in. So if you're not going to use an absolute path to your shader file, you need to place the shader file in the same directory as the project. Are you sure your problem is that it can't find the file?

As for UNICODE, are you defining that manually? Usually you set this in the project properties instead of defining the macro yourself.

#3 proanim   Members   -  Reputation: 446

Like
0Likes
Like

Posted 15 October 2012 - 03:22 PM

I just checked if i give absolute path it still can't find the file.

and the UNICODE i used #define UNICODE in the main header file of the project. It was defined like that on client-server sample on msdn.

#4 L. Spiro   Crossbones+   -  Reputation: 14253

Like
0Likes
Like

Posted 15 October 2012 - 03:44 PM

Again, set the Unicode character set in the project options, don’t define it manually.
Right-click your project -> Properties -> Configuration Properties -> General -> Character Set -> Use Unicode Character Set.


L. Spiro
It is amazing how often people try to be unique, and yet they are always trying to make others be like them. - L. Spiro 2011
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
I went to my local Subway once to find some guy yelling at the staff. When someone finally came to take my order and asked, “May I help you?”, I replied, “Yeah, I’ll have one asshole to go.”
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums

#5 proanim   Members   -  Reputation: 446

Like
0Likes
Like

Posted 15 October 2012 - 03:53 PM

i just did that, it is the same thing as #define UNICODE. In both cases i need to change LPCSTR to LPCWSTR

#6 L. Spiro   Crossbones+   -  Reputation: 14253

Like
1Likes
Like

Posted 15 October 2012 - 11:18 PM

i just did that, it is the same thing as #define UNICODE. In both cases i need to change LPCSTR to LPCWSTR

They are not the same. Once is scalable and reliable and one is not.

And yes, you need to change LPCSTR to LPCWSTR.
I am not sure why you are confused on this.
One is a char and one is a wchar_t. They are not the same type, and cannot be used interchangeably. By using UNICODE you have specified that you want to use wchar_t, so if you have any char’s being passed to those functions you will need to change them to wchar_t (or LPCWCHAR in your case), so what is the problem?


L. Spiro
It is amazing how often people try to be unique, and yet they are always trying to make others be like them. - L. Spiro 2011
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
I went to my local Subway once to find some guy yelling at the staff. When someone finally came to take my order and asked, “May I help you?”, I replied, “Yeah, I’ll have one asshole to go.”
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums

#7 proanim   Members   -  Reputation: 446

Like
0Likes
Like

Posted 16 October 2012 - 07:59 AM

ok i understand UNICODE now, at this point i can change everything in my program, but i still don't see why D3DX11CompileFromFile or in this case D3DX11CompileFromFileW can't find the file even with absolute path. What can cause this to happen?

#8 kauna   Crossbones+   -  Reputation: 2852

Like
0Likes
Like

Posted 16 October 2012 - 08:40 AM

Can you show the string you use for absolute path? In C/C++ the path string may not look like what you expect it to look like.

Can you confirm the error given by the D3DX11CompileFromFile?

Cheers!

#9 proanim   Members   -  Reputation: 446

Like
0Likes
Like

Posted 16 October 2012 - 10:20 AM

i think i tried every combination like:

L"color.hlsl" (and without L)
L"../shaders/color.hlsl" (and without L)
L"C:\\Documents and Settings\\...." (and without L)
L"C:/Documents and Settings/..." (and without L)

error is always the same if file is not found return file path like this:

[source lang="cpp"]// compile the vertex shader code result = D3DX11CompileFromFileW(ShaderFileName, NULL, NULL, "ColorVertexShader", "vs_5_0", D3D10_SHADER_ENABLE_STRICTNESS, 0, NULL, &vertexShaderBuffer, &errorMessage, NULL); if(FAILED(result)) { // if the shader failed to compile it should have writen something to the error message if(errorMessage) OutputShaderErrorMessage(errorMessage, hwnd, ShaderFileName); // if there was nothing in the error message then // it simply could not find the shader file itself else MessageBoxW(hwnd, ShaderFileName, L"Missing Shader File", MB_OK); return false; }[/source]

#10 L. Spiro   Crossbones+   -  Reputation: 14253

Like
1Likes
Like

Posted 16 October 2012 - 11:32 AM

Why not post the actual path of the shader?

And I mean via copy-and-paste.
Browse to the shader file, right-click it, select Properties, and copy/past the path.
Then add \ and select the file itself. Hit F2 and copy/paste.

Show result here.


L. Spiro
It is amazing how often people try to be unique, and yet they are always trying to make others be like them. - L. Spiro 2011
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
I went to my local Subway once to find some guy yelling at the staff. When someone finally came to take my order and asked, “May I help you?”, I replied, “Yeah, I’ll have one asshole to go.”
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums

#11 proanim   Members   -  Reputation: 446

Like
0Likes
Like

Posted 16 October 2012 - 11:43 AM

well this is interesting i already tried that with \\ and / in both cases it returned error now it doesn't return error but there is no colored triangle.

Edited by proanim, 16 October 2012 - 11:43 AM.


#12 Vexal   Members   -  Reputation: 416

Like
0Likes
Like

Posted 16 October 2012 - 05:50 PM

This function (and the entire D3DX library) is deprecated now. It's probably best to not rely on it.

#13 proanim   Members   -  Reputation: 446

Like
0Likes
Like

Posted 18 October 2012 - 10:11 AM

Well i found a solution, since i had .NET framework 4.5 installed, i found on the internet that it causes problems with visual studio 2010. So i uninstalled it. and reinstalled visual studio 2010 from maintanance option since it couldn't start any other way. This seems to solve every issue with the shader i had.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS