Skip to content

Commit 97d7796

Browse files
authored
Use row_major matrices rather than the default column_major matrices in the vertex shaders.
Also fixed incorrect window title names in the Camera(1-3-6) and Rasterizer State(1-3-5) chapter source codes. (#129)
1 parent fe35cce commit 97d7796

File tree

7 files changed

+26
-26
lines changed

7 files changed

+26
-26
lines changed

src/Cpp/1-getting-started/1-3-2-LoadingMeshes-Refactored/Assets/Shaders/Main.vs.hlsl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,25 @@ struct VSOutput
1414

1515
cbuffer PerApplication
1616
{
17-
matrix ProjectionMatrix;
17+
row_major matrix ProjectionMatrix;
1818
}
1919

2020
cbuffer PerFrame
2121
{
22-
matrix ViewMatrix;
22+
row_major matrix ViewMatrix;
2323
}
2424

2525
cbuffer PerObject
2626
{
27-
matrix WorldMatrix;
27+
row_major matrix WorldMatrix;
2828
}
2929

3030
VSOutput Main(VSInput input)
3131
{
32-
const matrix modelViewProjection = mul(ProjectionMatrix, mul(ViewMatrix, WorldMatrix));
32+
const matrix modelViewProjection = mul(WorldMatrix, mul(ViewMatrix, ProjectionMatrix));
3333

3434
VSOutput output = (VSOutput)0;
35-
output.Position = mul(modelViewProjection, float4(input.Position, 1.0f));
35+
output.Position = mul(float4(input.Position, 1.0f), modelViewProjection);
3636
output.Color = input.Color;
3737
output.Uv = input.Uv;
3838
return output;

src/Cpp/1-getting-started/1-3-2-LoadingMeshes/Assets/Shaders/Main.vs.hlsl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,25 @@ struct VSOutput
1414

1515
cbuffer PerApplication : register(b0)
1616
{
17-
matrix ProjectionMatrix;
17+
row_major matrix ProjectionMatrix;
1818
}
1919

2020
cbuffer PerFrame : register(b1)
2121
{
22-
matrix ViewMatrix;
22+
row_major matrix ViewMatrix;
2323
}
2424

2525
cbuffer PerObject : register(b2)
2626
{
27-
matrix WorldMatrix;
27+
row_major matrix WorldMatrix;
2828
}
2929

3030
VSOutput Main(VSInput input)
3131
{
32-
const matrix modelViewProjection = mul(ProjectionMatrix, mul(ViewMatrix, WorldMatrix));
32+
const matrix modelViewProjection = mul(WorldMatrix, mul(ViewMatrix, ProjectionMatrix));
3333

3434
VSOutput output = (VSOutput)0;
35-
output.Position = mul(modelViewProjection, float4(input.Position, 1.0f));
35+
output.Position = mul(float4(input.Position, 1.0f), modelViewProjection);
3636
output.Color = input.Color;
3737
output.Uv = input.Uv;
3838
return output;

src/Cpp/1-getting-started/1-3-3-DearImGui/Assets/Shaders/Main.vs.hlsl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,25 @@ struct VSOutput
1414

1515
cbuffer PerApplication
1616
{
17-
matrix ProjectionMatrix;
17+
row_major matrix ProjectionMatrix;
1818
}
1919

2020
cbuffer PerFrame
2121
{
22-
matrix ViewMatrix;
22+
row_major matrix ViewMatrix;
2323
}
2424

2525
cbuffer PerObject
2626
{
27-
matrix WorldMatrix;
27+
row_major matrix WorldMatrix;
2828
}
2929

3030
VSOutput Main(VSInput input)
3131
{
32-
const matrix modelViewProjection = mul(ProjectionMatrix, mul(ViewMatrix, WorldMatrix));
32+
const matrix modelViewProjection = mul(WorldMatrix, mul(ViewMatrix, ProjectionMatrix));
3333

3434
VSOutput output = (VSOutput)0;
35-
output.Position = mul(modelViewProjection, float4(input.Position, 1.0f));
35+
output.Position = mul(float4(input.Position, 1.0f), modelViewProjection);
3636
output.Color = input.Color;
3737
output.Uv = input.Uv;
3838
return output;

src/Cpp/1-getting-started/1-3-4-DepthBuffer/Assets/Shaders/Main.vs.hlsl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,25 @@ struct VSOutput
1414

1515
cbuffer PerApplication
1616
{
17-
matrix ProjectionMatrix;
17+
row_major matrix ProjectionMatrix;
1818
}
1919

2020
cbuffer PerFrame
2121
{
22-
matrix ViewMatrix;
22+
row_major matrix ViewMatrix;
2323
}
2424

2525
cbuffer PerObject
2626
{
27-
matrix WorldMatrix;
27+
row_major matrix WorldMatrix;
2828
}
2929

3030
VSOutput Main(VSInput input)
3131
{
32-
const matrix modelViewProjection = mul(ProjectionMatrix, mul(ViewMatrix, WorldMatrix));
32+
const matrix modelViewProjection = mul(WorldMatrix, mul(ViewMatrix, ProjectionMatrix));
3333

3434
VSOutput output = (VSOutput)0;
35-
output.Position = mul(modelViewProjection, float4(input.Position, 1.0f));
35+
output.Position = mul(float4(input.Position, 1.0f), modelViewProjection);
3636
output.Color = input.Color;
3737
output.Uv = input.Uv;
3838
return output;

src/Cpp/1-getting-started/1-3-5-RasterizerState/Assets/Shaders/Main.vs.hlsl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,25 @@ struct VSOutput
1414

1515
cbuffer PerApplication
1616
{
17-
column_major matrix ProjectionMatrix;
17+
row_major matrix ProjectionMatrix;
1818
}
1919

2020
cbuffer PerFrame
2121
{
22-
column_major matrix ViewMatrix;
22+
row_major matrix ViewMatrix;
2323
}
2424

2525
cbuffer PerObject
2626
{
27-
column_major matrix WorldMatrix;
27+
row_major matrix WorldMatrix;
2828
}
2929

3030
VSOutput Main(VSInput input)
3131
{
3232
const matrix modelViewProjection = mul(WorldMatrix, mul(ViewMatrix, ProjectionMatrix));
3333

3434
VSOutput output = (VSOutput)0;
35-
output.Position = mul(modelViewProjection, float4(input.Position, 1.0f));
35+
output.Position = mul(float4(input.Position, 1.0f), modelViewProjection);
3636
output.Color = input.Color;
3737
output.Uv = input.Uv;
3838
return output;

src/Cpp/1-getting-started/1-3-5-RasterizerState/Main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
int main()
44
{
5-
RasterizerStateApplication app{ "LearnD3D11 - Depth Buffer" };
5+
RasterizerStateApplication app{ "LearnD3D11 - Rasterizer State" };
66
app.Run();
77
return 0;
88
}

src/Cpp/1-getting-started/1-3-6-Camera/Main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
int main()
44
{
5-
CameraApplication app{ "LearnD3D11 - Depth Buffer" };
5+
CameraApplication app{ "LearnD3D11 - Camera" };
66
app.Run();
77
return 0;
88
}

0 commit comments

Comments
 (0)