Jump to content
  • Advertisement
Sign in to follow this  
bkt

Importing Method into a DLL

This topic is 4846 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to make my OpenGL driver as cross-platform as possible, and I was wondering if there was a way for me to import the WndProc method from the calling application? I did not want to have to pass a pointer to the function, although, its not a big problem if I'm going to have to. Thanks.

Share this post


Link to post
Share on other sites
Advertisement
I had the same problem myself.

Think about it:

There are no .DLLs on linux. It has .SO file or something like that.
So if you have a .DLL you already imply that it's running on windows.
So you could just pass the WndProc pointer.

Alternatively you could pass a os specific pointer to the dll that contains everything neccessary to setup the dll.

like:

struct InitPlugin
{
int operatingSystem;
}

struct InitWindowsPlugin : public InitPlugin
{
WndProc* wndProcPtr;
}

int main()
{
InitWindowsPlugin init;
init.operatingSystem = OS_WINDOWS;
init.wndProcPtr = WndProc;

//open dll
//...

dll->InitDLL(init);
}




in the dll:


int DLL::InitDLL(InitPlugin* init)
{
if (init->operatingSystem != OS_WINDOWS) return RET_WRONG_SYSTEM;
else
{
do_stuff((InitWindowsPlugin*)init);
}
return RET_SUCCESS;
}

Share this post


Link to post
Share on other sites
I'll probably end up doing that. But the point was to make the renderer able to just be compiled right on Linux as much possible (without having to recode a bunch) but this is something minor.

Share this post


Link to post
Share on other sites
Well, that's what I meant. I just couldn't express myself quite right. ;)

So, what do you think about the idea?
You would have to make os specific exceptions in your code anyway to make it cross playtform.

EDIT:
Oh well, I think that would be possible (compiling the renderer for windows and linux without code changes)
just use some #ifdef __WIN32__ #endif magic in the code

Share this post


Link to post
Share on other sites
Yeah, I've already done that to setup the window class in Windows. Its not a big problem, just something I was attempting to get around, if at all possible. I'm going to design my own Input listener system, and I suppose I'll have to have a different design for Linux/OSX since there's no WndProc used.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!