*
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
#include "CustomSwapChain.h"
|
||||
|
||||
namespace LifeGraphics
|
||||
{
|
||||
CustomSwapChain::CustomSwapChain(uint16 width, uint16 height, uint16 buffer_cnt, LifeGraphics::IRenderer* host, IDataFormat format)
|
||||
:back_buffer(nullptr), depth_buffer(nullptr){
|
||||
if(!host){
|
||||
sc_width = sc_height = sc_buffers = 0;
|
||||
return;
|
||||
}
|
||||
sc_width = width;
|
||||
sc_height = height;
|
||||
sc_buffers = buffer_cnt;
|
||||
sc_format = format;
|
||||
sc_renderer = host;
|
||||
RebuildBuffers();
|
||||
}
|
||||
LifeGraphics::ITexture2D* CustomSwapChain::GetBackBuffer(uint8 id){
|
||||
return back_buffer;
|
||||
}
|
||||
LifeGraphics::ITexture2D* CustomSwapChain::GetDepthBuffer(uint8 id){
|
||||
return depth_buffer;
|
||||
}
|
||||
void CustomSwapChain::Resize(uint16 width, uint16 height){
|
||||
if(width != sc_width || height != sc_height){
|
||||
sc_width = width;
|
||||
sc_height = height;
|
||||
RebuildBuffers();
|
||||
Event_Resized.Invoke(this);
|
||||
}
|
||||
}
|
||||
void CustomSwapChain::Present(){
|
||||
Event_Presented.Invoke(this);
|
||||
}
|
||||
void CustomSwapChain::RebuildBuffers(){
|
||||
if(back_buffer)
|
||||
back_buffer->Release();
|
||||
|
||||
if(depth_buffer)
|
||||
depth_buffer->Release();
|
||||
|
||||
back_buffer = sc_renderer->CreateRenderTarget(sc_width, sc_height, sc_format);
|
||||
depth_buffer = sc_renderer->CreateDepthTarget(sc_width, sc_height, FORMAT_D24_UNORM_S8_UINT);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user