AA branch: ImDrawCmd idx_count -> elem_count

This commit is contained in:
ocornut 2015-07-05 22:09:15 -06:00
parent f3303fa84f
commit b2b616be00
6 changed files with 17 additions and 17 deletions

View File

@ -131,9 +131,9 @@ static void ImGui_ImplDX11_RenderDrawLists(ImDrawData* draw_data)
const D3D11_RECT r = { (LONG)pcmd->clip_rect.x, (LONG)pcmd->clip_rect.y, (LONG)pcmd->clip_rect.z, (LONG)pcmd->clip_rect.w };
g_pd3dDeviceContext->PSSetShaderResources(0, 1, (ID3D11ShaderResourceView**)&pcmd->texture_id);
g_pd3dDeviceContext->RSSetScissorRects(1, &r);
g_pd3dDeviceContext->DrawIndexed(pcmd->idx_count, idx_offset, vtx_offset);
g_pd3dDeviceContext->DrawIndexed(pcmd->elem_count, idx_offset, vtx_offset);
}
idx_offset += pcmd->idx_count;
idx_offset += pcmd->elem_count;
}
vtx_offset += (int)cmd_list->vtx_buffer.size();
}

View File

@ -109,9 +109,9 @@ static void ImGui_ImplDX9_RenderDrawLists(ImDrawData* draw_data)
const RECT r = { (LONG)pcmd->clip_rect.x, (LONG)pcmd->clip_rect.y, (LONG)pcmd->clip_rect.z, (LONG)pcmd->clip_rect.w };
g_pd3dDevice->SetTexture( 0, (LPDIRECT3DTEXTURE9)pcmd->texture_id );
g_pd3dDevice->SetScissorRect(&r);
g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, vtx_offset, 0, (UINT)cmd_list->vtx_buffer.size(), idx_offset, pcmd->idx_count/3);
g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, vtx_offset, 0, (UINT)cmd_list->vtx_buffer.size(), idx_offset, pcmd->elem_count/3);
}
idx_offset += pcmd->idx_count;
idx_offset += pcmd->elem_count;
}
vtx_offset += (int)cmd_list->vtx_buffer.size();
}

View File

@ -97,9 +97,9 @@ static void ImGui_ImplGlfwGL3_RenderDrawLists(ImDrawData* draw_data)
{
glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->texture_id);
glScissor((int)pcmd->clip_rect.x, (int)(height - pcmd->clip_rect.w), (int)(pcmd->clip_rect.z - pcmd->clip_rect.x), (int)(pcmd->clip_rect.w - pcmd->clip_rect.y));
glDrawElementsBaseVertex(GL_TRIANGLES, (GLsizei)pcmd->idx_count, GL_UNSIGNED_SHORT, idx_buffer, vtx_offset);
glDrawElementsBaseVertex(GL_TRIANGLES, (GLsizei)pcmd->elem_count, GL_UNSIGNED_SHORT, idx_buffer, vtx_offset);
}
idx_buffer += pcmd->idx_count;
idx_buffer += pcmd->elem_count;
}
vtx_offset += (int)cmd_list->vtx_buffer.size();
}

View File

@ -73,9 +73,9 @@ static void ImGui_ImplGlfw_RenderDrawLists(ImDrawData* draw_data)
{
glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->texture_id);
glScissor((int)pcmd->clip_rect.x, (int)(height - pcmd->clip_rect.w), (int)(pcmd->clip_rect.z - pcmd->clip_rect.x), (int)(pcmd->clip_rect.w - pcmd->clip_rect.y));
glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->idx_count, GL_UNSIGNED_SHORT, idx_buffer);
glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->elem_count, GL_UNSIGNED_SHORT, idx_buffer);
}
idx_buffer += pcmd->idx_count;
idx_buffer += pcmd->elem_count;
}
}
#undef OFFSETOF

View File

