Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Clark Lin
hw3d
Commits
6a82d758
Commit
6a82d758
authored
Feb 12, 2019
by
chili
Browse files
mouse translation dxmath
parent
109d48f3
Changes
4
Hide whitespace changes
Inline
Side-by-side
hw3d/App.cpp
View file @
6a82d758
...
@@ -23,6 +23,10 @@ void App::DoFrame()
...
@@ -23,6 +23,10 @@ void App::DoFrame()
{
{
const
float
c
=
sin
(
timer
.
Peek
()
)
/
2.0
f
+
0.5
f
;
const
float
c
=
sin
(
timer
.
Peek
()
)
/
2.0
f
+
0.5
f
;
wnd
.
Gfx
().
ClearBuffer
(
c
,
c
,
1.0
f
);
wnd
.
Gfx
().
ClearBuffer
(
c
,
c
,
1.0
f
);
wnd
.
Gfx
().
DrawTestTriangle
(
timer
.
Peek
()
);
wnd
.
Gfx
().
DrawTestTriangle
(
timer
.
Peek
(),
wnd
.
mouse
.
GetPosX
()
/
400.0
f
-
1.0
f
,
-
wnd
.
mouse
.
GetPosY
()
/
300.0
f
+
1.0
f
);
wnd
.
Gfx
().
EndFrame
();
wnd
.
Gfx
().
EndFrame
();
}
}
\ No newline at end of file
hw3d/Graphics.cpp
View file @
6a82d758
...
@@ -3,8 +3,10 @@
...
@@ -3,8 +3,10 @@
#include <sstream>
#include <sstream>
#include <d3dcompiler.h>
#include <d3dcompiler.h>
#include <cmath>
#include <cmath>
#include <DirectXMath.h>
namespace
wrl
=
Microsoft
::
WRL
;
namespace
wrl
=
Microsoft
::
WRL
;
namespace
dx
=
DirectX
;
#pragma comment(lib,"d3d11.lib")
#pragma comment(lib,"d3d11.lib")
#pragma comment(lib,"D3DCompiler.lib")
#pragma comment(lib,"D3DCompiler.lib")
...
@@ -99,7 +101,7 @@ void Graphics::ClearBuffer( float red,float green,float blue ) noexcept
...
@@ -99,7 +101,7 @@ void Graphics::ClearBuffer( float red,float green,float blue ) noexcept
pContext
->
ClearRenderTargetView
(
pTarget
.
Get
(),
color
);
pContext
->
ClearRenderTargetView
(
pTarget
.
Get
(),
color
);
}
}
void
Graphics
::
DrawTestTriangle
(
float
angle
)
void
Graphics
::
DrawTestTriangle
(
float
angle
,
float
x
,
float
y
)
{
{
HRESULT
hr
;
HRESULT
hr
;
...
@@ -175,18 +177,16 @@ void Graphics::DrawTestTriangle( float angle )
...
@@ -175,18 +177,16 @@ void Graphics::DrawTestTriangle( float angle )
// create constant buffer for transformation matrix
// create constant buffer for transformation matrix
struct
ConstantBuffer
struct
ConstantBuffer
{
{
struct
dx
::
XMMATRIX
transform
;
{
float
element
[
4
][
4
];
}
transformation
;
};
};
const
ConstantBuffer
cb
=
const
ConstantBuffer
cb
=
{
{
{
{
(
3.0
f
/
4.0
f
)
*
std
::
cos
(
angle
),
std
::
sin
(
angle
),
0.0
f
,
0.0
f
,
dx
::
XMMatrixTranspose
(
(
3.0
f
/
4.0
f
)
*
-
std
::
sin
(
angle
),
std
::
cos
(
angle
),
0.0
f
,
0.0
f
,
dx
::
XMMatrixRotationZ
(
angle
)
*
0.0
f
,
0.0
f
,
1.0
f
,
0.0
f
,
dx
::
XMMatrixScaling
(
3.0
f
/
4.0
f
,
1.0
f
,
1.0
f
)
*
0.0
f
,
0.0
f
,
0.0
f
,
1.0
f
,
dx
::
XMMatrixTranslation
(
x
,
y
,
0.0
f
)
)
}
}
};
};
wrl
::
ComPtr
<
ID3D11Buffer
>
pConstantBuffer
;
wrl
::
ComPtr
<
ID3D11Buffer
>
pConstantBuffer
;
...
...
hw3d/Graphics.h
View file @
6a82d758
...
@@ -52,7 +52,7 @@ public:
...
@@ -52,7 +52,7 @@ public:
~
Graphics
()
=
default
;
~
Graphics
()
=
default
;
void
EndFrame
();
void
EndFrame
();
void
ClearBuffer
(
float
red
,
float
green
,
float
blue
)
noexcept
;
void
ClearBuffer
(
float
red
,
float
green
,
float
blue
)
noexcept
;
void
DrawTestTriangle
(
float
angle
);
void
DrawTestTriangle
(
float
angle
,
float
x
,
float
y
);
private:
private:
#ifndef NDEBUG
#ifndef NDEBUG
DxgiInfoManager
infoManager
;
DxgiInfoManager
infoManager
;
...
...
hw3d/VertexShader.hlsl
View file @
6a82d758
...
@@ -6,7 +6,7 @@ struct VSOut
...
@@ -6,7 +6,7 @@ struct VSOut
cbuffer
CBuf
cbuffer
CBuf
{
{
row_major
matrix
transform
;
matrix
transform
;
};
};
VSOut
main
(
float2
pos
:
Position
,
float3
color
:
Color
)
VSOut
main
(
float2
pos
:
Position
,
float3
color
:
Color
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment