Jump to content
  • Advertisement
Sign in to follow this  
Psychopathetica

Texture Array Issue (C++ 2008)

This topic is 2512 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to load a texture through a function using an array:


LPDIRECT3DTEXTURE9 Texture[6];

void Load_Texture(LPDIRECT3DTEXTURE9 *Texture, char *File_Path, int Transparency_Color)
{
D3DXCreateTextureFromFileEx(Device, File_Path, 512, 512, 0, 0, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, D3DX_FILTER_POINT, D3DX_FILTER_POINT, Transparency_Color, NULL, NULL, &Texture);
}


Now this works great using just one texture thats not an array, but when I load a texture that is an array....

Load_Texture(Texture[0], "front.png", D3DCOLOR_XRGB(0, 0, 0));


I end up with these 2 errors:

- : error C2664: 'D3DXCreateTextureFromFileExA' : cannot convert parameter 14 from 'LPDIRECT3DTEXTURE9 **' to 'LPDIRECT3DTEXTURE9 *'
- : error C2665: 'Load_Texture' : none of the 2 overloads could convert all the argument types

I was wondering, what is the correct way of doing this is? I know I'm messing up somewhere with the pointers. Thanks in advance

Share this post


Link to post
Share on other sites
Advertisement
Try to pass it as &Texture[ n ] to D3DXCreateTextureFromFileEx method giving Load_Texture an index in the array. Second option i guess is passing to the Load_Texture method *Texture[ n ] instead of Texture[ n ]

Share this post


Link to post
Share on other sites
The variable Texture in the method Load_Texture is not the same variable as the Texture[n] array I have. So instead let's call it T.


void Load_Texture(LPDIRECT3DTEXTURE9 *T, char *File_Path, int Transparency_Color)
{
D3DXCreateTextureFromFileEx(Device, File_Path, 512, 512, 0, 0, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, D3DX_FILTER_POINT, D3DX_FILTER_POINT, Transparency_Color, NULL, NULL, T);
}


And I tried using this:

Load_Texture(*Texture[0], "front.png", D3DCOLOR_XRGB(0, 0, 0));


But once again I got the error:
(error C2664: 'D3DXCreateTextureFromFileExA' : cannot convert parameter 14 from 'LPDIRECT3DTEXTURE9 **' to 'LPDIRECT3DTEXTURE9 *').

Then I did an experiment. I created a variable called Test:


LPDIRECT3DTEXTURE9 Test;


Added an address operator '&' to T in Load_Texture:

void Load_Texture(LPDIRECT3DTEXTURE9 *T, char *File_Path, int Transparency_Color)
{
D3DXCreateTextureFromFileEx(Device, File_Path, 512, 512, 0, 0, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, D3DX_FILTER_POINT, D3DX_FILTER_POINT, Transparency_Color, NULL, NULL, &T);
}



Ran it through Load_Texture and managed to duplicate the 'LPDIRECT3DTEXTURE9 **' to 'LPDIRECT3DTEXTURE9 *' error:

Load_Texture(Test, "front.png", D3DCOLOR_XRGB(0, 0, 0));


It turns out I can't use an address operator on T. I then changed the variable Test to the array I wanted to apply the texture to and vwola! It worked. Problem self resolved lol.

Share this post


Link to post
Share on other sites
Look at your last parameter of D3DXCreateTextureFromFileEx(). You are passing a LPDIRECT3DTEXTURE9*, but you're trying to get LPDIRECT3DTEXTURE9**.

Change the function code to this:
void Load_Texture(LPDIRECT3DTEXTURE9 *T, char *File_Path, int Transparency_Color)
{
D3DXCreateTextureFromFileEx(Device, File_Path, 512, 512, 0, 0, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, D3DX_FILTER_POINT, D3DX_FILTER_POINT, Transparency_Color, NULL, NULL, &(*T));
}


And call your function like this:

LPDIRECT3DTEXTURE9 myTextureArray [NUM_OF_TEXTURES];
LPCSTR file_name [NUM_OF_TEXTURES] = {"front.png", "back.png", "whoa.png", "blah_blah_blah.png", ... };
int transparency [NUM_OF_TEXTURES] = _WHO_CARES_;
for (UINT i = 0; i < NUM_OF_TEXTURES; i++)
Load_Texture (&myTextureArray, file_name, transparency);


hth.
-R

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!