Advertisement

Accessing global variables of an application from a DLL

Started by January 16, 2000 11:15 AM
0 comments, last by PSchuster 24 years, 11 months ago
Hi all !! I have a problem with DLLs !! My 3DEngine has a few Global Variables. One of them is an instance to a class CRenderer !! CRenderer has all the member variables for DirectX and Direct3D (so the backbuffer, z-buffer, and so on) and functions to render my primitives such as walls, Meshes and stuff. In my file 3dengine.cpp this looks like: ... CRenderer Renderer; .... In the header 3dengine.h: .... extern CRenderer Renderer; .... Ok, so I can access Renderer from everywhere in my program if I include 3dengine.h !! This works very fine, however I have a problem. I know want to create a DLL which is Loaded with LoadLibrary. I call Functions of this DLL using GetProcAdress. I need to go this way (I cannot use the header and use a lib) !! Now, does anyone know how I can access this global variable Renderer from my DLL ??? If I put a extern CRenderer Renderer in my DLL, the compiler works fine, but the linker gives errors !! I don''t want to pass Pointers of these instances to my dll. Thanks very much for your help, Phillip
I''m afraid you''re stuck passing a pointer to your global variable to your DLL. The point behind a DLL is that it''s memory space independent, that is, it doesn''t and can''t know what is going on in the application that summons it, unless you tell it.

This topic is closed to new replies.

Advertisement