This commit is contained in:
Branimir Karadžić
2017-07-25 19:47:07 -07:00
parent 87acea36e7
commit 1dce73936f

View File

@@ -188,9 +188,7 @@ public:
m_mesh = meshLoad("meshes/bunny.bin");
m_fbtextures[0] = bgfx::createTexture2D(uint16_t(m_width), uint16_t(m_height), false, 1, bgfx::TextureFormat::BGRA8, BGFX_TEXTURE_RT | BGFX_TEXTURE_U_CLAMP | BGFX_TEXTURE_V_CLAMP);
m_fbtextures[1] = bgfx::createTexture2D(uint16_t(m_width), uint16_t(m_height), false, 1, bgfx::TextureFormat::D16, BGFX_TEXTURE_RT_WRITE_ONLY);
m_fbh = bgfx::createFrameBuffer(BX_COUNTOF(m_fbtextures), m_fbtextures, true);
m_fbh.idx = bgfx::kInvalidHandle;
m_lum[0] = bgfx::createFrameBuffer(128, 128, bgfx::TextureFormat::BGRA8);
m_lum[1] = bgfx::createFrameBuffer( 64, 64, bgfx::TextureFormat::BGRA8);
@@ -244,7 +242,11 @@ public:
}
bgfx::destroy(m_bright);
bgfx::destroy(m_blur);
bgfx::destroy(m_fbh);
if (bgfx::isValid(m_fbh) )
{
bgfx::destroy(m_fbh);
}
bgfx::destroy(m_meshProgram);
bgfx::destroy(m_skyProgram);
@@ -277,7 +279,8 @@ public:
{
if (!entry::processEvents(m_width, m_height, m_debug, m_reset, &m_mouseState) )
{
if (m_oldWidth != m_width
if (!bgfx::isValid(m_fbh)
|| m_oldWidth != m_width
|| m_oldHeight != m_height
|| m_oldReset != m_reset)
{
@@ -288,10 +291,37 @@ public:
uint32_t msaa = (m_reset&BGFX_RESET_MSAA_MASK)>>BGFX_RESET_MSAA_SHIFT;
bgfx::destroy(m_fbh);
if (bgfx::isValid(m_fbh) )
{
bgfx::destroy(m_fbh);
}
m_fbtextures[0] = bgfx::createTexture2D(
uint16_t(m_width)
, uint16_t(m_height)
, false
, 1
, bgfx::TextureFormat::BGRA8
, ((msaa + 1) << BGFX_TEXTURE_RT_MSAA_SHIFT) | BGFX_TEXTURE_U_CLAMP | BGFX_TEXTURE_V_CLAMP
);
const uint32_t textureFlags = BGFX_TEXTURE_RT_WRITE_ONLY|( (msaa+1)<<BGFX_TEXTURE_RT_MSAA_SHIFT);
bgfx::TextureFormat::Enum depthFormat =
bgfx::isTextureValid(0, false, 1, bgfx::TextureFormat::D16, textureFlags) ? bgfx::TextureFormat::D16
: bgfx::isTextureValid(0, false, 1, bgfx::TextureFormat::D24S8, textureFlags) ? bgfx::TextureFormat::D24S8
: bgfx::TextureFormat::D32
;
m_fbtextures[1] = bgfx::createTexture2D(
uint16_t(m_width)
, uint16_t(m_height)
, false
, 1
, depthFormat
, textureFlags
);
m_fbtextures[0] = bgfx::createTexture2D(uint16_t(m_width), uint16_t(m_height), false, 1, bgfx::TextureFormat::BGRA8, ((msaa + 1) << BGFX_TEXTURE_RT_MSAA_SHIFT) | BGFX_TEXTURE_U_CLAMP | BGFX_TEXTURE_V_CLAMP);
m_fbtextures[1] = bgfx::createTexture2D(uint16_t(m_width), uint16_t(m_height), false, 1, bgfx::TextureFormat::D16, BGFX_TEXTURE_RT_WRITE_ONLY|( (msaa+1)<<BGFX_TEXTURE_RT_MSAA_SHIFT) );
m_fbh = bgfx::createFrameBuffer(BX_COUNTOF(m_fbtextures), m_fbtextures, true);
}