Graphics Reference
In-Depth Information
10. In
AxisLinesRenderer.cs
, change the vertex buffer creation so that each of the
Vector4
vertex positions are only an array of floats. Then, replace the color with a
texture coordinate as shown here:
axisLinesVertices = ToDispose(Buffer.Create(device,
BindFlags.VertexBuffer, new[] {
/* Vertex Position Texture UV */
// ~45x10
-1f, 0f, 0f, 1f,
0.1757f, 0.039f
,// - x-axis
1f, 0f, 0f, 1f, 0.1757f, 0.039f,// + x-axis
// SNIP... // ~135x35
0f, -1f, 0f, 1f,
0.5273f, 0.136f
,// - y-axis
// SNIP... // ~220x250
0f, 0f, -1f, 1f,
0.859f, 0.976f
, // - z-axis
// SNIP...
}));
axisLinesBinding = new VertexBufferBinding(axisLinesVertices,
Utilities.SizeOf<float>() * 6
, 0);
11. Within
TriangleRenderer.cs
, change the vertex buffer creation to use the
following vertices (be sure to also update the
VertexBufferBinding
method).
/* Vertex Position Vertex UV */
0.75f, -0.75f,
-0.001f
, 1.0f,
1.0f, 1.0f
, // Base-right
-0.75f, -0.75f,
-0.001f
, 1.0f,
0.0f, 1.0f
, // Base-left
0.0f, 0.75f,
-0.001f
, 1.0f,
0.5f, 0.0f
, // Apex
12. Within
QuadRenderer.cs
, change the vertex buffer creation as follows:
/* Vertex Position texture UV */
-0.75f, 0.75f, 0f, 1.0f,
0.0f, 0.0f
, // Top-left
0.75f, 0.75f, 0f, 1.0f,
2.0f, 0.0f
, // Top-right
0.75f, -0.75f, 0f, 1.0f,
2.0f, 2.0f
, // Base-right
-0.75f, -0.75f, 0f, 1.0f,
0.0f, 2.0f
, // Base-left
13. Compile and run (
F5
) your project. You should see the figure shown at the
beginning of this recipe.
If it looks like you are missing vertices or the primitives are drawing
incorrectly, you may have specified the incorrect size when creating
the vertex buffer binding. Make sure that it reads
Utilities.
SizeOf<float>() * 6
noting that we are using
float
(not
Vector4)
and there are six of them per vertex.