színes teáskannák
This commit is contained in:
parent
8b67a40e55
commit
c9fcc60c35
14
Entity.cpp
14
Entity.cpp
@ -16,6 +16,8 @@ eg3d::Entity::Entity(const Entity& other): Geometry(other.device)
|
||||
}
|
||||
|
||||
void eg3d::Entity::loadDefaults() {
|
||||
mConstBuf.color = { 1.0f, 1.0f, 1.0f, 1.0f };
|
||||
|
||||
XMStoreFloat4x4(&mConstBuf.worldMatrix, XMMatrixIdentity()); // egységmátrix betöltése a világ-mátrixba
|
||||
mSRTProps.loadDefaults();
|
||||
constructWorldMatrix();
|
||||
@ -54,7 +56,7 @@ void eg3d::Entity::constructWorldMatrix() {
|
||||
XMStoreFloat4x4(&mConstBuf.worldMatrix, w);
|
||||
|
||||
// konstansbuffer felmásolása a videokártyára
|
||||
bufferMapCopy(mConstBufRes, static_cast<void*>(&mConstBuf), sizeof(CB_Entity));
|
||||
updateConstantBuffer();
|
||||
}
|
||||
|
||||
void eg3d::Entity::createConstantBuffer()
|
||||
@ -62,6 +64,16 @@ void eg3d::Entity::createConstantBuffer()
|
||||
mConstBufRes = createBuffer_UH(device, calc256AlignedSize(sizeof(CB_Entity)));
|
||||
}
|
||||
|
||||
void eg3d::Entity::updateConstantBuffer()
|
||||
{
|
||||
bufferMapCopy(mConstBufRes, static_cast<void*>(&mConstBuf), sizeof(CB_Entity));
|
||||
}
|
||||
|
||||
void eg3d::Entity::setColor(float r, float g, float b)
|
||||
{
|
||||
mConstBuf.color = { r, g, b, 1.0f };
|
||||
updateConstantBuffer();
|
||||
}
|
||||
|
||||
// ----------------------
|
||||
|
||||
|
3
Entity.h
3
Entity.h
@ -31,6 +31,7 @@ namespace eg3d {
|
||||
|
||||
// TODO konstansbuffer létrehozása, feltöltése
|
||||
void createConstantBuffer(); // konstansbuffer létrehozása
|
||||
void updateConstantBuffer(); // konstansbuffer frissítése
|
||||
public:
|
||||
Entity(const ComPtr<ID3D12Device> &device);
|
||||
explicit Entity(const Entity& other); // másolókonstruktor
|
||||
@ -41,6 +42,8 @@ namespace eg3d {
|
||||
SRTProps getEntitySRT() const; // SRT-tualjdonságok elkérése
|
||||
|
||||
void draw(ComPtr<ID3D12GraphicsCommandList> commandList) const override;
|
||||
|
||||
void setColor(float r, float g, float b); // szín beállítása
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ cbuffer CFrame : register(b0)
|
||||
cbuffer CEntity : register(b1)
|
||||
{
|
||||
float4x4 worldMatrix;
|
||||
float4 color;
|
||||
}
|
||||
|
||||
VSOutput vs_main(VSInput input)
|
||||
@ -26,7 +27,7 @@ VSOutput vs_main(VSInput input)
|
||||
VSOutput output; // vertex shader kimenete
|
||||
|
||||
output.position_H = mul(float4(input.position_D, 1.0), mul(worldMatrix, mul(viewMatrix, projMatrix)));
|
||||
output.color = float3(1.0, 1.0, 1.0);
|
||||
output.color = color;
|
||||
|
||||
return output;
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ struct CB_Frame
|
||||
|
||||
struct CB_Entity {
|
||||
DirectX::XMFLOAT4X4 worldMatrix; // világ-mátrix (modell-mátrix)
|
||||
DirectX::XMFLOAT4 color; // szín
|
||||
};
|
||||
|
||||
#endif //CONST_BUFS
|
||||
|
Loading…
x
Reference in New Issue
Block a user