34 lines
799 B
C++
34 lines
799 B
C++
#include "Light.h"
|
|
#include "Utilities.h"
|
|
|
|
UINT Light::init(ID3D11Device* pD3DDevice, LightBuffer& lightData)
|
|
{
|
|
D3D11_BUFFER_DESC desc = {};
|
|
desc.ByteWidth = sizeof(LightBuffer);
|
|
desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
|
|
desc.Usage = D3D11_USAGE_IMMUTABLE; // no light update possible
|
|
//desc.Usage = D3D11_USAGE_DYNAMIC; // light update possible
|
|
|
|
D3D11_SUBRESOURCE_DATA initialData = {};
|
|
initialData.pSysMem = &lightData;
|
|
|
|
HRESULT hr = pD3DDevice->CreateBuffer(&desc, &initialData, &_pLightBuffer);
|
|
CheckFailed(hr, 70);
|
|
|
|
return 0;
|
|
}
|
|
|
|
void Light::update(FLOAT dt)
|
|
{
|
|
}
|
|
|
|
void Light::render(ID3D11DeviceContext* pD3DDeviceContext)
|
|
{
|
|
pD3DDeviceContext->PSSetConstantBuffers(0, 1, &_pLightBuffer);
|
|
}
|
|
|
|
void Light::deInit()
|
|
{
|
|
safeRelease(_pLightBuffer);
|
|
}
|