Jump to content
  • Advertisement
Sign in to follow this  
DarkRonin

DX11 Vertex buffers in DirectX 11

This topic is 1589 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,

 

I thought it might be well worth learning DX11 (rather than studying DX9c). So, I have been playing with the tutorials over at directxtutorial.com and so far so good.

 

Currently I am at the point where I have written my own render class (loosly based on the tutorials) and have a coloured triangle rendered to the screen smile.png

 

The thing that I have noticed is different so far is that the co-ordinates seem to be different on DX11 (or is it just the way the tutorial is doing it??).

 

In the past when I have made vertex buffers in DX9c, I would specify the co-ordinates in screen space. So, if I wanted a 'quad' that was 256 x 256 I would base the vertices around 0 to 256.

 

It seems in DX11 the screen centre to 0, left side is -1, right side 1, etc...

 

Is there a way to make it work in pixel space again (without having to normalise all of my co-ordiante calculations)?

 

I am only focused on creating 2D projects at this stage.

 

Thanks in advance smile.png

Share this post


Link to post
Share on other sites
Advertisement

Do you apply a projection matrix to your vertex data?

 

Instead of calculating the projection space values on CPU, you can use a vertex shader and apply a projection matrix to your vertex data, which scales the values to the clip/projection space. 

 

Cheers!

Share this post


Link to post
Share on other sites

Why don't you create an orthographic matrix using the screen resolution for your width and height. That way you can specify your coordinate directly in pixel coordinate.

Edited by BornToCode

Share this post


Link to post
Share on other sites

Why don't you create an orthographic matrix using the screen resolution for your width and height. That way you can specify your coordinate directly in pixel coordinate.

 

Yes, this is the problem.  You were probably using D3DFVF_XYZRHW in 9 so this will give you the same behaviour.

Share this post


Link to post
Share on other sites

Thanks guys,

 

Just trying to work this all out now.

 

So are all of the view matrices etc, donr through shaders now?

Share this post


Link to post
Share on other sites

Yes, everything is shaders now.  The old world/view/projection matrix setup was quite an artificial construct to begin with anyway, and didn't really reflect how hardware actually worked (where what you'd really see would have been position multiplied by a single combined matrix).

 

That said, there are exceptions.  For certain classes of lightweight geometry you can, for example, do some of the matrix multiplication on the CPU and write the transformed position to a dynamic vertex buffer.  This kind of setup might on the surface seem more expensive, but it can enable you to build bigger batches if drawing something like 2D sprites, so it can be a valid trade-off.  Another example might be a full-screen quad, where the -1..1 range is exactly what you want (and as a bonus is completely resolution-agnostic) and you can pass it through untransformed.

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!