Jump to content
  • Advertisement
Sign in to follow this  
stu_pidd_cow

D3D10 Orthographic view

This topic is 2993 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'm attempting to make a HUD system but I'm having trouble getting orthographic projections to work. Heres some of the code I'm using:


//...

// create the projection
D3DXMATRIX proj;
D3DXMatrixIdentity( &proj);
HUDWorld->SetMatrix( (float*)&proj);
HUDView->SetMatrix( (float*)&proj);
D3DXMatrixOrthoLH( &proj, (float)width, (float)height, 0.0f, 1.0f );
HUDProjection->SetMatrix( (float*)&proj );

//...

// move object so it is viewable
D3DXMatrixTranslation( &asd, 0.0f, 0.0f, 0.5f );
HUDWorld->SetMatrix( ( float* )&asd );



And this is the HLSL code:


matrix HUDWorld;
matrix HUDView;
matrix HUDProjection;

PS_INPUT HUD_VS( VS_INPUT input )
{
PS_INPUT output = (PS_INPUT)0;
output.Pos = input.Pos;
output.Pos = mul( input.Pos, HUDWorld );
output.Pos = mul( output.Pos, HUDView );
output.Pos = mul( output.Pos, Projection );
output.Tex = input.Tex;

return output;
}

//...



The object I'm drawing is a flat 2-sided square (dimensions 1x1) with a texture on it, though I'm not seeing anything.

The thing is, I can see *something* when I comment out the Projection line in the HLSL code, but it's not as easy to work with.

Any ideas?

Cheers.

Share this post


Link to post
Share on other sites
Advertisement
I believe your trouble is caused by supplying the wrong values with that function call, though I am not 100% sure of this.

Have you tried passing a 1.0 as width and the inversed aspect ratio as height?


Aside from this issue, have you considered not using a View and Projection matrix? If the UI is always on top of your 3D world and has no fancy depth stuff, you can probably get away with using clip-space or an transformed clip-space (using the world transformation to mimic the effect of your UI space having a (0,0) to (width,height) rectangle opposed to the (-1,1)(1,-1) clip-space).

Share this post


Link to post
Share on other sites
Pretty sure you can't use 0 as a value for the near-clip plane.

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!