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
caca4839
Commit
caca4839
authored
Jan 27, 2019
by
chili
Browse files
crashy crashy
parent
d5ba4169
Changes
3
Show whitespace changes
Inline
Side-by-side
hw3d/App.cpp
View file @
caca4839
...
@@ -23,5 +23,6 @@ void App::DoFrame()
...
@@ -23,5 +23,6 @@ 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
();
wnd
.
Gfx
().
EndFrame
();
wnd
.
Gfx
().
EndFrame
();
}
}
\ No newline at end of file
hw3d/Graphics.cpp
View file @
caca4839
...
@@ -94,6 +94,44 @@ void Graphics::ClearBuffer( float red,float green,float blue ) noexcept
...
@@ -94,6 +94,44 @@ void Graphics::ClearBuffer( float red,float green,float blue ) noexcept
pContext
->
ClearRenderTargetView
(
pTarget
.
Get
(),
color
);
pContext
->
ClearRenderTargetView
(
pTarget
.
Get
(),
color
);
}
}
void
Graphics
::
DrawTestTriangle
()
{
namespace
wrl
=
Microsoft
::
WRL
;
HRESULT
hr
;
struct
Vertex
{
float
x
;
float
y
;
};
// create vertex buffer (1 2d triangle at center of screen)
const
Vertex
vertices
[]
=
{
{
0.0
f
,
0.5
f
},
{
0.5
f
,
-
0.5
f
},
{
-
0.5
f
,
-
0.5
f
},
};
wrl
::
ComPtr
<
ID3D11Buffer
>
pVertexBuffer
;
D3D11_BUFFER_DESC
bd
=
{};
bd
.
BindFlags
=
D3D11_BIND_VERTEX_BUFFER
;
bd
.
Usage
=
D3D11_USAGE_DEFAULT
;
bd
.
CPUAccessFlags
=
0u
;
bd
.
MiscFlags
=
0u
;
bd
.
ByteWidth
=
sizeof
(
vertices
);
bd
.
StructureByteStride
=
sizeof
(
Vertex
);
D3D11_SUBRESOURCE_DATA
sd
=
{};
sd
.
pSysMem
=
vertices
;
GFX_THROW_INFO
(
pDevice
->
CreateBuffer
(
&
bd
,
&
sd
,
&
pVertexBuffer
)
);
// Bind vertex buffer to pipeline
const
UINT
stride
=
sizeof
(
Vertex
);
const
UINT
offset
=
0u
;
pContext
->
IASetVertexBuffers
(
0u
,
1u
,
&
pVertexBuffer
,
&
stride
,
&
offset
);
pContext
->
Draw
(
3u
,
0u
);
}
// Graphics exception stuff
// Graphics exception stuff
Graphics
::
HrException
::
HrException
(
int
line
,
const
char
*
file
,
HRESULT
hr
,
std
::
vector
<
std
::
string
>
infoMsgs
)
noexcept
Graphics
::
HrException
::
HrException
(
int
line
,
const
char
*
file
,
HRESULT
hr
,
std
::
vector
<
std
::
string
>
infoMsgs
)
noexcept
...
...
hw3d/Graphics.h
View file @
caca4839
...
@@ -42,6 +42,7 @@ public:
...
@@ -42,6 +42,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
();
private:
private:
#ifndef NDEBUG
#ifndef NDEBUG
DxgiInfoManager
infoManager
;
DxgiInfoManager
infoManager
;
...
...
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