mirror of
https://github.com/ocornut/imgui.git
synced 2024-11-12 02:00:58 +01:00
Examples: Most examples apps detect if ImDrawIdx was changed to 32-bits instead of 16
This commit is contained in:
parent
4982cd136e
commit
e46c7b70eb
@ -56,7 +56,8 @@ void ImGui_ImplA5_RenderDrawLists(ImDrawData* draw_data)
|
|||||||
vertices[i] = v;
|
vertices[i] = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME-OPT: Unfortunately Allegro doesn't support 16-bit vertices
|
// FIXME-OPT: Unfortunately Allegro doesn't support 16-bit indices
|
||||||
|
// You can also use '#define ImDrawIdx unsigned int' in imconfig.h and request ImGui to output 32-bit indices
|
||||||
static ImVector<int> indices;
|
static ImVector<int> indices;
|
||||||
indices.resize(cmd_list->IdxBuffer.size());
|
indices.resize(cmd_list->IdxBuffer.size());
|
||||||
for (int i = 0; i < cmd_list->IdxBuffer.size(); ++i)
|
for (int i = 0; i < cmd_list->IdxBuffer.size(); ++i)
|
||||||
|
@ -132,7 +132,7 @@ void ImGui_ImplDX11_RenderDrawLists(ImDrawData* draw_data)
|
|||||||
unsigned int offset = 0;
|
unsigned int offset = 0;
|
||||||
g_pd3dDeviceContext->IASetInputLayout(g_pInputLayout);
|
g_pd3dDeviceContext->IASetInputLayout(g_pInputLayout);
|
||||||
g_pd3dDeviceContext->IASetVertexBuffers(0, 1, &g_pVB, &stride, &offset);
|
g_pd3dDeviceContext->IASetVertexBuffers(0, 1, &g_pVB, &stride, &offset);
|
||||||
g_pd3dDeviceContext->IASetIndexBuffer(g_pIB, DXGI_FORMAT_R16_UINT, 0);
|
g_pd3dDeviceContext->IASetIndexBuffer(g_pIB, sizeof(ImDrawIdx) == 2 ? DXGI_FORMAT_R16_UINT : DXGI_FORMAT_R32_UINT, 0);
|
||||||
g_pd3dDeviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
|
g_pd3dDeviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
|
||||||
g_pd3dDeviceContext->VSSetShader(g_pVertexShader, NULL, 0);
|
g_pd3dDeviceContext->VSSetShader(g_pVertexShader, NULL, 0);
|
||||||
g_pd3dDeviceContext->VSSetConstantBuffers(0, 1, &g_pVertexConstantBuffer);
|
g_pd3dDeviceContext->VSSetConstantBuffers(0, 1, &g_pVertexConstantBuffer);
|
||||||
|
@ -47,7 +47,7 @@ void ImGui_ImplDX9_RenderDrawLists(ImDrawData* draw_data)
|
|||||||
{
|
{
|
||||||
if (g_pIB) { g_pIB->Release(); g_pIB = NULL; }
|
if (g_pIB) { g_pIB->Release(); g_pIB = NULL; }
|
||||||
g_IndexBufferSize = draw_data->TotalIdxCount + 10000;
|
g_IndexBufferSize = draw_data->TotalIdxCount + 10000;
|
||||||
if (g_pd3dDevice->CreateIndexBuffer(g_IndexBufferSize * sizeof(ImDrawIdx), D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, D3DFMT_INDEX16, D3DPOOL_DEFAULT, &g_pIB, NULL) < 0)
|
if (g_pd3dDevice->CreateIndexBuffer(g_IndexBufferSize * sizeof(ImDrawIdx), D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, sizeof(ImDrawIdx) == 2 ? D3DFMT_INDEX16 : D3DFMT_INDEX32, D3DPOOL_DEFAULT, &g_pIB, NULL) < 0)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ void ImGui_ImplGlfwGL3_RenderDrawLists(ImDrawData* draw_data)
|
|||||||
{
|
{
|
||||||
glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->TextureId);
|
glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->TextureId);
|
||||||
glScissor((int)pcmd->ClipRect.x, (int)(fb_height - pcmd->ClipRect.w), (int)(pcmd->ClipRect.z - pcmd->ClipRect.x), (int)(pcmd->ClipRect.w - pcmd->ClipRect.y));
|
glScissor((int)pcmd->ClipRect.x, (int)(fb_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_offset);
|
glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer_offset);
|
||||||
}
|
}
|
||||||
idx_buffer_offset += pcmd->ElemCount;
|
idx_buffer_offset += pcmd->ElemCount;
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ void ImGui_ImplGlfw_RenderDrawLists(ImDrawData* draw_data)
|
|||||||
{
|
{
|
||||||
glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->TextureId);
|
glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->TextureId);
|
||||||
glScissor((int)pcmd->ClipRect.x, (int)(fb_height - pcmd->ClipRect.w), (int)(pcmd->ClipRect.z - pcmd->ClipRect.x), (int)(pcmd->ClipRect.w - pcmd->ClipRect.y));
|
glScissor((int)pcmd->ClipRect.x, (int)(fb_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);
|
glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer);
|
||||||
}
|
}
|
||||||
idx_buffer += pcmd->ElemCount;
|
idx_buffer += pcmd->ElemCount;
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ void ImGui_ImplSdl_RenderDrawLists(ImDrawData* draw_data)
|
|||||||
{
|
{
|
||||||
glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->TextureId);
|
glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->TextureId);
|
||||||
glScissor((int)pcmd->ClipRect.x, (int)(fb_height - pcmd->ClipRect.w), (int)(pcmd->ClipRect.z - pcmd->ClipRect.x), (int)(pcmd->ClipRect.w - pcmd->ClipRect.y));
|
glScissor((int)pcmd->ClipRect.x, (int)(fb_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);
|
glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer);
|
||||||
}
|
}
|
||||||
idx_buffer += pcmd->ElemCount;
|
idx_buffer += pcmd->ElemCount;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user