Advertisement

Windows C++, Multiple Window Threads, Direct2D 11

Started by August 12, 2020 07:39 PM
0 comments, last by GfxProgrammer 4 years, 5 months ago

Hi-

I am using Direct2D 11, and I have created a window class that initializes its own D2D factory and a render target for the window handle, on its own thread. I have a message pump going in the thread function and it works fine if I dont use Direct2D - if i just launch the window on a new UI thread and paint with Win32. If I use D2D, I get a blank, transparent region where the window should be. Not exactly sure how to debug this.

I have been piecing together pieces from the internet (https://docs.microsoft.com/en-us/windows/win32/direct2d/server-side-rendering-overview?redirectedfrom=MSDN#multithreading​ and this https://docs.microsoft.com/en-us/windows/win32/direct2d/multi-threaded-direct2d-apps).​ The second one mentions D3 which I am not using.

I am not doing anything special:

  1. Create thread
  2. In thread function create the window, the factory and create the message loop.
  3. Paint to the render target in the WM_PAINT message.
  4. Paint a border in Win32 - this works.

I have a handler to manage the hittesting so I can resize (the window is borderless), and that isnt running which I think is related to the transparent window.

Any advice?

Thanks,

SP

It looks like the issue is the dwStyle param on CreateWindowEx. I am creating with WS_EX_LAYERED, which doesnt work if the window is not on the main thread. Not sure why.

SP

This topic is closed to new replies.

Advertisement