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
b4c37cb8
Commit
b4c37cb8
authored
Aug 26, 2019
by
chili
Browse files
refactor Cbuf for increased extensibility
parent
bf379f2a
Changes
2
Show whitespace changes
Inline
Side-by-side
hw3d/TransformCbuf.cpp
View file @
b4c37cb8
...
...
@@ -14,17 +14,25 @@ namespace Bind
void
TransformCbuf
::
Bind
(
Graphics
&
gfx
)
noexcept
{
const
auto
modelView
=
parent
.
GetTransformXM
()
*
gfx
.
GetCamera
();
const
Transforms
tf
=
UpdateBindImpl
(
gfx
,
GetTransforms
(
gfx
)
);
}
void
TransformCbuf
::
UpdateBindImpl
(
Graphics
&
gfx
,
const
Transforms
&
tf
)
noexcept
{
pVcbuf
->
Update
(
gfx
,
tf
);
pVcbuf
->
Bind
(
gfx
);
}
TransformCbuf
::
Transforms
TransformCbuf
::
GetTransforms
(
Graphics
&
gfx
)
noexcept
{
const
auto
modelView
=
parent
.
GetTransformXM
()
*
gfx
.
GetCamera
();
return
{
DirectX
::
XMMatrixTranspose
(
modelView
),
DirectX
::
XMMatrixTranspose
(
modelView
*
gfx
.
GetProjection
()
)
};
pVcbuf
->
Update
(
gfx
,
tf
);
pVcbuf
->
Bind
(
gfx
);
}
std
::
unique_ptr
<
VertexConstantBuffer
<
TransformCbuf
::
Transforms
>>
TransformCbuf
::
pVcbuf
;
...
...
hw3d/TransformCbuf.h
View file @
b4c37cb8
...
...
@@ -7,15 +7,18 @@ namespace Bind
{
class
TransformCbuf
:
public
Bindable
{
pr
ivate
:
pr
otected
:
struct
Transforms
{
DirectX
::
XMMATRIX
modelView
;
DirectX
::
XMMATRIX
modelViewProj
;
DirectX
::
XMMATRIX
model
;
};
public:
TransformCbuf
(
Graphics
&
gfx
,
const
Drawable
&
parent
,
UINT
slot
=
0u
);
void
Bind
(
Graphics
&
gfx
)
noexcept
override
;
protected:
void
UpdateBindImpl
(
Graphics
&
gfx
,
const
Transforms
&
tf
)
noexcept
;
Transforms
GetTransforms
(
Graphics
&
gfx
)
noexcept
;
private:
static
std
::
unique_ptr
<
VertexConstantBuffer
<
Transforms
>>
pVcbuf
;
const
Drawable
&
parent
;
...
...
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