Skip to main content
gamedev.net
🔒 Locked

IDirect3DTexture problem

Started by BloodLust666 8 replies 1.4k views
Original Post
BloodLust666
BloodLust666
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...
-------------------------Unless specified otherwise, my questions pertain:Windows Platform (with the mindset to keep things multi-platform as possible)C++Visual Studio 2008OpenGL with SFML
Kibble
Kibble
You can't, you have to make textures with the IDirect3DDevice9::CreateTexture function. That will give you an error about instantiating an abstract class.
BloodLust666
BloodLust666
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?
-------------------------Unless specified otherwise, my questions pertain:Windows Platform (with the mindset to keep things multi-platform as possible)C++Visual Studio 2008OpenGL with SFML
BloodLust666
BloodLust666
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?
-------------------------Unless specified otherwise, my questions pertain:Windows Platform (with the mindset to keep things multi-platform as possible)C++Visual Studio 2008OpenGL with SFML
DrunkenHyena
DrunkenHyena
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.
Stay Casual,KenDrunken Hyena</FON
BloodLust666
BloodLust666
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]
-------------------------Unless specified otherwise, my questions pertain:Windows Platform (with the mindset to keep things multi-platform as possible)C++Visual Studio 2008OpenGL with SFML
Leviathan3328
Leviathan3328
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
}
BloodLust666
BloodLust666
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...
-------------------------Unless specified otherwise, my questions pertain:Windows Platform (with the mindset to keep things multi-platform as possible)C++Visual Studio 2008OpenGL with SFML
Muhammad Haggag
Muhammad Haggag
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];

BloodLust666
BloodLust666
ok thanks, i think i know what i need to do now.
-------------------------Unless specified otherwise, my questions pertain:Windows Platform (with the mindset to keep things multi-platform as possible)C++Visual Studio 2008OpenGL with SFML

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.