🔒 Locked
IDirect3DTexture problem
Advertisement
Original Post
Is there anything wrong with this? m_pTexture = new IDirect3DTexture9[NumTextures]; I haven't put it to use yet, but I just wanna make sure i can do that...
well, if i do that and i have a class that has all the textures i want in it. How will i be able to tell one texture from the next?
does it have something to do with the "UINT levels" parameter in the CreateTexture function? are the levels the same as the number of textures?
This creates an array of Texture pointers
IDirect3DTexture9 *m_textures[NumTextures];
The you can loop through and call CreateTexture (or D3DXCreateTextureFrom*) to make the actual textures.
IDirect3DTexture9 *m_textures[NumTextures];
The you can loop through and call CreateTexture (or D3DXCreateTextureFrom*) to make the actual textures.
well what i have is a pointer to a IDirect3DTexture object in my class, then in an Init() function i want to define a new amount of textures to load. Such as:
IDirect3DTexture *m_Texture;
m_NumTexture = 5;
m_Texture = new IDirect3DTexture[m_NumTexture];
would i be able to do that? because m_Texture is a pointer
[Edited by - EvilKnuckles666 on April 3, 2005 3:31:04 AM]
IDirect3DTexture *m_Texture;
m_NumTexture = 5;
m_Texture = new IDirect3DTexture[m_NumTexture];
would i be able to do that? because m_Texture is a pointer
[Edited by - EvilKnuckles666 on April 3, 2005 3:31:04 AM]
You cant create textures by calling new on the texture object because that is just a interface to the texture object and abstract, it cant be created directly. The textures need to be created by the device.
What you will have to do is something like this:
IDirect3DTexture * m_Texture[5];
for( unsigned int i = 0; i < 5; i++ )
{
//Use the IDirect3DDevice9::CreateTexture interface create each texture
}
What you will have to do is something like this:
IDirect3DTexture * m_Texture[5];
for( unsigned int i = 0; i < 5; i++ )
{
//Use the IDirect3DDevice9::CreateTexture interface create each texture
}
ok, well, how will i be able to specific a new amount of arrays whenever i want. because i have a class that has the Texture object.
class cGraphic {
private:
IDirect3DTexture* m_Texture;
char m_NumTextures;
public:
Init(char Num);
}
cGraphics::Init(char Num)
{
m_Texture = IDirect3DTexture[Num];
}
Know what i mean? so then, whenever i clear out the interface, i can always specify a NEW amount of arrays with the init function for a differnt level that will have more or less textures than the one b4...
Also, in the IDirect3DTexture::CreateTexture(), what does the UINT Levels parameter suppose to mean? i that how i put more than one texture in one texture interface??? if so, then i could just use ONE pointer and put the textures in each of the levels...
class cGraphic {
private:
IDirect3DTexture* m_Texture;
char m_NumTextures;
public:
Init(char Num);
}
cGraphics::Init(char Num)
{
m_Texture = IDirect3DTexture[Num];
}
Know what i mean? so then, whenever i clear out the interface, i can always specify a NEW amount of arrays with the init function for a differnt level that will have more or less textures than the one b4...
Also, in the IDirect3DTexture::CreateTexture(), what does the UINT Levels parameter suppose to mean? i that how i put more than one texture in one texture interface??? if so, then i could just use ONE pointer and put the textures in each of the levels...
Allocate an array of interface pointers:
IDirect3DTexture9** m_textures = new IDirect3DTexture9*[num];
And then loop on them and create each one.
If you can't get your head around the pointer to pointer thing in the above allocation, look at it this way:
typedef IDirect3DTexture9* TextureInterfacePointer;
TextureInterfacePointer* m_textures = new TextureInterfacePointer[num];
IDirect3DTexture9** m_textures = new IDirect3DTexture9*[num];
And then loop on them and create each one.
If you can't get your head around the pointer to pointer thing in the above allocation, look at it this way:
typedef IDirect3DTexture9* TextureInterfacePointer;
TextureInterfacePointer* m_textures = new TextureInterfacePointer[num];
ok thanks, i think i know what i need to do now.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement