Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


Texture Array Issue (C++ 2008)


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
3 replies to this topic

#1 Psychopathetica   Members   -  Reputation: 199

Like
0Likes
Like

Posted 01 February 2012 - 10:43 AM

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

Sponsor:

#2 DgekGD   Members   -  Reputation: 374

Like
0Likes
Like

Posted 01 February 2012 - 11:05 AM

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 ]

#3 Psychopathetica   Members   -  Reputation: 199

Like
0Likes
Like

Posted 01 February 2012 - 04:34 PM

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.

#4 programci_84   Members   -  Reputation: 336

Like
0Likes
Like

Posted 02 February 2012 - 12:22 AM

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[i], file_name[i], transparency[i]);

hth.
-R
There's no "hard", and "the impossible" takes just a little time.




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