Commit c98e3648 authored by chili's avatar chili
Browse files

static vertex constant buffer + protected:tion

parent 7fa7828c
......@@ -14,9 +14,10 @@ public:
virtual DirectX::XMMATRIX GetTransformXM() const noexcept = 0;
void Draw( Graphics& gfx ) const noexcept(!IS_DEBUG);
virtual void Update( float dt ) noexcept = 0;
virtual ~Drawable() = default;
protected:
void AddBind( std::unique_ptr<Bindable> bind ) noexcept(!IS_DEBUG);
void AddIndexBuffer( std::unique_ptr<class IndexBuffer> ibuf ) noexcept(!IS_DEBUG);
virtual ~Drawable() = default;
private:
virtual const std::vector<std::unique_ptr<Bindable>>& GetStaticBinds() const noexcept = 0;
private:
......
......@@ -5,14 +5,14 @@
template<class T>
class DrawableBase : public Drawable
{
public:
bool IsStaticInitialized() const noexcept
protected:
static bool IsStaticInitialized() noexcept
{
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 AddStaticIndexBuffer to bind index buffer" && typeid(*bind) != typeid(IndexBuffer) );
staticBinds.push_back( std::move( bind ) );
}
void AddStaticIndexBuffer( std::unique_ptr<IndexBuffer> ibuf ) noexcept(!IS_DEBUG)
......
......@@ -2,16 +2,22 @@
TransformCbuf::TransformCbuf( Graphics& gfx,const Drawable& parent )
:
vcbuf( gfx ),
parent( parent )
{}
{
if( !pVcbuf )
{
pVcbuf = std::make_unique<VertexConstantBuffer<DirectX::XMMATRIX>>( gfx );
}
}
void TransformCbuf::Bind( Graphics& gfx ) noexcept
{
vcbuf.Update( gfx,
pVcbuf->Update( gfx,
DirectX::XMMatrixTranspose(
parent.GetTransformXM() * gfx.GetProjection()
)
);
vcbuf.Bind( gfx );
pVcbuf->Bind( gfx );
}
std::unique_ptr<VertexConstantBuffer<DirectX::XMMATRIX>> TransformCbuf::pVcbuf;
\ No newline at end of file
......@@ -9,6 +9,6 @@ public:
TransformCbuf( Graphics& gfx,const Drawable& parent );
void Bind( Graphics& gfx ) noexcept override;
private:
VertexConstantBuffer<DirectX::XMMATRIX> vcbuf;
static std::unique_ptr<VertexConstantBuffer<DirectX::XMMATRIX>> pVcbuf;
const Drawable& parent;
};
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment