Sign in to follow this  
Googol PL3X

Loading Textures

Recommended Posts

Just wondering about somthing if somone could tell me, when you load textures in Direct3D like this IDirect3DTexture9* g_pTextureA = NULL; do you need to have the image in a particular directory when you compile or just in the same directory when its running. hope that was understandable :p

Share this post


Link to post
Share on other sites
No, the compilation of code wont fail because your image resources are in the wrong folder.

IDirect3DTexture9* g_pTextureA = NULL;

This line doesn't load any textures at all. It just declares a pointer to a texture. (You can load a texture later and point to it with this though)

Share this post


Link to post
Share on other sites
First of all, there is no such thing as a stupid question.
To answer your question...
Let's take a look at the logic here.

You have a variable and object if you will that will reference an image(texture).
This object needs to know where the texture is so that it can reference it.
If your application runs without this texture being in the place you specified, the application is going to react unexpectedly.

So you have a variable/object


Texture yourTexture = null; //This will declare a texture variable and assign it to nothing.
yourTexture = someLoaderObject.LoadTexture("YourTexture/texture.jpg"); //this will load a texture. If you specified a location to a texture here and the texture is not found, it will throw an exception.



I hope this clears up some stuff.
I hope this helps.
take care.

Share this post


Link to post
Share on other sites
It depends on how you write your code.

You can test the return value from the function that creates the texture to determine if it was successful or not (which you should always do anyway).

If the texture isn't there or the function fails for some other reason, you can terminate the application or set a flag to be used later to skip rendering the texture. That flag can be the texture pointer itself being NULL.

If you do not terminate the application on a texture load failure, you must test the value of the texture pointer before you use it in any function.

But, if you test the pointer and skip setting the texture during rendering, then the application can still run without the textures being present.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this