# Drawing screen quad using orthogonal projection?

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

## Recommended Posts

Hi guys, So I want to draw screen quad using orthogonal projection. I already have two methods to draw screen quad: one uses frustum corner, and the other use vertex XYZRHW. The problem is I have no idea on how to do orthogonal projection. Do I start with: - defining a vertex structure with a flag like D3DFVF_XYZ - build the quad - setup camera in orthogonal mode - draw the quad Am I correct with the steps above? How do I setup a camera in orthogonal mode? I know there is this function to calculate orthogonal projection matrix: D3DXMatrixOrthoLH() but do I have to do anything else for setting up orthogonal projection? Thanks in advance for all the help. [Edited by - b_thangvn on December 24, 2009 2:52:23 AM]

##### Share on other sites
Working on this myself..

##### Share on other sites
Hi there,

Thanks for reply. If you don't mind, I would like to ask about the advantage and disadvantage of various methods used to draw screen-quad: frustum corner, vertex XYZRHW, and orthogonal projection. Why do people choose to use one from another? Also, how should I write a vertex shader according to the method that I choose? Thanks.

[Edited by - b_thangvn on December 25, 2009 5:48:57 AM]

Bump.

##### Share on other sites

In D3D10 there's a funny way of drawing a screen quad (or a generic rect).

struct VSIn
{
uint vertexId : SV_VertexID;
};

m_pD3D10Device->Draw( 4, 0 );

Implement the vertex shader this way:

    VSOut output;    if (input.vertexId == 0)    {        // First vertex    }    else if (input.vertexId == 1)    {        // Second vertex    }    else if (input.vertexId == 2)    {        // Third vertex    }    else if (input.vertexId == 3)    {        // Fourth vertex    }

If you need to draw generic rects all you need to do is to use variables and fill them in drawQuad.

If it's not funny enough, you can draw a full screen quad with just a triangle. No support for generic rects in this case.

Use: Draw(3,0) and make the vertices (and texcoords) go beyond the screen, like
0,0 -> 3,0 -> 0,3. Clipping will do the work for you.

I have such a drawQuad implemented somewhere in my framework. I suppose it's not fast or clean. I use it because it's so hacky it deserved to be implemented!

[wink]

1. 1
2. 2
Rutin
16
3. 3
4. 4
5. 5

• 9
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633717
• Total Posts
3013513
×