hi everyone,
ok, I recently up till now, used static libs to partition off code that I wanted to keep in a library, then I''d link it in with my executables, just like everyone does...which worked fine..
yesterday, I got some tutorial code from a friend on how to use DLL''s and well, I implemented it
instead of exporting class definitions from the dll, I resorted to exporting a function, which would create the object for me, returning me a pointer to it. This pointer is a base class pointer, since my library is to do with DirectX. So by using this technique, I could just link with OpenGL dll and it should work fine. Everyone knows about that technique, or you should do anyway, cause it rules.
I have these classes in my dll
DXGraphics
DXSurfaceManager
DXSpriteManager
now, DXGraphics uses a DXSurfaceManager object to maintain it''s list of flipping surfaces
also, DXSpriteManager uses a DXSurfaceManager object to maintain it''s list of sprites
DXGraphics seems to execute fine. but DXSpriteManager doesnt
the constructor is like this
DXSpriteManager::DXSpriteManager(Graphics2D *gfx_object,char *logfilename): SpriteManager(logfilename)
{
//#if defined _DEBUG
logfile << "TRACE-> DXSpriteManager::DXSpriteManager(Graphics2D *, char *)" << endl;
//#endif
logfile << "assigning gfx object" << endl;
gfx = (DXGraphics2D *)gfx_object;
logfile << "Creating a surface manager for the sprite manager object" << endl;
surface_manager = new DXSurfaceManager(gfx->GetDirectDrawObject(),logfile);
logfile << "everything ok, returning" << endl;
}
Where Graphics2D * is a parent class of DXGraphics, it has a pure virtual class beneath is IGraphics, which is just a shell, I should remove that, since it does nothing really... but anyway....
the logfile is of type ofstream and it''s used to write a logfile of whats going on in my code.
everything works fine, the DXGraphics object is constructed and a Graphics2D pointer is returned to the application
that pointer is then pushed into the creation of the DXSpriteManager object, now, as you can see
surface_manager = new DXSurfaceManager(gfx->GetDirectDrawObject(),logfile);
that should use the Graphics2D * to call it''s GetDirectDrawObject function, which returns a IDirectDraw7 * back, so that it can be passed into the constructor, logfile is passed in as a ofstream &
but the code stops here, just quits...When I debug it, the debugger stops and just doesnt do anything, doesnt tell me anything, doesnt give any errors, nothing
so, you can see, my problem, thanks if you can help me, it would be great
cya !
kosh
if understanding it made and born with time, then time, is understandings greatest enemy.....
ok, I narrowed this down, in the constructor for the DXSpriteManager object I say this
gfx = (DXGraphics *)gfx_object;
where gfx is defined within the DXSpriteManager class like so:-
DXSpriteManager: public SpriteManager { protected: DXGraphics2D *gfx;
etc,etc };
now, when I say the first code segment in this message, you should think that would be ok, but it''s not, if I remove the gfx pointer from the class and make it local to the function, alike this
The DXSpriteManager.log file thats written to the disk
TRACE-> SpriteManager::SpriteManager(char *) TRACE-> DXSpriteManager::DXSpriteManager(DXGraphics2D *, char *) assigning a temp DXGraphics2D pointer assigning gfx object gfx_object = 0x00970050 gfx = 0x00970050 getting a dd7 object Creating a surface manager for the sprite manager object TRACE-> DXSurfaceManager::DXSurfaceManager(IDirectDraw7 *, ofstream &) everything ok, returning TRACE-> DXSpriteManager::~DXSpriteManager() TRACE-> DXSurfaceManager::~DXSurfaceManager()
Now, if I remove the local DXGraphics2D and rely on the class version again, remembering this is all inside the class, it worked in static libs, it just doesnt work in dll files, for some reason, I get this