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
6554f8c8
Commit
6554f8c8
authored
Jan 14, 2019
by
chili
Browse files
purdy colors (clear backbuffer)
parent
831380f6
Changes
4
Show whitespace changes
Inline
Side-by-side
hw3d/App.cpp
View file @
6554f8c8
...
...
@@ -21,5 +21,7 @@ int App::Go()
void
App
::
DoFrame
()
{
const
float
c
=
sin
(
timer
.
Peek
()
)
/
2.0
f
+
0.5
f
;
wnd
.
Gfx
().
ClearBuffer
(
c
,
c
,
1.0
f
);
wnd
.
Gfx
().
EndFrame
();
}
\ No newline at end of file
hw3d/App.h
View file @
6554f8c8
#pragma once
#include "Window.h"
#include "ChiliTimer.h"
class
App
{
...
...
@@ -11,4 +12,5 @@ private:
void
DoFrame
();
private:
Window
wnd
;
ChiliTimer
timer
;
};
\ No newline at end of file
hw3d/Graphics.cpp
View file @
6554f8c8
...
...
@@ -36,10 +36,23 @@ Graphics::Graphics( HWND hWnd )
nullptr
,
&
pContext
);
// gain access to texture subresource in swap chain (back buffer)
ID3D11Resource
*
pBackBuffer
=
nullptr
;
pSwap
->
GetBuffer
(
0
,
__uuidof
(
ID3D11Resource
),
reinterpret_cast
<
void
**>
(
&
pBackBuffer
)
);
pDevice
->
CreateRenderTargetView
(
pBackBuffer
,
nullptr
,
&
pTarget
);
pBackBuffer
->
Release
();
}
Graphics
::~
Graphics
()
{
if
(
pTarget
!=
nullptr
)
{
pTarget
->
Release
();
}
if
(
pContext
!=
nullptr
)
{
pContext
->
Release
();
...
...
hw3d/Graphics.h
View file @
6554f8c8
...
...
@@ -10,8 +10,14 @@ public:
Graphics
&
operator
=
(
const
Graphics
&
)
=
delete
;
~
Graphics
();
void
EndFrame
();
void
ClearBuffer
(
float
red
,
float
green
,
float
blue
)
noexcept
{
const
float
color
[]
=
{
red
,
green
,
blue
,
1.0
f
};
pContext
->
ClearRenderTargetView
(
pTarget
,
color
);
}
private:
ID3D11Device
*
pDevice
=
nullptr
;
IDXGISwapChain
*
pSwap
=
nullptr
;
ID3D11DeviceContext
*
pContext
=
nullptr
;
ID3D11RenderTargetView
*
pTarget
=
nullptr
;
};
\ 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