Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Milla.M

Member Since 13 Jun 2012
Offline Last Active Jul 17 2012 08:42 AM

Topics I've Started

The drawing is lost when window is minimized

13 July 2012 - 02:45 AM

Hi
I am drawing with directx9, windowed mode. The drawing is in dialog box . The drawing is a simple animation, and the user have option to pause the animation from button click. The problem is following:

1) The animation is paused
2) User minimizes main application
3) when main application window is restored , the drawing is lost i.e the dialog is empty

The drawing is like this ( pseudo code) :
OnBtnClikedPause()
{
	paused = true;
}
bool isRunning= true;
while (isRunning)
{
	MSG msg;
	if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
	{
		if (msg.message == WM_QUIT)
		{
			isRunning= false;
			continue;
		}
	}
	else
	{
		if( ! paused )
		{
			scene.Update();
			BeginScene();
			ClearBuffers();
			Draw();
			EndScene();
			Present();
		}
	}
}  
The updating and drawing of the scenegraph is only if the animation is not paused.

If I change the code , so that I am drawing all the time and only updating if not paused , then I am no longer seeing this problem when restoring back :
if( !paused )
{
   scene.Update();
}
BeginScene();
ClearBuffers();
Draw();
EndScene();
Present();


So I don't get it why the rendering in the dialog is lost ?
anyone have idea how to solve the problem without drawing all the time

DirectX drawing in other thread

02 July 2012 - 01:06 AM

Hi
I have some directx code that I want to run in second thread.
I read the following http://www.codermind...-Direct3D9.html which says that is ok to use directx device from other thread as long as you are not using concurrently from many threads, and I am not doing that. And that you have to call CreateDevice and CreateWindow from the same thread , and some others functions like TestCooperativeLevel, Reset etc

And I am doing the following :

1) create window and directx device in main thread

2) start second thread and do the rendering and updating there , basically :

update
BeginScene
Draw
EndScene
Present


3) Also I care to call TestCooperativeLevel, Reset, pDevice->Release and pDirect3D->Release() from the main thread.

Problem :
The code is working when I test it in debug mode. But it doesn't in relase mode i.e it seems that the rendering threads draws all fine, but my main thread seems blocked and doesn't process messages, or maybe sometimes process them very slow. If just comment the call to Present , everything is fine ( of course it doesnot draw on screen ) i.e the main thread is responsive and second thread is running too. Sooo, is there some problem when calling Present from other thread, if the window and device is created in main thread ? As I read the following http://msdn.microsof...4(v=vs.85).aspx such restriction has only on CreateDevice,TestCooperativeLevel and Release.

game message loop in plugin dll

13 June 2012 - 12:45 AM

Hi
I am developing plugin dll for thirdparty application. I want to do simple animation from my plugin dll, only when there is not messages in the main application i.e when the application is idle. The standrad way of doing this is :

while ( bDoingBackgroundProcessing )
{
	MSG msg;
	while ( ::PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) )
	{
		if ( !PumpMessage( ) )
		{
			bDoingBackgroundProcessing = FALSE;
			::PostQuitMessage( );
			break;
		}
	}
// here draw  
DrawScene();
}

But since I want to do the drawing from dll plugin, I can not this, i.e I can not modify the host application main message loop.

I already tried to put nested message loop in my dll, and it works with some problems, like some messages from the main application are not processed at all.

Anyone have suggestion how to solve this ?

PARTNERS