Jump to content
  • Advertisement
Sign in to follow this  
zerotheend2000

DirectShow, render an avi to texture

This topic is 4706 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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?

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!