2021-06-02 09:07:45 +04:30
|
|
|
#include "ltpch.h"
|
|
|
|
#include "dxRenderCommand.h"
|
|
|
|
|
|
|
|
#include "dxSharedContext.h"
|
|
|
|
|
|
|
|
namespace Light {
|
|
|
|
|
2021-06-19 15:12:42 +04:30
|
|
|
dxRenderCommand::dxRenderCommand(std::shared_ptr<dxSharedContext> sharedContext)
|
|
|
|
: m_Context(sharedContext)
|
2021-06-02 09:07:45 +04:30
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void dxRenderCommand::SwapBuffers()
|
|
|
|
{
|
2021-06-21 17:04:51 +04:30
|
|
|
#ifdef LIGHT_DEBUG
|
|
|
|
HRESULT hr;
|
|
|
|
if (FAILED(hr = m_Context->swapChain->Present(0u, 0u)))
|
|
|
|
{
|
|
|
|
if (hr == DXGI_ERROR_DEVICE_REMOVED)
|
|
|
|
{
|
|
|
|
LT_ENGINE_CRITICAL("dxRenderCommand::SwapBuffers: DeviceRemoved:");
|
|
|
|
LT_ENGINE_CRITICAL(" {}", m_Context->device->GetDeviceRemovedReason());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
m_Context->swapChain->Present(0u, 0u);
|
|
|
|
#endif
|
|
|
|
|
2021-06-02 09:07:45 +04:30
|
|
|
}
|
|
|
|
|
|
|
|
void dxRenderCommand::ClearBackBuffer()
|
|
|
|
{
|
|
|
|
float colors[] = { 1.2f, 0.4f, 0.9f, 1.0f };
|
2021-06-19 15:12:42 +04:30
|
|
|
m_Context->deviceContext->ClearRenderTargetView(m_Context->renderTargetView.Get(), colors);
|
2021-06-02 09:07:45 +04:30
|
|
|
}
|
|
|
|
|
|
|
|
void dxRenderCommand::Draw(unsigned int count)
|
|
|
|
{
|
2021-06-19 15:12:42 +04:30
|
|
|
m_Context->deviceContext->Draw(count, 0u);
|
2021-06-02 09:07:45 +04:30
|
|
|
}
|
|
|
|
|
|
|
|
void dxRenderCommand::DrawIndexed(unsigned int count)
|
|
|
|
{
|
2021-06-19 15:12:42 +04:30
|
|
|
m_Context->deviceContext->DrawIndexed(count, 0u, 0u);
|
2021-06-02 09:07:45 +04:30
|
|
|
}
|
|
|
|
|
|
|
|
}
|