void ConstBuffer::VInit(uint byteSize, void* data) { m_byteSize = byteSize; D3D11_BUFFER_DESC bDesc; bDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER; bDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE; bDesc.ByteWidth = byteSize; bDesc.Usage = D3D11_USAGE_DYNAMIC; bDesc.MiscFlags = 0; bDesc.StructureByteStride = 0; D3D_SAVE_CALL(chimera::d3d::GetDevice()->CreateBuffer(&bDesc, NULL, &m_buffer)); if(data) { VSetData(data); } }
bool DXShader::SetMatrix4x4(std::string name, const DirectX::XMFLOAT4X4 data) { return VSetData(name, &data, sizeof(float) * 16); }
bool DXShader::VSetMatrix4x4(std::string name, const float data[16]) { return VSetData(name, static_cast<void*>(&data), sizeof(float) * 16); }
bool DXShader::SetFloat4(std::string name, const DirectX::XMFLOAT4 data) { return VSetData(name, &data, sizeof(float) * 4); }
bool DXShader::VSetFloat4(std::string name, const float data[4]) { return VSetData(name, static_cast<void*>(&data), sizeof(float) * 4); }
bool DXShader::VSetFloat(std::string name, float data) { return VSetData(name, static_cast<void*>(&data), sizeof(float)); }
bool DXShader::VSetInt(std::string name, int data) { return VSetData(name, static_cast<void*>(&data), sizeof(int)); }
void ConstBuffer::VSetFromMatrix(const util::Mat4& mat) { VSetData((void*)&mat.m_m); }