Sign in to follow this  
zerotheend2000

DirectShow, render an avi to texture

Recommended Posts

hi there ive been playing around with directshow and i want to render an avi to a texture. im using the sdk samples but im having problems with working out how to get rid of that damn cylinder surface and just have a flat square surface. ive done most of the code for shoinbg a surface but i cant render the avi onto it . . how would i go about doing this, here is some of my code

	CUSTOMVERTEX triangleVertices[] = 
	{
		{250.0f, 200.0f, 0.0f, 1.0f, 0.0f, 0.0f,),
		{550.0f, 200.0f, 0.0f, 1.0f, 1.0f, 0.0f,),
		{250.0f, 400.0f, 0.0f, 1.0f, 0.0f, 1.0f,},
		{550.0f, 200.0f, 0.0f, 1.0f, 1.0f, 0.0f,),
		{550.0f, 400.0f, 0.0f, 1.0f, 1.0f, 1.0f,),

	}; 

	 if( FAILED( hr = g_pd3dDevice->CreateVertexBuffer( 6*sizeof(CUSTOMVERTEX), 0, D3DFVF_CUSTOMVERTEX,D3DPOOL_DEFAULT, &g_pVB, NULL ) ) )

 {
        Msg(TEXT("Could not create a vertex buffer!  hr=0x%x"), hr);
        return E_FAIL;
    }

    // Fill the vertex buffer. We are setting the tu and tv texture
    // coordinates, which range from 0.0 to 1.0

    CUSTOMVERTEX* pVertices;
    if ( FAILED( hr = g_pVB->Lock( 0, 0, (void**)&pVertices, 0 ) ) )
    {
        Msg(TEXT("Could not lock the vertex buffer!  hr=0x%x"), hr);
        return E_FAIL;
    }

    g_pVB->Unlock();

    // DShow: Set up filter graph with our custom renderer.
    if( FAILED( InitDShowTextureRenderer() ) )
        return E_FAIL;

    return S_OK;



then the rest is just the dx8 directshow sample for rendering an avi to texture. cna anyone help me out and explain where ive gone wrong, im pretty sure its to do with the fact that i dont fully understand how to texture to surfaces properly [Edited by - zerotheend2000 on September 1, 2005 5:55:40 AM]

Share this post


Link to post
Share on other sites
i think i need an eqivalent example of creating a square plane.

the cylinder code is as follows:

{
FLOAT theta = (2*D3DX_PI*i)/(nGrid-1.f) + (FLOAT)(D3DX_PI/2.f);

pVertices[2*i+0].position = D3DXVECTOR3( sinf(theta),-1.0f, cosf(theta) );
pVertices[2*i+0].color = 0xffffffff;
pVertices[2*i+0].tu = ((FLOAT)i)/((FLOAT)nGrid-1.f);
pVertices[2*i+0].tv = 1.0f;

pVertices[2*i+1].position = D3DXVECTOR3( sinf(theta), 1.0f, cosf(theta) );
pVertices[2*i+1].color = 0xffffffff;
pVertices[2*i+1].tu = ((FLOAT)i)/((FLOAT)nGrid-1.f);
pVertices[2*i+1].tv = 0.0f;
}



what would be a recatgular plane equivalent

Share this post


Link to post
Share on other sites

pVertices[0].position = D3DXVECTOR3(-1.f, -1.f, 0.f);
pVertices[1].position = D3DXVECTOR3( 1.f, -1.f, 0.f);
pVertices[2].position = D3DXVECTOR3( 1.f, 1.f, 0.f);
pVertices[3].position = D3DXVECTOR3(-1.f, 1.f, 0.f);

Share this post


Link to post
Share on other sites
wouldnt it be 6 elements . . to make a square dont u use 2 triangles? . . this has me a bit confused. do you see what i want to do tho? I want the example of the directshow in the sample viewer, texture3d9 to be a flat plane rather than the cylinder.

Share this post


Link to post
Share on other sites
Quote:
Original post by zerotheend2000
wouldnt it be 6 elements . . to make a square dont u use 2 triangles?
Render it as a triangle fan. Two triangles, four vertices.

If you can't figure out how to set up vertices for a basic quad, you really may want to spend some more time studying basic 3D before messing with streaming video-to-texture and suchlike...

Share this post


Link to post
Share on other sites
i know how to set up basic quads, thats not a problem, its just i cant get them to replace the code in the sample, when i do i get a wierd looking result, im just asking for a little helping hand in the right direction. i appreciate ur responses but i wouldnt be asking here if i could get the info from somewhere else

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