Problems loading Textures from file with directx10

Started by
7 comments, last by handsomekorean 12 years, 1 month ago
Hey guys,

finally decided to post this because I could not find a solution from anywhere else.
My problem is that when I try to load a texture bmp file and create a shader resource with it and click run, I get the error message saying that creation of the shader resource view has failed (""Could not load texture: %s!").

I'm pretty sure this is a simply a problem of putting my texture files in the wrong directory. I set the Debug--> Vc+ directory-> Executable Directories to the path where my bmp textures are located, but it still gives me the same error message.

BTW, I am using Visual studio 2010

here's a screenshot of my layout and shader resource view creation code

JcAut.png
Advertisement
Hi,

have you tried \\ instead of / ?

Cheers!
you mean like texture\\t1.bmp?

Tried it and that doesn't do anything.
Hi,

Well then, have you checked the exact error code from the function call since FAILED() can mean many things.

Best regards!

[edit] Ok, I can see that you have copied the source from some D3D10 tutorial. Ensure that the file locations are correct.
I understand that the problem has something to do with the files not being in the right location.

I put the textures files in c://my documents/Visual studio/project name/project name/ Debug, and set the executable directories to that pathway, but I am still having this problem.

Here's the error message.

[color=#FF0000]First-chance exception at 0x00c11f28 in tutorial.exe: 0xC0000005: Access violation reading location 0x00000000.
Unhandled exception at 0x00c11f28 in[color=#ff0000] tutorial[color=#ff0000].exe: 0xC0000005: Access violation reading location 0x00000000.
Can you run your program under debugger line by line to see where you get the access violation? In the first message you didn't mention the access violation.

so if your .exe-file is under /debug directory, your textures should be under /debug/textures

You can also try to put the texture in the same directory as your .exe file and remove the path from the file names.

Best regards!
Wow thanks I just put the texture files in the same directory as the .exe file( visual studio 2010/projects/tutorial/tutorial and removed the path from the file names

and it works.


Can't believe it tooke me 3 hours to figure this out...Wish the books that I am reading covered stuff like this.

Just another stupid question. How do I find out where the .exe file is? Do I set the pathway under Project manager- DEbug- VC++ directories--> Executable Directories?
If this is the case, I set the pathway for executable directories as C:\Users\Loo\Documents\Visual Studio 2010\Projects\tutorial\tutorial\Debug;$(ExecutablePath), but my texture files are in C:\Users\Loo\Documents\Visual studio 2010/tutorial/tutorial/), so I am a little confused.

Thanks for the help.
You don't have touch the VC++ Directories, they contain things like where to find the .exe-files related to the Visual Studio such as compilers or include files for different libraries (DirectX). Be careful with the VC++ directories, you may render your Visual Studio non-working.

Under Configuration Properties / General you should be able to find the "output directory" and "target name" which define the location and name of the file.

Cheers!
Got it. Thanks alot

This topic is closed to new replies.

Advertisement