This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch master
in repository direct3d.
View the commit online.
commit 91a0373d8623902efcb873cb2dcf7fbdec32f870
Author: Vincent Torri <vto...@outlook.fr>
AuthorDate: Sat Apr 13 08:00:08 2024 +0200
use same filename number for .c and .hlsl, change color of the rectangle, add some comments
---
src/d3d_6.c | 32 ++++++++++++++++++++++++++++----
src/shader_6.hlsl | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 62 insertions(+), 4 deletions(-)
diff --git a/src/d3d_6.c b/src/d3d_6.c
index 4a35576..01844e6 100644
--- a/src/d3d_6.c
+++ b/src/d3d_6.c
@@ -166,7 +166,7 @@ D3d *d3d_init(Window *win, int vsync)
D3D11_INPUT_ELEMENT_DESC desc_ie[] =
{
{ "POSITION", 0, DXGI_FORMAT_R32G32_UINT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
- { "COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, 2 * sizeof(UINT), D3D11_INPUT_PER_VERTEX_DATA, 0 }
+ { "COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }
};
DXGI_SWAP_CHAIN_DESC1 desc_sw;
DXGI_SWAP_CHAIN_FULLSCREEN_DESC desc_fs;
@@ -298,7 +298,7 @@ D3d *d3d_init(Window *win, int vsync)
flags |= D3DCOMPILE_DEBUG;
#endif
vs_blob = NULL;
- res = D3DCompileFromFile(L"shader_5.hlsl",
+ res = D3DCompileFromFile(L"shader_6.hlsl",
NULL,
D3D_COMPILE_STANDARD_FILE_INCLUDE,
"main_vs",
@@ -343,7 +343,7 @@ D3d *d3d_init(Window *win, int vsync)
/* Pixel shader */
ps_blob = NULL;
- res = D3DCompileFromFile(L"shader_5.hlsl",
+ res = D3DCompileFromFile(L"shader_6.hlsl",
NULL,
D3D_COMPILE_STANDARD_FILE_INCLUDE,
"main_ps",
@@ -470,6 +470,12 @@ void d3d_resize(D3d *d3d, int rot, UINT width, UINT height)
switch (rot)
{
+ /*
+ * no rotation
+ *
+ * 1 0 0
+ * 0 1 0
+ */
case 0:
((Const_Buffer *)mapped.pData)->rotation[0][0] = 1;
((Const_Buffer *)mapped.pData)->rotation[0][1] = 0;
@@ -478,6 +484,12 @@ void d3d_resize(D3d *d3d, int rot, UINT width, UINT height)
((Const_Buffer *)mapped.pData)->rotation[1][1] = 1;
((Const_Buffer *)mapped.pData)->rotation[1][2] = 0;
break;
+ /*
+ * rotation 90° clock-wise
+ *
+ * 0 -1 w-1
+ * 1 0 0
+ */
case 1:
((Const_Buffer *)mapped.pData)->rotation[0][0] = 0;
((Const_Buffer *)mapped.pData)->rotation[0][1] = -1;
@@ -486,6 +498,12 @@ void d3d_resize(D3d *d3d, int rot, UINT width, UINT height)
((Const_Buffer *)mapped.pData)->rotation[1][1] = 0;
((Const_Buffer *)mapped.pData)->rotation[1][2] = 0;
break;
+ /*
+ * rotation 180° clock-wise
+ *
+ * -1 0 w-1
+ * 0 -1 h-1
+ */
case 2:
((Const_Buffer *)mapped.pData)->rotation[0][0] = -1;
((Const_Buffer *)mapped.pData)->rotation[0][1] = 0;
@@ -494,6 +512,12 @@ void d3d_resize(D3d *d3d, int rot, UINT width, UINT height)
((Const_Buffer *)mapped.pData)->rotation[1][1] = -1;
((Const_Buffer *)mapped.pData)->rotation[1][2] = height - 1;
break;
+ /*
+ * rotation 270° clock-wise
+ *
+ * 0 1 0
+ * -1 0 h-1
+ */
case 3:
((Const_Buffer *)mapped.pData)->rotation[0][0] = 0;
((Const_Buffer *)mapped.pData)->rotation[0][1] = 1;
@@ -705,7 +729,7 @@ void d3d_scene_begin(D3d *d3d)
o = rectangle_new(d3d,
220, 20,
203, 101,
- 0, 0, 255, 255); /* r, g, b, a */
+ 255, 255, 255, 255); /* r, g, b, a */
objects[0] = o;
o = rectangle_new(d3d,
diff --git a/src/shader_6.hlsl b/src/shader_6.hlsl
new file mode 100644
index 0000000..66b17d5
--- /dev/null
+++ b/src/shader_6.hlsl
@@ -0,0 +1,34 @@
+cbuffer cv_viewport : register(b0)
+{
+ row_major int2x3 rotation_matrix;
+ float2 ivps;
+}
+
+struct vs_input
+{
+ uint2 position : POSITION;
+ float4 color : COLOR;
+};
+
+struct ps_input
+{
+ float4 position : SV_POSITION;
+ float4 color : COLOR;
+};
+
+ps_input main_vs(vs_input input )
+{
+ ps_input output;
+ float2 o = float2(mul(rotation_matrix, int3(input.position, 1))) * ivps;
+ o *= 2.0f;
+ o -= 1.0f;
+ o.y *= -1.0f;
+ output.position = float4(o, 0.0f, 1.0f);
+ output.color = input.color;
+ return output;
+}
+
+float4 main_ps(ps_input input) : SV_TARGET
+{
+ return input.color;
+}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.