Texture override internal now returns 0 to signal that internal texture is not yet created.

This commit is contained in:
Branimir Karadžić
2016-02-05 18:41:01 -08:00
parent 55e72a2dd1
commit cf6ccace77
4 changed files with 32 additions and 15 deletions

View File

@@ -314,18 +314,31 @@ namespace bgfx
return &g_internalData;
}
void overrideInternal(TextureHandle _handle, uintptr_t _ptr)
uintptr_t overrideInternal(TextureHandle _handle, uintptr_t _ptr)
{
BGFX_CHECK_RENDER_THREAD();
s_ctx->m_renderCtx->overrideInternal(_handle, _ptr);
RendererContextI* rci = s_ctx->m_renderCtx;
if (0 == rci->getInternal(_handle) )
{
return 0;
}
rci->overrideInternal(_handle, _ptr);
return rci->getInternal(_handle);
}
uintptr_t overrideInternal(TextureHandle _handle, uint16_t _width, uint16_t _height, uint8_t _numMips, TextureFormat::Enum _format, uint32_t _flags)
{
BGFX_CHECK_RENDER_THREAD();
RendererContextI* rci = s_ctx->m_renderCtx;
if (0 == rci->getInternal(_handle) )
{
return 0;
}
uint32_t size = sizeof(uint32_t) + sizeof(TextureCreate);
Memory* mem = const_cast<Memory*>(alloc(size) );
Memory* mem = const_cast<Memory*>(alloc(size) );
bx::StaticMemoryBlockWriter writer(mem->data, mem->size);
uint32_t magic = BGFX_CHUNK_MAGIC_TEX;
@@ -343,12 +356,12 @@ namespace bgfx
tc.m_mem = NULL;
bx::write(&writer, tc);
s_ctx->m_renderCtx->destroyTexture(_handle);
s_ctx->m_renderCtx->createTexture(_handle, mem, _flags, 0);
rci->destroyTexture(_handle);
rci->createTexture(_handle, mem, _flags, 0);
release(mem);
return s_ctx->m_renderCtx->getInternal(_handle);
return rci->getInternal(_handle);
}
void setGraphicsDebuggerPresent(bool _present)
@@ -4457,10 +4470,10 @@ BGFX_C_API const bgfx_internal_data_t* bgfx_get_internal_data()
return (const bgfx_internal_data_t*)bgfx::getInternalData();
}
BGFX_C_API void bgfx_override_internal_texture_ptr(bgfx_texture_handle_t _handle, uintptr_t _ptr)
BGFX_C_API uintptr_t bgfx_override_internal_texture_ptr(bgfx_texture_handle_t _handle, uintptr_t _ptr)
{
union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle = { _handle };
bgfx::overrideInternal(handle.cpp, _ptr);
return bgfx::overrideInternal(handle.cpp, _ptr);
}
BGFX_C_API uintptr_t bgfx_override_internal_texture(bgfx_texture_handle_t _handle, uint16_t _width, uint16_t _height, uint8_t _numMips, bgfx_texture_format_t _format, uint32_t _flags)