You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/1-introduction/1-1-getting-started/1-1-4-abstractions.md
+381-4Lines changed: 381 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -97,15 +97,392 @@ struct VertexPositionColor
97
97
};
98
98
```
99
99
100
+
This file will contain all future vertex types as well.
101
+
100
102
## Pipeline & DeviceContext
101
103
102
-
!!! error "Explain Pipeline"
104
+
### Pipeline
105
+
106
+
What is a pipeline? It's just a immutable container of various things. It describes all state for the current thing you want to render or compute. All Vertex and Pixel or Compute shaders we might require for that render task to complete, the type of primitives we want to draw and how they are setup. Since we are coming from the Hello Triangle chapter our pipeline will not contain much, but it will grow in complexity further down the chapter road.
107
+
108
+
### PipelineFactory
109
+
110
+
`PipelineFactory` will handle the creation of `Pipeline` for us, which includes loading and compiling shaders, figuring out the right input layout by the given vertex type, for now.
111
+
112
+
### DeviceContext
113
+
114
+
`DeviceContext` is an abstraction over DX's native ID3D11DeviceContext, which has plenty of methods you need to call in order to get your triangles on screen. `DeviceContext` will know what to call specifically and handles that for you to keep the actual business logic "clean".
115
+
116
+
### Migration to Pipeline/PipelineFactory/DeviceContext
117
+
118
+
Let's create a `Pipeline.hpp` and add the following
`Pipeline` is supposed to be an immutable object, there fore all relevant fields are `private`, so that you cant accidentally set them from outside. Only `PipelineFactory` will be able to access those fields, as its creating them. Also `DeviceContext` can access them too, as it needs these to set the actual state/values.
151
+
152
+
We also create `Pipeline.cpp` with the following content:
153
+
154
+
```cpp
155
+
#include"Pipeline.hpp"
156
+
157
+
voidPipeline::SetViewport(
158
+
const float left,
159
+
const float top,
160
+
const float width,
161
+
const float height)
162
+
{
163
+
_viewport.TopLeftX = left;
164
+
_viewport.TopLeftY = top;
165
+
_viewport.Width = width;
166
+
_viewport.Height = height;
167
+
_viewport.MinDepth = 0.0f;
168
+
_viewport.MaxDepth = 1.0f;
169
+
}
170
+
```
171
+
172
+
Its quite empty for now.
173
+
174
+
Lets move on to `PipelineFactory`. Create a new file `PipelineFactory.hpp` and add the following content:
std::cout << "D3D11: Failed to create the input layout";
382
+
return false;
383
+
}
384
+
return true;
385
+
}
386
+
```
387
+
388
+
Most of the methods are now private and cannot be called from outside `PipelineFactory` and that is good. There is no need for somebody or something else to
389
+
create arbitrary shaders or other pipeline relevant things.
390
+
391
+
On to `DeviceContext`. Create a new `DeviceContext.hpp` with the following content
0 commit comments