mirror of
https://github.com/bkaradzic/bgfx.git
synced 2026-11-15 04:25:31 +00:00
Added support for automatic texture scaling by backbuffer ratio on backbuffer resize.
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user