3
\$\begingroup\$

How can I embed a video in a XNA application? I'm developing a card game with XNA C# and I need to send webcam video between four machines. Could anyone give me some tips about that?

\$\endgroup\$
1
\$\begingroup\$

I believe the general solution to this is to capture the webcam images and apply it to a Texture2D. This is known as rendering to a texture. You can find more information here: http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series3/Render_to_texture.php

Be warned that that tutorial is made for XNA 3.1 so it might need a bit of work porting it to XNA 4.0 code.

I've found a few webcam components/image capture facilities that are written in C# so they can be used along with the XNA framework:

https://stackoverflow.com/questions/1789684/webcam-calling-in-xna - This SO question provides a few answers and even some techniques to apply the webcam stream to an image (although it's a very dirty way in my opinion).

http://forums.create.msdn.com/forums/p/1467/9530.aspx#9530 - This forum post provides an XNA specific Webcam component that allows you to capture the images to a texture. I believe this to be fairly buggy, but the code should provide you with a good starting point.

Hope that helps!

\$\endgroup\$
  • \$\begingroup\$ That tutorial is a bit off, but I used it as the basis for my answer here, which is for 4.0: gamedev.stackexchange.com/questions/16206/… It covers rendering to a RenderTarget2D, then how to to render that to the screen (ie. exactly the same as any texture) \$\endgroup\$ – Matthew Scharley Aug 24 '11 at 4:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.