Sign in to follow this  

Creating a window inside a dll

This topic is 4377 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

Hi, As the topic says, I'm trying to create a directX window inside a dll, but it isn't working as I want it to. I´m not sure if it is a directX issue, but when I put the same code in a exe project it works. This is what happens, I create the window and a d3d device and start the message loop which looks like this:
MSG msg;
ZeroMemory( &msg, sizeof(msg) );
while( msg.message!=WM_QUIT )
{
        if( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) )
        {
	  TranslateMessage( &msg );
	  DispatchMessage( &msg );
	}
	else
	{
	  RenderFrame();
	}
}

The PeekMessage seems to always return true, but not in the exe-project? I've searched these forums and found articles about dll renderer, but it didn't solve my problem. Help anyone?

Share this post


Link to post
Share on other sites
Had same problem, it is not a direct3d issue. Create App class outside of render dll and place window creation and message loop in it ( this is the way most render engines are written - as far as i know ). Inside App class you should call render functions exposed by dll. Hope this helps. As for the reason why it doesn't work from dll, i am not shure ( i guess it has something to do with the way dll works. )

Share this post


Link to post
Share on other sites
Message loop is of course in the main.cpp of my appication, which uses the engine dll. There is no other way around, cause every application has its own specific loop requirements

edit: Tell me which part of code, cause i must get it from my laptop first

Share this post


Link to post
Share on other sites
Ok, I thought you created everything in the dll. I got it working with the messageloop and wndproc callback in a dll. It's not just a renderer, I'm working on a gameengine. I just had to create the Window in main application.. it's a bit ugly cause I export the WndProc so when I create the windowclass I have to do this Engine::WndProc to get adress... I'll see when I find a better solution. Just tired of this issue right now :P

Share this post


Link to post
Share on other sites
My engine is compiled in a dll, but i use singleton classes for window and renderer(opengl), cause the advantage to modify from every point of the app or engine, secondly i dont need more windows if i go fullscreen. So i mustn't create window all time as i start new projects.

I use something like that for creation:

engWindow *win 0 new engWindow("Test",0,0,640,480,hInst);
win->Create();
win->Show(true);

also is the initialization of the renderer in this style, so i get off the work to write it allways new.

Share this post


Link to post
Share on other sites

This topic is 4377 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this