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
7fa7828c
Commit
7fa7828c
authored
Feb 15, 2019
by
chili
Browse files
fix static index buffer issue more than 1 box
parent
45e4a393
Changes
2
Hide whitespace changes
Inline
Side-by-side
hw3d/Box.cpp
View file @
7fa7828c
...
@@ -92,6 +92,10 @@ Box::Box( Graphics& gfx,
...
@@ -92,6 +92,10 @@ Box::Box( Graphics& gfx,
AddStaticBind
(
std
::
make_unique
<
Topology
>
(
gfx
,
D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST
)
);
AddStaticBind
(
std
::
make_unique
<
Topology
>
(
gfx
,
D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST
)
);
}
}
else
{
SetIndexFromStatic
();
}
AddBind
(
std
::
make_unique
<
TransformCbuf
>
(
gfx
,
*
this
)
);
AddBind
(
std
::
make_unique
<
TransformCbuf
>
(
gfx
,
*
this
)
);
}
}
...
...
hw3d/DrawableBase.h
View file @
7fa7828c
...
@@ -17,10 +17,23 @@ public:
...
@@ -17,10 +17,23 @@ public:
}
}
void
AddStaticIndexBuffer
(
std
::
unique_ptr
<
IndexBuffer
>
ibuf
)
noexcept
(
!
IS_DEBUG
)
void
AddStaticIndexBuffer
(
std
::
unique_ptr
<
IndexBuffer
>
ibuf
)
noexcept
(
!
IS_DEBUG
)
{
{
assert
(
pIndexBuffer
==
nullptr
);
assert
(
"Attempting to add index buffer a second time"
&&
pIndexBuffer
==
nullptr
);
pIndexBuffer
=
ibuf
.
get
();
pIndexBuffer
=
ibuf
.
get
();
staticBinds
.
push_back
(
std
::
move
(
ibuf
)
);
staticBinds
.
push_back
(
std
::
move
(
ibuf
)
);
}
}
void
SetIndexFromStatic
()
noexcept
(
!
IS_DEBUG
)
{
assert
(
"Attempting to add index buffer a second time"
&&
pIndexBuffer
==
nullptr
);
for
(
const
auto
&
b
:
staticBinds
)
{
if
(
const
auto
p
=
dynamic_cast
<
IndexBuffer
*>
(
b
.
get
())
)
{
pIndexBuffer
=
p
;
return
;
}
}
assert
(
"Failed to find index buffer in static binds"
&&
pIndexBuffer
!=
nullptr
);
}
private:
private:
const
std
::
vector
<
std
::
unique_ptr
<
Bindable
>>&
GetStaticBinds
()
const
noexcept
override
const
std
::
vector
<
std
::
unique_ptr
<
Bindable
>>&
GetStaticBinds
()
const
noexcept
override
{
{
...
...
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