Sign in to follow this  

Screen-Sized quad

This topic is 4202 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

I've written some post processing shaders, but cannot seem to get the quad I render to, to be the exact size of the screen. I am using this as of now:
D3DXCreateMeshFVF(2, 4, D3DXMESH_MANAGED, Vertex::FVF, D3DDevice, &PPBillboardMesh);

Vertex* v = 0;
PPBillboardMesh->LockVertexBuffer(0, (void**)&v);

float WidthOffset = (ScreenHeight/ScreenWidth) * 0.885f;

v[0] = Vertex(-WidthOffset, -0.5f, 1.2f, 0.0f, 1.0f);
v[1] = Vertex(-WidthOffset,  0.5f, 1.2f, 0.0f, 0.0f);
v[2] = Vertex( WidthOffset,  0.5f, 1.2f, 1.0f, 0.0f);
v[3] = Vertex( WidthOffset, -0.5f, 1.2f, 1.0f, 1.0f);

PPBillboardMesh->UnlockVertexBuffer();

WORD* i = 0;
PPBillboardMesh->LockIndexBuffer(0, (void**)&i);

i[0] = 0; i[1] = 1; i[2] = 2;
i[3] = 0; i[4] = 2; i[5] = 3;

PPBillboardMesh->UnlockIndexBuffer();

And just billboard it to face the camera. This gets close, but not quite the right size. How do I go about creating the correct size quad? -Chris

Share this post


Link to post
Share on other sites
Here is code that I am using in AG :


bool Renderer::RenderQuad()
{
D3DSURFACE_DESC pdesc;
DXCALL( mFrame.mpBackBuffer->GetDesc( &pdesc ) );

FilterVertex fv[ 4 ];

fv[ 0 ].x = -0.5f;
fv[ 0 ].y = -0.5f;

fv[ 1 ].x = (float32)( pdesc.Width ) -0.5f;
fv[ 1 ].y = -0.5f;

fv[ 2 ].x = (float32)( pdesc.Width ) -0.5f;
fv[ 2 ].y = (float32)( pdesc.Height )-0.5f;

fv[ 3 ].x = -0.5f;
fv[ 3 ].y = (float32)( pdesc.Height )-0.5f;

fv[ 0 ].uv0[ 0 ] = 0.0f;
fv[ 0 ].uv0[ 1 ] = 1.0f;
fv[ 0 ].uv1[ 0 ] = 0.0f;
fv[ 0 ].uv1[ 1 ] = 1.0f;

fv[ 1 ].uv0[ 0 ] = 1.0f;
fv[ 1 ].uv0[ 1 ] = 1.0f;
fv[ 1 ].uv1[ 0 ] = 1.0f;
fv[ 1 ].uv1[ 1 ] = 1.0f;

fv[ 2 ].uv0[ 0 ] = 1.0f;
fv[ 2 ].uv1[ 0 ] = 1.0f;
fv[ 2 ].uv1[ 1 ] = 0.0f;
fv[ 2 ].uv0[ 1 ] = 0.0f;

fv[ 3 ].uv0[ 0 ] = 0.0f;
fv[ 3 ].uv0[ 1 ] = 0.0f;
fv[ 3 ].uv1[ 0 ] = 0.0f;
fv[ 3 ].uv1[ 1 ] = 0.0f;

mpDevice->SetVertexShader( 0 );

mpDevice->SetFVF( FilterVertex::FVF );

mpDevice->SetVertexDeclaration( mpFilterDecl );

DXCALL( mpDevice->DrawPrimitiveUP( D3DPT_TRIANGLEFAN, 2, &( fv[ 0 ] ), sizeof( FilterVertex ) ) );

return true;
}


Share this post


Link to post
Share on other sites
Nope, I started my own game company. Right now I work in Sunnyvale, but I will probably be working at home starting next month, as my partner is moving to Denver, so there's not much point in maintaining an office...

Share this post


Link to post
Share on other sites

This topic is 4202 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.

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