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
7800295e
Commit
7800295e
authored
Feb 03, 2019
by
chili
Browse files
colored triangle
parent
27bd983e
Changes
3
Hide whitespace changes
Inline
Side-by-side
hw3d/Graphics.cpp
View file @
7800295e
...
@@ -100,21 +100,23 @@ void Graphics::ClearBuffer( float red,float green,float blue ) noexcept
...
@@ -100,21 +100,23 @@ void Graphics::ClearBuffer( float red,float green,float blue ) noexcept
void
Graphics
::
DrawTestTriangle
()
void
Graphics
::
DrawTestTriangle
()
{
{
namespace
wrl
=
Microsoft
::
WRL
;
HRESULT
hr
;
HRESULT
hr
;
struct
Vertex
struct
Vertex
{
{
float
x
;
float
x
;
float
y
;
float
y
;
float
r
;
float
g
;
float
b
;
};
};
// create vertex buffer (1 2d triangle at center of screen)
// create vertex buffer (1 2d triangle at center of screen)
const
Vertex
vertices
[]
=
const
Vertex
vertices
[]
=
{
{
{
0.0
f
,
0.5
f
},
{
0.0
f
,
0.5
f
,
1.0
f
,
0.0
f
,
0.0
f
},
{
0.5
f
,
-
0.5
f
},
{
0.5
f
,
-
0.5
f
,
0.0
f
,
1.0
f
,
0.0
f
},
{
-
0.5
f
,
-
0.5
f
},
{
-
0.5
f
,
-
0.5
f
,
0.0
f
,
0.0
f
,
1.0
f
},
};
};
wrl
::
ComPtr
<
ID3D11Buffer
>
pVertexBuffer
;
wrl
::
ComPtr
<
ID3D11Buffer
>
pVertexBuffer
;
D3D11_BUFFER_DESC
bd
=
{};
D3D11_BUFFER_DESC
bd
=
{};
...
@@ -158,6 +160,7 @@ void Graphics::DrawTestTriangle()
...
@@ -158,6 +160,7 @@ void Graphics::DrawTestTriangle()
const
D3D11_INPUT_ELEMENT_DESC
ied
[]
=
const
D3D11_INPUT_ELEMENT_DESC
ied
[]
=
{
{
{
"Position"
,
0
,
DXGI_FORMAT_R32G32_FLOAT
,
0
,
0
,
D3D11_INPUT_PER_VERTEX_DATA
,
0
},
{
"Position"
,
0
,
DXGI_FORMAT_R32G32_FLOAT
,
0
,
0
,
D3D11_INPUT_PER_VERTEX_DATA
,
0
},
{
"Color"
,
0
,
DXGI_FORMAT_R32G32B32_FLOAT
,
0
,
8u
,
D3D11_INPUT_PER_VERTEX_DATA
,
0
},
};
};
GFX_THROW_INFO
(
pDevice
->
CreateInputLayout
(
GFX_THROW_INFO
(
pDevice
->
CreateInputLayout
(
ied
,(
UINT
)
std
::
size
(
ied
),
ied
,(
UINT
)
std
::
size
(
ied
),
...
...
hw3d/PixelShader.hlsl
View file @
7800295e
float4
main
()
:
SV_Target
float4
main
(
float3
color
:
Color
)
:
SV_Target
{
{
return
float4
(
1
.
0
f
,
1
.
0
f
,
1
.
0
f
,
1
.
0
f
);
return
float4
(
color
,
1
.
0
f
);
}
}
\ No newline at end of file
hw3d/VertexShader.hlsl
View file @
7800295e
float4
main
(
float2
pos
:
Position
)
:
SV_Position
struct
VSOut
{
{
return
float4
(
pos
.
x
,
pos
.
y
,
0
.
0
f
,
1
.
0
f
);
float3
color
:
Color
;
float4
pos
:
SV_Position
;
};
VSOut
main
(
float2
pos
:
Position
,
float3
color
:
Color
)
{
VSOut
vso
;
vso
.
pos
=
float4
(
pos
.
x
,
pos
.
y
,
0
.
0
f
,
1
.
0
f
);
vso
.
color
=
color
;
return
vso
;
}
}
\ No newline at end of file
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