mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-04 20:18:47 +02:00
AA branch: Agressively renamed all fields of ImDrawList, ImDrawCmd, ImDrawData to match the rest of our coding convention (#133)
This commit is contained in:
@ -50,13 +50,13 @@ static void ImGui_ImplDX11_RenderDrawLists(ImDrawData* draw_data)
|
||||
return;
|
||||
ImDrawVert* vtx_dst = (ImDrawVert*)vtx_resource.pData;
|
||||
ImDrawIdx* idx_dst = (ImDrawIdx*)idx_resource.pData;
|
||||
for (int n = 0; n < draw_data->cmd_lists_count; n++)
|
||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
||||
{
|
||||
const ImDrawList* cmd_list = draw_data->cmd_lists[n];
|
||||
memcpy(vtx_dst, &cmd_list->vtx_buffer[0], cmd_list->vtx_buffer.size() * sizeof(ImDrawVert));
|
||||
memcpy(idx_dst, &cmd_list->idx_buffer[0], cmd_list->idx_buffer.size() * sizeof(ImDrawIdx));
|
||||
vtx_dst += cmd_list->vtx_buffer.size();
|
||||
idx_dst += cmd_list->idx_buffer.size();
|
||||
const ImDrawList* cmd_list = draw_data->CmdLists[n];
|
||||
memcpy(vtx_dst, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
|
||||
memcpy(idx_dst, &cmd_list->IdxBuffer[0], cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx));
|
||||
vtx_dst += cmd_list->VtxBuffer.size();
|
||||
idx_dst += cmd_list->IdxBuffer.size();
|
||||
}
|
||||
g_pd3dDeviceContext->Unmap(g_pVB, 0);
|
||||
g_pd3dDeviceContext->Unmap(g_pIB, 0);
|
||||
@ -116,26 +116,26 @@ static void ImGui_ImplDX11_RenderDrawLists(ImDrawData* draw_data)
|
||||
// Render command lists
|
||||
int vtx_offset = 0;
|
||||
int idx_offset = 0;
|
||||
for (int n = 0; n < draw_data->cmd_lists_count; n++)
|
||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
||||
{
|
||||
const ImDrawList* cmd_list = draw_data->cmd_lists[n];
|
||||
for (int cmd_i = 0; cmd_i < cmd_list->cmd_buffer.size(); cmd_i++)
|
||||
const ImDrawList* cmd_list = draw_data->CmdLists[n];
|
||||
for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
|
||||
{
|
||||
const ImDrawCmd* pcmd = &cmd_list->cmd_buffer[cmd_i];
|
||||
if (pcmd->user_callback)
|
||||
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
|
||||
if (pcmd->UserCallback)
|
||||
{
|
||||
pcmd->user_callback(cmd_list, pcmd);
|
||||
pcmd->UserCallback(cmd_list, pcmd);
|
||||
}
|
||||
else
|
||||
{
|
||||
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);
|
||||
const D3D11_RECT r = { (LONG)pcmd->ClipRect.x, (LONG)pcmd->ClipRect.y, (LONG)pcmd->ClipRect.z, (LONG)pcmd->ClipRect.w };
|
||||
g_pd3dDeviceContext->PSSetShaderResources(0, 1, (ID3D11ShaderResourceView**)&pcmd->TextureId);
|
||||
g_pd3dDeviceContext->RSSetScissorRects(1, &r);
|
||||
g_pd3dDeviceContext->DrawIndexed(pcmd->elem_count, idx_offset, vtx_offset);
|
||||
g_pd3dDeviceContext->DrawIndexed(pcmd->ElemCount, idx_offset, vtx_offset);
|
||||
}
|
||||
idx_offset += pcmd->elem_count;
|
||||
idx_offset += pcmd->ElemCount;
|
||||
}
|
||||
vtx_offset += (int)cmd_list->vtx_buffer.size();
|
||||
vtx_offset += cmd_list->VtxBuffer.size();
|
||||
}
|
||||
|
||||
// Restore modified state
|
||||
|
@ -35,15 +35,15 @@ static void ImGui_ImplDX9_RenderDrawLists(ImDrawData* draw_data)
|
||||
// Copy and convert all vertices into a single contiguous buffer
|
||||
CUSTOMVERTEX* vtx_dst;
|
||||
ImDrawIdx* idx_dst;
|
||||
if (g_pVB->Lock(0, (UINT)(draw_data->total_vtx_count * sizeof(CUSTOMVERTEX)), (void**)&vtx_dst, D3DLOCK_DISCARD) < 0)
|
||||
if (g_pVB->Lock(0, (UINT)(draw_data->TotalVtxCount * sizeof(CUSTOMVERTEX)), (void**)&vtx_dst, D3DLOCK_DISCARD) < 0)
|
||||
return;
|
||||
if (g_pIB->Lock(0, (UINT)(draw_data->total_idx_count * sizeof(ImDrawIdx)), (void**)&idx_dst, D3DLOCK_DISCARD) < 0)
|
||||
if (g_pIB->Lock(0, (UINT)(draw_data->TotalIdxCount * sizeof(ImDrawIdx)), (void**)&idx_dst, D3DLOCK_DISCARD) < 0)
|
||||
return;
|
||||
for (int n = 0; n < draw_data->cmd_lists_count; n++)
|
||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
||||
{
|
||||
const ImDrawList* cmd_list = draw_data->cmd_lists[n];
|
||||
const ImDrawVert* vtx_src = &cmd_list->vtx_buffer[0];
|
||||
for (int i = 0; i < cmd_list->vtx_buffer.size(); i++)
|
||||
const ImDrawList* cmd_list = draw_data->CmdLists[n];
|
||||
const ImDrawVert* vtx_src = &cmd_list->VtxBuffer[0];
|
||||
for (int i = 0; i < cmd_list->VtxBuffer.size(); i++)
|
||||
{
|
||||
vtx_dst->pos.x = vtx_src->pos.x;
|
||||
vtx_dst->pos.y = vtx_src->pos.y;
|
||||
@ -54,8 +54,8 @@ static void ImGui_ImplDX9_RenderDrawLists(ImDrawData* draw_data)
|
||||
vtx_dst++;
|
||||
vtx_src++;
|
||||
}
|
||||
memcpy(idx_dst, &cmd_list->idx_buffer[0], cmd_list->idx_buffer.size() * sizeof(ImDrawIdx));
|
||||
idx_dst += cmd_list->idx_buffer.size();
|
||||
memcpy(idx_dst, &cmd_list->IdxBuffer[0], cmd_list->IdxBuffer.size() * sizeof(ImDrawIdx));
|
||||
idx_dst += cmd_list->IdxBuffer.size();
|
||||
}
|
||||
g_pVB->Unlock();
|
||||
g_pIB->Unlock();
|
||||
@ -94,26 +94,26 @@ static void ImGui_ImplDX9_RenderDrawLists(ImDrawData* draw_data)
|
||||
// Render command lists
|
||||
int vtx_offset = 0;
|
||||
int idx_offset = 0;
|
||||
for (int n = 0; n < draw_data->cmd_lists_count; n++)
|
||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
||||
{
|
||||
const ImDrawList* cmd_list = draw_data->cmd_lists[n];
|
||||
for (int cmd_i = 0; cmd_i < cmd_list->cmd_buffer.size(); cmd_i++)
|
||||
const ImDrawList* cmd_list = draw_data->CmdLists[n];
|
||||
for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
|
||||
{
|
||||
const ImDrawCmd* pcmd = &cmd_list->cmd_buffer[cmd_i];
|
||||
if (pcmd->user_callback)
|
||||
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
|
||||
if (pcmd->UserCallback)
|
||||
{
|
||||
pcmd->user_callback(cmd_list, pcmd);
|
||||
pcmd->UserCallback(cmd_list, pcmd);
|
||||
}
|
||||
else
|
||||
{
|
||||
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 );
|
||||
const RECT r = { (LONG)pcmd->ClipRect.x, (LONG)pcmd->ClipRect.y, (LONG)pcmd->ClipRect.z, (LONG)pcmd->ClipRect.w };
|
||||
g_pd3dDevice->SetTexture( 0, (LPDIRECT3DTEXTURE9)pcmd->TextureId );
|
||||
g_pd3dDevice->SetScissorRect(&r);
|
||||
g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, vtx_offset, 0, (UINT)cmd_list->vtx_buffer.size(), idx_offset, pcmd->elem_count/3);
|
||||
g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, vtx_offset, 0, (UINT)cmd_list->VtxBuffer.size(), idx_offset, pcmd->ElemCount/3);
|
||||
}
|
||||
idx_offset += pcmd->elem_count;
|
||||
idx_offset += pcmd->ElemCount;
|
||||
}
|
||||
vtx_offset += (int)cmd_list->vtx_buffer.size();
|
||||
vtx_offset += cmd_list->VtxBuffer.size();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ static void ImGui_ImplGlfwGL3_RenderDrawLists(ImDrawData* draw_data)
|
||||
|
||||
// Grow our buffer according to what we need
|
||||
glBindBuffer(GL_ARRAY_BUFFER, g_VboHandle);
|
||||
int needed_vtx_size = draw_data->total_vtx_count * sizeof(ImDrawVert);
|
||||
int needed_vtx_size = draw_data->TotalVtxCount * sizeof(ImDrawVert);
|
||||
if (g_VboSize < needed_vtx_size)
|
||||
{
|
||||
g_VboSize = needed_vtx_size + 5000 * sizeof(ImDrawVert); // Grow buffer
|
||||
@ -70,38 +70,38 @@ static void ImGui_ImplGlfwGL3_RenderDrawLists(ImDrawData* draw_data)
|
||||
unsigned char* vtx_data = (unsigned char*)glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
|
||||
if (!vtx_data)
|
||||
return;
|
||||
for (int n = 0; n < draw_data->cmd_lists_count; n++)
|
||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
||||
{
|
||||
const ImDrawList* cmd_list = draw_data->cmd_lists[n];
|
||||
memcpy(vtx_data, &cmd_list->vtx_buffer[0], cmd_list->vtx_buffer.size() * sizeof(ImDrawVert));
|
||||
vtx_data += cmd_list->vtx_buffer.size() * sizeof(ImDrawVert);
|
||||
const ImDrawList* cmd_list = draw_data->CmdLists[n];
|
||||
memcpy(vtx_data, &cmd_list->VtxBuffer[0], cmd_list->VtxBuffer.size() * sizeof(ImDrawVert));
|
||||
vtx_data += cmd_list->VtxBuffer.size() * sizeof(ImDrawVert);
|
||||
}
|
||||
glUnmapBuffer(GL_ARRAY_BUFFER);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glBindVertexArray(g_VaoHandle);
|
||||
|
||||
int vtx_offset = 0;
|
||||
for (int n = 0; n < draw_data->cmd_lists_count; n++)
|
||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
||||
{
|
||||
const ImDrawList* cmd_list = draw_data->cmd_lists[n];
|
||||
const ImDrawIdx* idx_buffer = (const unsigned short*)&cmd_list->idx_buffer.front();
|
||||
const ImDrawList* cmd_list = draw_data->CmdLists[n];
|
||||
const ImDrawIdx* idx_buffer = &cmd_list->IdxBuffer.front();
|
||||
|
||||
const ImDrawCmd* pcmd_end = cmd_list->cmd_buffer.end();
|
||||
for (const ImDrawCmd* pcmd = cmd_list->cmd_buffer.begin(); pcmd != pcmd_end; pcmd++)
|
||||
const ImDrawCmd* pcmd_end = cmd_list->CmdBuffer.end();
|
||||
for (const ImDrawCmd* pcmd = cmd_list->CmdBuffer.begin(); pcmd != pcmd_end; pcmd++)
|
||||
{
|
||||
if (pcmd->user_callback)
|
||||
if (pcmd->UserCallback)
|
||||
{
|
||||
pcmd->user_callback(cmd_list, pcmd);
|
||||
pcmd->UserCallback(cmd_list, pcmd);
|
||||
}
|
||||
else
|
||||
{
|
||||
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->elem_count, GL_UNSIGNED_SHORT, idx_buffer, vtx_offset);
|
||||
glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->TextureId);
|
||||
glScissor((int)pcmd->ClipRect.x, (int)(height - pcmd->ClipRect.w), (int)(pcmd->ClipRect.z - pcmd->ClipRect.x), (int)(pcmd->ClipRect.w - pcmd->ClipRect.y));
|
||||
glDrawElementsBaseVertex(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, GL_UNSIGNED_SHORT, idx_buffer, vtx_offset);
|
||||
}
|
||||
idx_buffer += pcmd->elem_count;
|
||||
idx_buffer += pcmd->ElemCount;
|
||||
}
|
||||
vtx_offset += (int)cmd_list->vtx_buffer.size();
|
||||
vtx_offset += cmd_list->VtxBuffer.size();
|
||||
}
|
||||
|
||||
// Restore modified state
|
||||
|
@ -53,29 +53,29 @@ static void ImGui_ImplGlfw_RenderDrawLists(ImDrawData* draw_data)
|
||||
|
||||
// Render command lists
|
||||
#define OFFSETOF(TYPE, ELEMENT) ((size_t)&(((TYPE *)0)->ELEMENT))
|
||||
for (int n = 0; n < draw_data->cmd_lists_count; n++)
|
||||
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
||||
{
|
||||
const ImDrawList* cmd_list = draw_data->cmd_lists[n];
|
||||
const unsigned char* vtx_buffer = (const unsigned char*)&cmd_list->vtx_buffer.front();
|
||||
const ImDrawIdx* idx_buffer = (const unsigned short*)&cmd_list->idx_buffer.front();
|
||||
const ImDrawList* cmd_list = draw_data->CmdLists[n];
|
||||
const unsigned char* vtx_buffer = (const unsigned char*)&cmd_list->VtxBuffer.front();
|
||||
const ImDrawIdx* idx_buffer = &cmd_list->IdxBuffer.front();
|
||||
glVertexPointer(2, GL_FLOAT, sizeof(ImDrawVert), (void*)(vtx_buffer + OFFSETOF(ImDrawVert, pos)));
|
||||
glTexCoordPointer(2, GL_FLOAT, sizeof(ImDrawVert), (void*)(vtx_buffer + OFFSETOF(ImDrawVert, uv)));
|
||||
glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(ImDrawVert), (void*)(vtx_buffer + OFFSETOF(ImDrawVert, col)));
|
||||
|
||||
for (int cmd_i = 0; cmd_i < cmd_list->cmd_buffer.size(); cmd_i++)
|
||||
for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.size(); cmd_i++)
|
||||
{
|
||||
const ImDrawCmd* pcmd = &cmd_list->cmd_buffer[cmd_i];
|
||||
if (pcmd->user_callback)
|
||||
const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i];
|
||||
if (pcmd->UserCallback)
|
||||
{
|
||||
pcmd->user_callback(cmd_list, pcmd);
|
||||
pcmd->UserCallback(cmd_list, pcmd);
|
||||
}
|
||||
else
|
||||
{
|
||||
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->elem_count, GL_UNSIGNED_SHORT, idx_buffer);
|
||||
glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->TextureId);
|
||||
glScissor((int)pcmd->ClipRect.x, (int)(height - pcmd->ClipRect.w), (int)(pcmd->ClipRect.z - pcmd->ClipRect.x), (int)(pcmd->ClipRect.w - pcmd->ClipRect.y));
|
||||
glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, GL_UNSIGNED_SHORT, idx_buffer);
|
||||
}
|
||||
idx_buffer += pcmd->elem_count;
|
||||
idx_buffer += pcmd->ElemCount;
|
||||
}
|
||||
}
|
||||
#undef OFFSETOF
|
||||
|
Reference in New Issue
Block a user