Advertisement Jump to content
Sign in to follow this  
Jeremiah Griffin

DirectShow Being Rotated

This topic is 3103 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've come up against a rather interesting problem while using DirectShow to play a WMV video in fullscreen mode. It works great... as long as my game isn't running in fullscreen as well. If it is, the DirectShow window takes over as expected, and plays the video just as it does when the game is in windowed mode, except the video is rotated 180 degrees clockwise.

Screenshot of the video when my game is running in windowed mode (1680x1050)
Screenshot of the video when my game is running in fullscreen mode (1680x1050)

(Images not resized to also show that the letterboxing also changes.)

Code for creating the DirectShow window:
CoCreateInstance(CLSID_FilterGraph, 0, CLSCTX_INPROC, IID_IGraphBuilder, (void **)&m_graphBuilder);
m_graphBuilder->QueryInterface(IID_IMediaControl, (void **)&m_mediaControl);
m_graphBuilder->QueryInterface(IID_IVideoWindow, (void **)&m_videoWindow);
m_graphBuilder->QueryInterface(IID_IMediaEventEx, (void **)&m_mediaEvent);
m_graphBuilder->RenderFile(m_file, 0);

long mode;
if (mode == OAFALSE)


The message handling code for the drain window:
if (m_videoWindow)
m_videoWindow->NotifyOwnerMessage((OAHWND)wnd, (long)msg, (LONG_PTR)wParam, (LONG_PTR)lParam);

And the code for handling DirectShow messages:
long eventCode;
LONG_PTR wParam, lParam;
if (m_mediaEvent->GetEvent(&eventCode, &wParam, &lParam, 0) != E_ABORT)
if (eventCode == EC_COMPLETE)
m_play = false;

m_mediaEvent->FreeEventParams(eventCode, wParam, lParam);

As with most Direct3D programs, my game window is created in fullscreen mode by setting the "Windowed" member of the D3DPRESENT_PARAMS struct to false:
m_presentParams.Windowed = (m_presentParams.FullScreen_RefreshRateInHz ? false : true);

I'm also passing WS_POPUP as the CreateWindowEx() window style:
RECT size = { 0, };
size.right = m_engine->DisplayMode()->Width;
size.bottom = m_engine->DisplayMode()->Height;

DWORD style = (m_engine->SettingsMgr()->GetBool(_TEXT("display.fullscreen")) ? WS_POPUP : WS_OVERLAPPEDWINDOW & ~WS_THICKFRAME & ~WS_MAXIMIZEBOX);

AdjustWindowRect(&size, style, false);

CreateWindowEx(0, _TEXT("EngineWindowClass"), _TEXT("Game"), style, CW_USEDEFAULT, CW_USEDEFAULT, size.right - size.left, size.bottom -, 0, 0, m_class.hInstance, (LPVOID)this);

(Note that in all of the above snippets, I've removed the error checking code to make it more readable--I am checking every COM call with the SUCCEEDED() macro.)

I've looked all over Google and MSDN trying to figure this out, but I've only found questions/answers on how to intentionally rotate the DirectShow output. Maybe it's just the keywords I'm using, though.

If anyone has any insight, suggestions, or simpler/more pleasant alternatives to DirectShow, I'd greatly appreciate it.

There's also an issue with recovering from losing the device (only when it's lost to the DirectShow window) when the game window is fullscreen, but I figure that's an unrelated issue.

Share this post

Link to post
Share on other sites
I've not really used DirectShow before, so this is a stab in the dark - the fullscreen output isn't rotated, it's vertically flipped. And BMP files and DIB sections are normally specified in bottom-up order (I.e. vertically flipped). I wonder if there's some optimisation going on and DirectShow is writing directly to your window instead of going through some other step, and because of that the output is flipped? Or the video output surface is created with the height flipped (You can specify a negative height when creating DIB sections to request a top-down bitmap).

I don't really know, these are just guesses...

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!