Jump to content
  • Advertisement
Sign in to follow this  
b_thangvn

Drawing screen quad using orthogonal projection?

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

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 this post


Link to post
Share on other sites
Advertisement
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]

Share this post


Link to post
Share on other sites
I don't know if it's been posted, I thought I read about this technique here at gamedev.

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

Use this as shader input:

struct VSIn
{
uint vertexId : SV_VertexID;
};

In your drawQuad method do the following:


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]

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!