• Create Account

## Vertex buffers in DirectX 11

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

5 replies to this topic

### #1DarkRonin  Members

1080
Like
1Likes
Like

Posted 13 May 2014 - 11:52 PM

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

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.

Win32 Developer
One Of Them - Martial arts game that is mid development.

### #2kauna  Members

2918
Like
2Likes
Like

Posted 14 May 2014 - 07:02 AM

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!

### #3BornToCode  Members

1178
Like
2Likes
Like

Posted 14 May 2014 - 10:18 AM

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, 14 May 2014 - 10:18 AM.

### #4mhagain  Members

12437
Like
0Likes
Like

Posted 14 May 2014 - 11:49 AM

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.

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.

### #5DarkRonin  Members

1080
Like
0Likes
Like

Posted 14 May 2014 - 05:00 PM

Thanks guys,

Just trying to work this all out now.

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

Win32 Developer
One Of Them - Martial arts game that is mid development.

### #6mhagain  Members

12437
Like
0Likes
Like

Posted 14 May 2014 - 05:17 PM

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.

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.