Added support for automatic texture scaling by backbuffer ratio on backbuffer resize.

This commit is contained in:
Branimir Karadžić
2015-04-13 18:39:38 -07:00
parent 6878b8de29
commit c01a93e29d
8 changed files with 208 additions and 29 deletions
+29
View File
@@ -1717,6 +1717,35 @@ namespace bgfx { namespace gl
{
}
void resizeTexture(TextureHandle _handle, uint16_t _width, uint16_t _height) BX_OVERRIDE
{
TextureGL& texture = m_textures[_handle.idx];
uint32_t size = sizeof(uint32_t) + sizeof(TextureCreate);
const Memory* mem = alloc(size);
bx::StaticMemoryBlockWriter writer(mem->data, mem->size);
uint32_t magic = BGFX_CHUNK_MAGIC_TEX;
bx::write(&writer, magic);
TextureCreate tc;
tc.m_flags = texture.m_flags;
tc.m_width = _width;
tc.m_height = _height;
tc.m_sides = 0;
tc.m_depth = 0;
tc.m_numMips = 1;
tc.m_format = texture.m_requestedFormat;
tc.m_cubeMap = false;
tc.m_mem = NULL;
bx::write(&writer, tc);
texture.destroy();
texture.create(mem, tc.m_flags, 0);
release(mem);
}
void destroyTexture(TextureHandle _handle) BX_OVERRIDE
{
m_textures[_handle.idx].destroy();