1
votes

So, I want to start to make a game engine and I realized that I would have to draw 3D Objects and GUI(Immediate Mode) at the same time.

3D objects will use the perspective projection matrix and as GUI is in 2D space I will have to use Orthographic projection matrix.

So how can I implement that please anyone guide me. I'm not one of the professional Graphics programmers.

Also I'm using DirectX 11 so keep it that way.

1
You generally only use a single projection matrix at a time, but you can draw multiple render passes to the same render target each using distinct matrices. As you are new to DirectX 11, you should look at DirectX Tool Kit.Chuck Walbourn

1 Answers

0
votes

To preface my answer, when I say "draw at the same time", I mean all drawing that takes place with a single call to ID3D11DeviceContext::Draw (or DrawIndexed/DrawAuto/etc). You might mean something different.

You do not required to draw objects with orthographic and perspective projections at the same time, and this isn't very commonly done.

Generally the projection matrix is provided to a vertex shader via a shader constant (or frequently via a concatenation of the World, View and Projection matrices). When you made a draw of a perspective object, you would bind one set of constants, when drawing an orthographic one, you'd set different ones. Frequently, different shaders are used to render perspective and orthographic objects, because they generally have completely different properties (eg. lighting, etc.).

You could draw the two different types of objects at the same time, and there are several ways you could accomplish that. A straightforward way would be to provide both projection matrices to the vertex shader, and have an additional vertex stream which determines which projection matrix to use.

In some edge cases, you might get some small performance benefit from this sort of batching. I don't suggest you do that. Make you life easier and use separate draw calls for orthographic and perspective objects.