Sign in to follow this  
beuschl

Short question about ID3D10ShaderResourceView

Recommended Posts

Hi I've only a short question about ID3D10ShaderResourceView How can I test if a variable of the ID3D10ShaderResourceView type is set yet or not so for example i have the variable ID3D10ShaderResourceView pTexture now I want to test if pTexture has assigned any value yet or not if I want it to test with: if(pTexture == NULL) oder if(!pTexture) this has no effect for me. The if statement is always false and the block after the statement is never executed (I have pTexture stored in a struct and at the beginning of the application i allocate memory for a array of this struct. So there are some ID3D10ShaderResourceView variables in memory which shouldn't have any value right now)

Share this post


Link to post
Share on other sites
ok I want to code a simple TextureManager
therefore i have the following struct

struct TextureManager
{
LPCWSTR textureName;
ID3D10ShaderResourceView* pTextureRV;
};


After program start I allocate an array of this struct. Lets say 15 elements for the beginning
When I want to add a new Texture to that array I have to check the array and find a free index (where pTextureRV is empty). And here is my problem: How can i check if the pTextureRV is empty or already filled? (pTexture == NULL or !pTexture doesn't work)

Share this post


Link to post
Share on other sites
Now I understand your problem. C++ doesn’t fill newly allocated memory with useful values. It will contain garbage. Therefore you are responsible to set initial values (in your case NULL) to all elements in the array after memory allocation.

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