Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Can I mix Direct3D and GDI in a single window?

133 views
Skip to first unread message

Bogdan

unread,
Aug 27, 2008, 9:00:28 AM8/27/08
to
Hi,

I've been using Direct3D in a designated window - i.e. the whole window was
dedicated to D3D device. Recently I had to add DirectShow playback to my
app. I noticed that VMR9, which is based on D3D9, when used in a windowless
mode is able to co-exist with GDI in the same window. The only thing I need
to do is to exclude VMR9's region in WM_PAINT handler. This is illustrated
in MS's samples. And it works well in my app (at least on my dev machine).
So, if VMR9 can share a window with GDI can my own D3D device do the same?
I'll appreciate any suggestions and/or pointers to on-line docs.

Thanks,
Bogdan


Richard [Microsoft Direct3D MVP]

unread,
Aug 27, 2008, 2:06:35 PM8/27/08
to
[Please do not mail me a copy of your followup]

"Bogdan" <bog...@company.com> spake the secret code
<OUHHoTEC...@TK2MSFTNGP02.phx.gbl> thusly:

>So, if VMR9 can share a window with GDI can my own D3D device do the same?

If you're running in windowed mode, it should be no problem. VMR9 is
just interacting with the window like GDI and D3D do in that situation.

If you're running in exclusive mode, it might be possible if you've made
your setup compatible with GDI dialog boxes.
--
"The Direct3D Graphics Pipeline" -- DirectX 9 draft available for download
<http://www.xmission.com/~legalize/book/download/index.html>

Legalize Adulthood! <http://blogs.xmission.com/legalize/>

Chris P.

unread,
Aug 27, 2008, 6:02:15 PM8/27/08
to

If you're GDI compatible it might work as it is, otherwise read below ...

The typically recommended method is to use a Custom Allocator (renderless
mode). Every time a new video frame arrives it calls PresentImage which
includes a pointer to the video surface. In your game main loop you can
copy this surface to your render target using StrectRect.

For rendering your basic chain of events is the following:
IDirect3DDevice9::GetRenderTarget
IDirect3DDevice9::Clear
IDirect3DDevice9::BeginScene
IDirect3DDevice9::StretchRect
IDirect3DDevice9::EndScene
IDirect3DDevice9::Present

If you are going to apply the video to a scene mesh you'll have to add
steps for that.

--
http://www.chrisnet.net/code.htm
[MS MVP for DirectShow / MediaFoundation]

Richard [Microsoft Direct3D MVP]

unread,
Aug 27, 2008, 9:26:57 PM8/27/08
to
[Please do not mail me a copy of your followup]

"Chris P." <ms...@chrisnet.net> spake the secret code
<fpqootbx3ct5$.3280jid5pbup$.d...@40tude.net> thusly:

>The typically recommended method is to use a Custom Allocator (renderless

>mode). [...]

Hey cool, I didn't realize this was supported directly with VMR9. I was
just thinking about a video effect I wanted to implement the other day
and now I know how to do it! Thanks, Chris.

Chris P.

unread,
Aug 29, 2008, 10:25:04 AM8/29/08
to
On Wed, 27 Aug 2008 18:26:57 -0700, Richard [Microsoft Direct3D MVP] wrote:

> Hey cool, I didn't realize this was supported directly with VMR9. I was
> just thinking about a video effect I wanted to implement the other day
> and now I know how to do it! Thanks, Chris.

No problem. One of these days I'll figure out how use 3D vector math so I
can actually do something useful with Direct3D.

0 new messages