Merge pull request #428 from ocornut/imgui_scintilla_fixes

Fixes for ocornut-imgui integration
This commit is contained in:
Branimir Karadžić 2015-06-09 16:00:29 -07:00
commit 33de71efbd

View file

@ -35,17 +35,10 @@ struct OcornutImguiContext
{ {
bgfx::TransientVertexBuffer tvb; bgfx::TransientVertexBuffer tvb;
uint32_t vtx_size = 0;
const ImDrawList* cmd_list = _lists[ii]; const ImDrawList* cmd_list = _lists[ii];
const ImDrawVert* vtx_buffer = cmd_list->vtx_buffer.begin(); const ImDrawVert* vtx_buffer = cmd_list->vtx_buffer.begin();
uint32_t vtx_size = (uint32_t)cmd_list->vtx_buffer.size();
const ImDrawCmd* pcmd_begin = cmd_list->commands.begin();
const ImDrawCmd* pcmd_end = cmd_list->commands.end();
for (const ImDrawCmd* pcmd = pcmd_begin; pcmd != pcmd_end; pcmd++)
{
vtx_size += (uint32_t)pcmd->vtx_count;
}
if (!bgfx::checkAvailTransientVertexBuffer(vtx_size, m_decl)) if (!bgfx::checkAvailTransientVertexBuffer(vtx_size, m_decl))
{ {
@ -59,6 +52,8 @@ struct OcornutImguiContext
memcpy(verts, vtx_buffer, vtx_size * sizeof(ImDrawVert)); memcpy(verts, vtx_buffer, vtx_size * sizeof(ImDrawVert));
uint32_t vtx_offset = 0; uint32_t vtx_offset = 0;
const ImDrawCmd* pcmd_begin = cmd_list->commands.begin();
const ImDrawCmd* pcmd_end = cmd_list->commands.end();
for (const ImDrawCmd* pcmd = pcmd_begin; pcmd != pcmd_end; pcmd++) for (const ImDrawCmd* pcmd = pcmd_begin; pcmd != pcmd_end; pcmd++)
{ {
if (0 == pcmd->vtx_count) if (0 == pcmd->vtx_count)
@ -72,10 +67,10 @@ struct OcornutImguiContext
| BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_SRC_ALPHA, BGFX_STATE_BLEND_INV_SRC_ALPHA) | BGFX_STATE_BLEND_FUNC(BGFX_STATE_BLEND_SRC_ALPHA, BGFX_STATE_BLEND_INV_SRC_ALPHA)
| BGFX_STATE_MSAA | BGFX_STATE_MSAA
); );
bgfx::setScissor(uint16_t(pcmd->clip_rect.x) bgfx::setScissor(uint16_t(bx::fmax(pcmd->clip_rect.x, 0.0f))
, uint16_t(pcmd->clip_rect.y) , uint16_t(bx::fmax(pcmd->clip_rect.y, 0.0f))
, uint16_t(pcmd->clip_rect.z-pcmd->clip_rect.x) , uint16_t(bx::fmin(pcmd->clip_rect.z, 65535.0f)-bx::fmax(pcmd->clip_rect.x, 0.0f))
, uint16_t(pcmd->clip_rect.w-pcmd->clip_rect.y) , uint16_t(bx::fmin(pcmd->clip_rect.w, 65535.0f)-bx::fmax(pcmd->clip_rect.y, 0.0f))
); );
union { void* ptr; bgfx::TextureHandle handle; } texture = { pcmd->texture_id }; union { void* ptr; bgfx::TextureHandle handle; } texture = { pcmd->texture_id };