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
c98e3648
Commit
c98e3648
authored
Feb 15, 2019
by
chili
Browse files
static vertex constant buffer + protected:tion
parent
7fa7828c
Changes
4
Hide whitespace changes
Inline
Side-by-side
hw3d/Drawable.h
View file @
c98e3648
...
@@ -14,9 +14,10 @@ public:
...
@@ -14,9 +14,10 @@ public:
virtual
DirectX
::
XMMATRIX
GetTransformXM
()
const
noexcept
=
0
;
virtual
DirectX
::
XMMATRIX
GetTransformXM
()
const
noexcept
=
0
;
void
Draw
(
Graphics
&
gfx
)
const
noexcept
(
!
IS_DEBUG
);
void
Draw
(
Graphics
&
gfx
)
const
noexcept
(
!
IS_DEBUG
);
virtual
void
Update
(
float
dt
)
noexcept
=
0
;
virtual
void
Update
(
float
dt
)
noexcept
=
0
;
virtual
~
Drawable
()
=
default
;
protected:
void
AddBind
(
std
::
unique_ptr
<
Bindable
>
bind
)
noexcept
(
!
IS_DEBUG
);
void
AddBind
(
std
::
unique_ptr
<
Bindable
>
bind
)
noexcept
(
!
IS_DEBUG
);
void
AddIndexBuffer
(
std
::
unique_ptr
<
class
IndexBuffer
>
ibuf
)
noexcept
(
!
IS_DEBUG
);
void
AddIndexBuffer
(
std
::
unique_ptr
<
class
IndexBuffer
>
ibuf
)
noexcept
(
!
IS_DEBUG
);
virtual
~
Drawable
()
=
default
;
private:
private:
virtual
const
std
::
vector
<
std
::
unique_ptr
<
Bindable
>>&
GetStaticBinds
()
const
noexcept
=
0
;
virtual
const
std
::
vector
<
std
::
unique_ptr
<
Bindable
>>&
GetStaticBinds
()
const
noexcept
=
0
;
private:
private:
...
...
hw3d/DrawableBase.h
View file @
c98e3648
...
@@ -5,14 +5,14 @@
...
@@ -5,14 +5,14 @@
template
<
class
T
>
template
<
class
T
>
class
DrawableBase
:
public
Drawable
class
DrawableBase
:
public
Drawable
{
{
p
ublic
:
p
rotected
:
bool
IsStaticInitialized
()
const
noexcept
static
bool
IsStaticInitialized
()
noexcept
{
{
return
!
staticBinds
.
empty
();
return
!
staticBinds
.
empty
();
}
}
void
AddStaticBind
(
std
::
unique_ptr
<
Bindable
>
bind
)
noexcept
(
!
IS_DEBUG
)
static
void
AddStaticBind
(
std
::
unique_ptr
<
Bindable
>
bind
)
noexcept
(
!
IS_DEBUG
)
{
{
assert
(
"*Must* use AddIndexBuffer to bind index buffer"
&&
typeid
(
*
bind
)
!=
typeid
(
IndexBuffer
)
);
assert
(
"*Must* use Add
Static
IndexBuffer to bind index buffer"
&&
typeid
(
*
bind
)
!=
typeid
(
IndexBuffer
)
);
staticBinds
.
push_back
(
std
::
move
(
bind
)
);
staticBinds
.
push_back
(
std
::
move
(
bind
)
);
}
}
void
AddStaticIndexBuffer
(
std
::
unique_ptr
<
IndexBuffer
>
ibuf
)
noexcept
(
!
IS_DEBUG
)
void
AddStaticIndexBuffer
(
std
::
unique_ptr
<
IndexBuffer
>
ibuf
)
noexcept
(
!
IS_DEBUG
)
...
@@ -38,7 +38,7 @@ private:
...
@@ -38,7 +38,7 @@ private:
const
std
::
vector
<
std
::
unique_ptr
<
Bindable
>>&
GetStaticBinds
()
const
noexcept
override
const
std
::
vector
<
std
::
unique_ptr
<
Bindable
>>&
GetStaticBinds
()
const
noexcept
override
{
{
return
staticBinds
;
return
staticBinds
;
}
}
private:
private:
static
std
::
vector
<
std
::
unique_ptr
<
Bindable
>>
staticBinds
;
static
std
::
vector
<
std
::
unique_ptr
<
Bindable
>>
staticBinds
;
};
};
...
...
hw3d/TransformCbuf.cpp
View file @
c98e3648
...
@@ -2,16 +2,22 @@
...
@@ -2,16 +2,22 @@
TransformCbuf
::
TransformCbuf
(
Graphics
&
gfx
,
const
Drawable
&
parent
)
TransformCbuf
::
TransformCbuf
(
Graphics
&
gfx
,
const
Drawable
&
parent
)
:
:
vcbuf
(
gfx
),
parent
(
parent
)
parent
(
parent
)
{}
{
if
(
!
pVcbuf
)
{
pVcbuf
=
std
::
make_unique
<
VertexConstantBuffer
<
DirectX
::
XMMATRIX
>>
(
gfx
);
}
}
void
TransformCbuf
::
Bind
(
Graphics
&
gfx
)
noexcept
void
TransformCbuf
::
Bind
(
Graphics
&
gfx
)
noexcept
{
{
v
cbuf
.
Update
(
gfx
,
pV
cbuf
->
Update
(
gfx
,
DirectX
::
XMMatrixTranspose
(
DirectX
::
XMMatrixTranspose
(
parent
.
GetTransformXM
()
*
gfx
.
GetProjection
()
parent
.
GetTransformXM
()
*
gfx
.
GetProjection
()
)
)
);
);
v
cbuf
.
Bind
(
gfx
);
pV
cbuf
->
Bind
(
gfx
);
}
}
std
::
unique_ptr
<
VertexConstantBuffer
<
DirectX
::
XMMATRIX
>>
TransformCbuf
::
pVcbuf
;
\ No newline at end of file
hw3d/TransformCbuf.h
View file @
c98e3648
...
@@ -9,6 +9,6 @@ public:
...
@@ -9,6 +9,6 @@ public:
TransformCbuf
(
Graphics
&
gfx
,
const
Drawable
&
parent
);
TransformCbuf
(
Graphics
&
gfx
,
const
Drawable
&
parent
);
void
Bind
(
Graphics
&
gfx
)
noexcept
override
;
void
Bind
(
Graphics
&
gfx
)
noexcept
override
;
private:
private:
VertexConstantBuffer
<
DirectX
::
XMMATRIX
>
v
cbuf
;
static
std
::
unique_ptr
<
VertexConstantBuffer
<
DirectX
::
XMMATRIX
>
>
pV
cbuf
;
const
Drawable
&
parent
;
const
Drawable
&
parent
;
};
};
\ 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