• Advertisement
Sign in to follow this  

D3D10 Orthographic view

This topic is 2807 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
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 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?


Share this post

Link to post
Share on other sites
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
Sign in to follow this  

  • Advertisement