🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Accessing global variables of an application from a DLL

Started by
0 comments, last by PSchuster 24 years, 5 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
Advertisement
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