XNA Creators Club Online
Page 1 of 1 (4 items)
Sort Posts: Previous Next

Transparency, XNA and Video

Last post 08/07/2009 0:17 by The ZMan. 3 replies.
  • 07/07/2009 23:59

    Transparency, XNA and Video

    Dear all,

    I'm developing a game where I have a window in the center which displays some instructions. The instructions are avi-videos that another member of my team recorded. On top of the video instructions, the game is supposed to be superimposed and transparent. That's why I originally went for XNA - I wanted to take advantage of its full 3d-capabilities to animate the game. What we want is best described with an image. Our ideal situation is something like this. That is a screenshot from "Ultrastar" which is a Singstar clone where you can import your own videos. Notice how the graphics are on top of the background video, but you can see through the gaps between the note lines? That's what we want.

    During my research, however, I found that XNA has no acceptable way to playback video, so I had to host my XNA game in a PictureBox on a Windows Form, so I could take advantage of WinForms' video capabilities, such as the managed DirectX library AudioVideoPlayback. But this introduces another serious problem: Winforms applications are drawn by GDI+ (right?) and are totally 2D. They can't do opacity like that, so I have no way to get the PictureBox with the XNA output to display transparently on top of the video.

    I've tried like 4 or 5 different solutions to this pesky problem. I've tried overriding the Paint method of the picturebox to prevent it from drawing its own background since that supposedly achieves true transparency, but all I get from that is a black background when it's rendered. I've also tried to host everything in seperate MDI-windows inside an MDI parent container, thinking I could take advantage of the fact that the form itself actually does have an opacity property in WinForms, but that introduces the problem that MDI windows cannot be shown modally and I have no control over which windows wind up on top of one another when I pile them.

    Finally, I started researching a port of my entire GUI to WPF because WPF controls all natively support opacity, but now I read that since WPF controls have no IntPtr-handle, I can't provide a target window for my XNA game to render its content to. So XNA can't be hosted inside a WPF application without interop, and then I fear the hosting control won't be a full-fledged WPF-control with the opacity that I want.

    So... this is it. I've spent about 6 months of spare time on this ***, and now I'm afraid I'm out of ideas. Can anyone help me?

    Thanks so much in advance,

    Christian
  • 08/07/2009 0:03 In reply to

    Re: Transparency, XNA and Video

    XNa 3.1 supports video, though there's some limitations and it does need to be preproceessed at compile time.
    Play Kissy Poo - a game for 4 year olds on Xbox and windows
    The ZBuffer
    News and information for XNA
      Follow The Zman on twitter, Email me
        Please read the forum FAQs - Bug/Feature reporting
          Don't forget to mark good answers and good playtest feedback when you see it!!!
  • 08/07/2009 0:06 In reply to

    Re: Transparency, XNA and Video

    Ooooh, I had no idea about that. I'm using XNA 3.0 here. This must be a relatively new release because there was nothing about video support when I did my research on it some months ago. :)

    I'll definitely look into that, since I would LOOOOOVE to be able to abandon winforms and do everything in XNA.
  • 08/07/2009 0:17 In reply to

    Re: Transparency, XNA and Video

    Yes - within the last month. http://creators.xna.com/en-US/article/xnags3.1whatsnew

    The programming model is pretty simple. You start the video playing which kicks off the sound and at any time in your render loop you can ask for the texture of the current frame and render it however you like. See http://msdn.microsoft.com/en-us/library/bb417503.aspx#ID4EZG
    Play Kissy Poo - a game for 4 year olds on Xbox and windows
    The ZBuffer
    News and information for XNA
      Follow The Zman on twitter, Email me
        Please read the forum FAQs - Bug/Feature reporting
          Don't forget to mark good answers and good playtest feedback when you see it!!!
Page 1 of 1 (4 items) Previous Next