new IDirect3DTexture9 C++

This is a discussion on new IDirect3DTexture9 C++ within the Game Programming forums, part of the General Programming Boards category; I'm trying to make a texture wrapper for d3d 9.0c and I'm having trouble with my copy constructor. Code: TEXTURE::TEXTURE( ...

  1. #1
    Not stupid, just stupider yaya's Avatar
    Join Date
    May 2007
    Location
    Earthland
    Posts
    204

    Thumbs up new IDirect3DTexture9 C++

    I'm trying to make a texture wrapper for d3d 9.0c and I'm having trouble with my copy constructor.

    Code:
    TEXTURE::TEXTURE( const TEXTURE& temp )
    {
    	// ...
    
    	Texture = new IDirect3DTexture9;
    	*Texture = *temp.Texture;
    
    	// ...
    };
    I get the "error C2259: 'IDirect3DTexture9' : cannot instantiate abstract class" error and I know what the problem is (I think). But how am I supposed to get around this (I'm not 100% familiar with copy constructors so this could just be a general C++ question).

    Much appreciated!

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,313
    So, the member variable Texture is a pointer to IDirect3DTexture9. You do not know what is the exact type of the object that the pointer temp.Texture points to. Check the interface for IDirect3DTexture9. If it provides a clone() member function, use it:
    Code:
    Texture = temp.Texture->clone();
    If not, you might be reduced to using dynamic_cast to try all the possible derived classes of IDirect3DTexture9 until you find the correct one.

    Or maybe this TEXTURE class really should be non-copyable, in which case you should declare its copy constructor and copy assignment operator as private and do not implement them.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,230
    Anything called IBlahBlah is an abstract COM interface. You are not able to copy such objects. If the object is copyable, then there should be an exposed interface which allows you to copy it.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  4. #4
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,590
    You cannot call new on a COM object and expect it to work correctly.

    Use D3DXCreateTextureFromFile/Memory/Ex() or IDirect3DDevice9::CreateTexture() to create a pointer to a texture interface.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. deleting objects, textures, and materials
    By infernosnow in forum Game Programming
    Replies: 11
    Last Post: 07-19-2006, 05:19 AM
  2. Vectors + Classes = Confusing
    By Epo in forum C++ Programming
    Replies: 59
    Last Post: 12-18-2004, 03:42 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21