DirectShow, render an avi to texture

Started by
7 comments, last by zerotheend2000 18 years, 7 months ago
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]
Advertisement
You don't appear to be copying your vertex data into the vertex buffer.

Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse

hmm, if u look at the sdk texture3d example, where would i put my code in the
InitGeometry() part, or should i say what code whould i add to make a simple square play my avi?
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
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);

Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse

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.
all im trying to do is change the sample in the dx9 sample browser named 'texture 3d' from a rotating cylinder to a flat sqaure, how would i do this?
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...

Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse

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

This topic is closed to new replies.

Advertisement