Examples: Cast to ImTextureID instead of void* when assigning to TexId. Applied to all examples. (#2015)

This commit is contained in:
omar 2018-08-09 17:49:48 +02:00
parent 9c0805010f
commit 421dc19798
10 changed files with 17 additions and 14 deletions

View File

@ -213,7 +213,8 @@ void ImGui_ImplDX10_RenderDrawData(ImDrawData* draw_data)
ctx->RSSetScissorRects(1, &r);
// Bind texture, Draw
ctx->PSSetShaderResources(0, 1, (ID3D10ShaderResourceView**)&pcmd->TextureId);
ID3D10ShaderResourceView* texture_srv = (ID3D10ShaderResourceView*)pcmd->TextureId;
ctx->PSSetShaderResources(0, 1, &texture_srv);
ctx->DrawIndexed(pcmd->ElemCount, idx_offset, vtx_offset);
}
idx_offset += pcmd->ElemCount;
@ -279,7 +280,7 @@ static void ImGui_ImplDX10_CreateFontsTexture()
}
// Store our identifier
io.Fonts->TexID = (void *)g_pFontTextureView;
io.Fonts->TexID = (ImTextureID)g_pFontTextureView;
// Create texture sampler
{

View File

@ -218,7 +218,8 @@ void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data)
ctx->RSSetScissorRects(1, &r);
// Bind texture, Draw
ctx->PSSetShaderResources(0, 1, (ID3D11ShaderResourceView**)&pcmd->TextureId);
ID3D11ShaderResourceView* texture_srv = (ID3D11ShaderResourceView*)pcmd->TextureId;
ctx->PSSetShaderResources(0, 1, &texture_srv);
ctx->DrawIndexed(pcmd->ElemCount, idx_offset, vtx_offset);
}
idx_offset += pcmd->ElemCount;
@ -286,7 +287,7 @@ static void ImGui_ImplDX11_CreateFontsTexture()
}
// Store our identifier
io.Fonts->TexID = (void *)g_pFontTextureView;
io.Fonts->TexID = (ImTextureID)g_pFontTextureView;
// Create texture sampler
{

View File

@ -177,7 +177,8 @@ void ImGui_ImplDX9_RenderDrawData(ImDrawData* draw_data)
else
{
const RECT r = { (LONG)(pcmd->ClipRect.x - pos.x), (LONG)(pcmd->ClipRect.y - pos.y), (LONG)(pcmd->ClipRect.z - pos.x), (LONG)(pcmd->ClipRect.w - pos.y) };
g_pd3dDevice->SetTexture(0, (LPDIRECT3DTEXTURE9)pcmd->TextureId);
const LPDIRECT3DTEXTURE9 texture = (LPDIRECT3DTEXTURE9)pcmd->TextureId;
g_pd3dDevice->SetTexture(0, texture);
g_pd3dDevice->SetScissorRect(&r);
g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, vtx_offset, 0, (UINT)cmd_list->VtxBuffer.Size, idx_offset, pcmd->ElemCount/3);
}
@ -228,7 +229,7 @@ static bool ImGui_ImplDX9_CreateFontsTexture()
g_FontTexture->UnlockRect(0);
// Store our identifier
io.Fonts->TexID = (void *)g_FontTexture;
io.Fonts->TexID = (ImTextureID)g_FontTexture;
return true;
}

View File

@ -190,7 +190,7 @@ bool ImGui_Marmalade_CreateDeviceObjects()
g_FontTexture->Upload();
// Store our identifier
io.Fonts->TexID = (void *)g_FontTexture;
io.Fonts->TexID = (ImTextureID)g_FontTexture;
return true;
}

View File

@ -98,7 +98,7 @@ bool ImGui_ImplMetal_CreateFontsTexture(id<MTLDevice> device)
[g_sharedMetalContext makeFontTextureWithDevice:device];
ImGuiIO& io = ImGui::GetIO();
io.Fonts->TexID = (__bridge void *)g_sharedMetalContext.fontTexture;
io.Fonts->TexID = (__bridge void *)g_sharedMetalContext.fontTexture; // ImTextureID == void*
return (g_sharedMetalContext.fontTexture != nil);
}

View File

@ -182,7 +182,7 @@ bool ImGui_ImplOpenGL2_CreateFontsTexture()
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
// Store our identifier
io.Fonts->TexID = (void *)(intptr_t)g_FontTexture;
io.Fonts->TexID = (ImTextureID)(intptr_t)g_FontTexture;
// Restore state
glBindTexture(GL_TEXTURE_2D, last_texture);

View File

@ -279,7 +279,7 @@ bool ImGui_ImplOpenGL3_CreateFontsTexture()
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
// Store our identifier
io.Fonts->TexID = (void *)(intptr_t)g_FontTexture;
io.Fonts->TexID = (ImTextureID)(intptr_t)g_FontTexture;
// Restore state
glBindTexture(GL_TEXTURE_2D, last_texture);

View File

@ -461,7 +461,7 @@ bool ImGui_ImplVulkan_CreateFontsTexture(VkCommandBuffer command_buffer)
}
// Store our identifier
io.Fonts->TexID = (void *)(intptr_t)g_FontImage;
io.Fonts->TexID = (ImTextureID)(intptr_t)g_FontImage;
return true;
}