SpiecsEngine
 
Loading...
Searching...
No Matches

◆ CustomMaterialImage()

void Spices::ImGuiH::CustomMaterialImage ( SlateImage * context,
ImVec2 size )
static

Draw image with custom material.

Parameters
[in]contextSlateImage.
[in]sizeimage size.

Definition at line 307 of file ImguiHelper.cpp.

308 {
310
311 ImGuiWindow* window = ImGui::GetCurrentWindow();
312 const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + size);
313
314 ImDrawList* draw_list = ImGui::GetWindowDrawList();
315 draw_list->PushTextureID(context->GetTextureID());
316 draw_list->PrimReserve(6, 4);
317 draw_list->PrimRectUV(bb.Min, bb.Max, ImVec2(0.0f, 0.0f), ImVec2(1.0f, 1.0f), ImGui::GetColorU32(ImVec4(1.0f, 1.0f, 1.0f, 1.0f)));
318 draw_list->AddCallback([](const ImDrawList* drawList, const ImDrawCmd* cmd, const int global_idx_offset, const int global_vtx_offset) {
319
320 ImGui_ImplVulkan_RenderState* render_state = (ImGui_ImplVulkan_RenderState*)ImGui::GetPlatformIO().Renderer_RenderState;
321 auto set = reinterpret_cast<VkDescriptorSet>(cmd->GetTexID());
322 auto pipeline = static_cast<VulkanPipeline*>(cmd->UserCallbackData);
323
324 ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData();
325 vkCmdBindDescriptorSets(render_state->CommandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, render_state->PipelineLayout, 0, 1, &set, 0, nullptr);
326
327 //vkCmdBindPipeline(render_state->CommandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline->GetPipeline());
328
329 vkCmdDrawIndexed(render_state->CommandBuffer, cmd->ElemCount, 1, cmd->IdxOffset + global_idx_offset, cmd->VtxOffset + global_vtx_offset, 0);
330
331 }, SlateRenderer::GetPipeline(context->GetMaterial()->GetName()).get());
332 draw_list->PopTextureID();
333 draw_list->AddCallback(ImDrawCallback_ResetRenderState, nullptr);
334 }
#define SPICES_PROFILE_ZONE
static std::shared_ptr< VulkanPipeline > GetPipeline(const std::string &name)
Get slate material pipeline.