Jump to content
  • Advertisement
Sign in to follow this  
bengaltgrs

Screen-Sized quad

This topic is 4393 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
Advertisement
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
Thanks for the help guys, I got it now. Kind of a simple mistake actually.

SimmerD - I noticed you have Los Gatos there, do you work for Cryptic? I was actually born and raised there so it caught my eye.

-Chris

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
And here I was begining to think I was the only game developer in Los Gatos. Anyway, good luck with the company, the screenshots in your journal are very impressive.

-Chris

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!