@ -1890,7 +1890,7 @@ static inline void AddDrawListToRenderList(ImVector<ImDrawList*>& out_render_lis
{
if (!draw_list->commands.empty() && !draw_list->vtx_buffer.empty())
{
if (draw_list->commands.back().idx_count == 0)
if (draw_list->commands.back().elem_count == 0)
draw_list->commands.pop_back();
out_render_list.push_back(draw_list);
GImGui->IO.MetricsRenderVertices += (int)draw_list->vtx_buffer.size();
@ -8965,7 +8965,7 @@ void ImDrawList::ClearFreeMemory()
void ImDrawList::AddDrawCmd()
{
ImDrawCmd draw_cmd;
draw_cmd.idx_count = 0;
draw_cmd.elem_count = 0;
draw_cmd.clip_rect = clip_rect_stack.empty() ? GNullClipRect : clip_rect_stack.back();
draw_cmd.texture_id = texture_id_stack.empty() ? NULL : texture_id_stack.back();
draw_cmd.user_callback = NULL;
@ -8978,7 +8978,7 @@ void ImDrawList::AddDrawCmd()
void ImDrawList::AddCallback(ImDrawCallback callback, void* callback_data)
{
ImDrawCmd* current_cmd = commands.empty() ? NULL : &commands.back();
if (!current_cmd || current_cmd->idx_count != 0 || current_cmd->user_callback != NULL)
if (!current_cmd || current_cmd->elem_count != 0 || current_cmd->user_callback != NULL)
{
AddDrawCmd();
current_cmd = &commands.back();
@ -8994,7 +8994,7 @@ void ImDrawList::AddCallback(ImDrawCallback callback, void* callback_data)
void ImDrawList::UpdateClipRect()
{
ImDrawCmd* current_cmd = commands.empty() ? NULL : &commands.back();
if (!current_cmd || (current_cmd->idx_count != 0) || current_cmd->user_callback != NULL)
if (!current_cmd || (current_cmd->elem_count != 0) || current_cmd->user_callback != NULL)
{
AddDrawCmd();
}
@ -9035,7 +9035,7 @@ void ImDrawList::UpdateTextureID()
{
ImDrawCmd* current_cmd = commands.empty() ? NULL : &commands.back();
const ImTextureID texture_id = texture_id_stack.empty() ? NULL : texture_id_stack.back();
if (!current_cmd || (current_cmd->idx_count != 0 && current_cmd->texture_id != texture_id) || current_cmd->user_callback != NULL)
if (!current_cmd || (current_cmd->elem_count != 0 && current_cmd->texture_id != texture_id) || current_cmd->user_callback != NULL)
{
AddDrawCmd();
}
@ -9061,7 +9061,7 @@ void ImDrawList::PopTextureID()
void ImDrawList::PrimReserve(unsigned int idx_count, unsigned int vtx_count)
{
ImDrawCmd& draw_cmd = commands.back();
draw_cmd.idx_count += idx_count;
draw_cmd.elem_count += idx_count;
size_t vtx_buffer_size = vtx_buffer.size();
vtx_buffer.resize(vtx_buffer_size + vtx_count);
@ -9480,7 +9480,7 @@ void ImDrawList::AddText(const ImFont* font, float font_size, const ImVec2& pos,
idx_buffer.resize((size_t)(idx_write - &idx_buffer.front()));
unsigned int vtx_unused = vtx_count_max - (unsigned int)(vtx_buffer.size() - vtx_begin);
unsigned int idx_unused = idx_count_max - (unsigned int)(idx_buffer.size() - idx_begin);
commands.back().idx_count -= idx_unused;
commands.back().elem_count -= idx_unused;
vtx_write -= vtx_unused;
idx_write -= idx_unused;
vtx_current_idx = (ImDrawIdx)vtx_buffer.size();
@ -12208,7 +12208,7 @@ void ImGui::ShowMetricsWindow(bool* opened)
if (pcmd->user_callback)
ImGui::BulletText("Callback %p, user_data %p", pcmd->user_callback, pcmd->user_callback_data);
else
ImGui::BulletText("Draw %d indexed vtx, tex = %p", pcmd->idx_count, pcmd->texture_id);
ImGui::BulletText("Draw %d indexed vtx, tex = %p", pcmd->elem_count, pcmd->texture_id);
ImGui::TreePop();
}

View File

@ -999,7 +999,7 @@ typedef void (*ImDrawCallback)(const ImDrawList* parent_list, const ImDrawCmd* c
// Typically, 1 command = 1 gpu draw call (unless command is a callback)
struct ImDrawCmd
{
unsigned int idx_count; // Number of indices (multiple of 3) to be rendered as triangles. Vertices are stored in the callee ImDrawList's vtx_buffer[] array, indices in idx_buffer[].
unsigned int elem_count; // Number of indices (multiple of 3) to be rendered as triangles. Vertices are stored in the callee ImDrawList's vtx_buffer[] array, indices in idx_buffer[].
ImVec4 clip_rect; // Clipping rectangle (x1, y1, x2, y2)
ImTextureID texture_id; // User-provided texture ID. Set by user in ImfontAtlas::SetTexID() for fonts or passed to Image*() functions. Ignore if never using images or multiple fonts atlas.
ImDrawCallback user_callback; // If != NULL, call the function instead of rendering the vertices. clip_rect and texture_id will be set normally.