Sign in to follow this  
Jacob Roman

DirectX8 - Playing a Video in a Polygon

Recommended Posts

There are many sites that show you how to play videos using DirectShow, like DirectX4VB for example. But what I'm looking for is something on playing videos inside a polygon. A tutorial on that would be nice to have. Google can't find squat on the internet regarding this subject. And I'm still digging the the source code of the Texture3D prog in the SDK, trying to find out what functions they used to do this. I hate playing this "Wheres Waldo" kinda game with myself, so any help would be appreciated. :)

Share this post


Link to post
Share on other sites
It's dynamic texture maps i believe... Just copy the video bits to the textures surface and render it. I could be wrong though.

Share this post


Link to post
Share on other sites
Never really worked with that before. Normally I just do what I always do when texturing polygons. Load my BMP file using CreateTextureFromFile, set some attributes, draw the polygons or polygonal objects, and vwola.

Share this post


Link to post
Share on other sites
Quote:
Original post by Daggett
It's dynamic texture maps i believe... Just copy the video bits to the textures surface and render it. I could be wrong though.


I believe you are right. I haven't dealt with video before actually but I'm pretty sure there is a method of gaining access to the raw frame data at a specific time interval. You'll have to create a blank texture using IDirect3DDevice9::CreateTexture with the correct size of the video. Once that is done I suspect that you gain access to the video frame pixels and lock you texture, fill it, then unlock it and use it like any other texture.

Share this post


Link to post
Share on other sites
I haven't done anything at all with DirectShow before, but here's a link with all of the interfaces for it (since I don't know what you're using): MSDN
Look for the something along the lines of locking and unlocking, as PumpkinPieman suggests.
If it is for Direct3D, you would create a texture of the same dimensions of the video (beware of padding), and get the texture's surface level using IDirect3DTexture8::GetSurfaceLevel(). From there you would proced to lock the surface, get the surface's data, fill it in with the data from DirectShow, unlock the surface, release the surface, and then apply the texture to a primitive. However, this would be somewhat slow...

Share this post


Link to post
Share on other sites
Are you stuck usinh DirectX8? I believe I read something about DirectX9 bringing video into the pipeline to that you can now easily use it as textures without any sort of hacks like locking/copying/unlocking. It was an MSD?N article and they were really trying to hype how easy it is now to put video into the actual game environment.

If you are interested I can try to dig it up.

Share this post


Link to post
Share on other sites
Without getting into code, you are setting up a DirectShow filter that streams/converts the video data and inserts it onto a texture surface. That teture is then used to render with. There is an example in the DX8 and DX9 SDKs.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this