1

I'm trying to port some GDI/GDI+ code to Direct2D, but I'm still a little confused about which type of target is better to use (DC or Hwnd), because I found different performance depending on whether or not I used the Gpu. In particular, I found the following problems:

If I use the DCRenderTarget I can not use hardware acceleration (or Default), because I have continued violations of protected areas of memory. This does not happen if I use HwndRenderTarget.

If I use HwndRenderTarget, in general everything is fine, but if I have many window (like buttons), I lose the focus on the main window, which does not recognize the KeyPressed message, and, if I use the Gpu, performance fall a lot and strongly depend on the number of active targets (which does not happen if I use the software acceleration).

Has anyone encountered the same problems? Can you recommend something about it?

Thanks a lot!

andrea
  • 61
  • 5

1 Answers1

0

In general, if you want Direct2D to interoperate with GDI, you should use ID2D1DCRenderTarget, otherwise, use ID2D1HwndRenderTarget.

I am not quite understood what you said about the performance, do you mean the performance was bad when your main window lost focus? If that's the case, you can handle the windows status to let it stop rendering when the window was lost focus, for example inactive.

zdd
  • 8,258
  • 8
  • 46
  • 75