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.

Don't forget to read Tuesday's email newsletter for your chance to win a free copy of Construct 2!


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

Posts I've Made

In Topic: The drawing is lost when window is minimized

13 July 2012 - 06:06 AM

Thank you for the suggestion I will do that. But I still don't get why this re-rendering in WM_SIZE is needed at all. Once the drawing is displayed in the window it should stay on the window right ?

In Topic: The drawing is lost when window is minimized

13 July 2012 - 05:46 AM

You're dealing with a lost device, you'll need to draw at least once to get something back up on the screen next to reloading specific resources. You can find more info on the topic here.

I don't get lost device cause I am checking the return value of Present and throwing exception if it returns that the device is lost, and I don't get exception at all

In Topic: DirectX drawing in other thread

03 July 2012 - 12:01 AM

by this i mean, have your scenegraph updated at the secondary thread(s).
but use your draw & simlar commands on the main thread.

but then I need to have synchronization for each frame between my main thread and rendering thread, so the main thread doesn't update when the rendering thread draws.I think this would be no good.

So anyone else have other idea why the rendering in second thread doesn't work

In Topic: DirectX drawing in other thread

02 July 2012 - 08:07 AM

I can send minimum ( doesn't compile code). I should mention that the code uses wild magic 5 library for rendering, and I am using Qt , to start the second thread. The second thread starts its own message loop , so it can receive the update message . I don't know if you familiar wit qt signal/slots mechanism but this should be irrelevant here.
void Initialize( HWND parentHWND)
	// DirectX uses a projection matrix for depth in [0,1].

	// === Create the window for rendering. ===  
	// Register the window class.
	static wchar_t sWindowClass[] = L"My Window";
	wc.lpfnWndProc   = MyEventHandler;
	wc.cbClsExtra	= 0;
	wc.cbWndExtra	= 0;
	wc.hInstance	 = 0;
	wc.hIcon		 = 0;
	wc.hCursor	   =0;
	wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
	wc.lpszClassName = sWindowClass;
	wc.lpszMenuName  = 0;
	DWORD dwStyle;

	// resize it, to fit its parent
	RECT rect;
	::GetWindowRect(parentHWND, &rect);
	int width = rect.right - rect.left;
	int height = rect.bottom - rect.top;
static wchar_t sWindowName[] = L"MyWindow";
	// Create the application window.
	HWND handle = CreateWindow(sWindowClass,

	 // Create the device for rendering.
	mRenderInput.mWindowHandle = handle;
	mRenderInput.mDriver = Direct3DCreate9(D3D_SDK_VERSION);
	assertion(mRenderInput.mDriver != 0, "Failed to create Direct3D9\n");
	mRenderer = new0 Wm5::Renderer(mRenderInput, width, height,
		mColorFormat, mDepthStencilFormat, mNumMultisamples);
	// Display the window.
	ShowWindow(handle, SW_SHOW);

class MyRunner: public QObject

public slots :
  void update()

		if (mRenderer->PreDraw()) // PreDraw just calls BeginScene
			mRenderer->PostDraw(); // PostDraw just calls EndScene
			mRenderer->DisplayColorBuffer(); // DisplayColorBuffer just calls Present

	  emit(SignalUpdate()); // this post message to the second thread message loop so it can basically start the update cycle anew

class MyThread : public QThread
   void run()
	   this->exec(); // this starts message loop
HWND mainAppHwnd = GetMainHwnd();
MyThread* thread = new MyThread;
MyRunner* runner = new MyRunner;

"And if i remember correct, you should not render on a secondthread, you should render on your main thread, but do all the updating and setup all data to
just be scheduald for drawing, so that the main thread do as litle as possible when the drawing´s begins."

I don't uderstand this.
Does this mean that in my case that I should call the updating of the scenegraph, and drawing functions on second thread, but only call Present on main thread ?

By the way what problem did you solve with Sleep(1) ?

Also I can't switch to DirectX11