UserCallback bindings
See original GitHub issueHow are you handling situations when the render state changes, in vulkan they are using a callback function. Is it possible for you to quickly add this binding to your native library?
` // Render command lists
// (Because we merged all buffers into a single one, we maintain our own offset into them)
int global_vtx_offset = 0;
int global_idx_offset = 0;
for (int n = 0; n < draw_data->CmdListsCount; n++)
{
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->CmdBuffer[cmd_i];
if (pcmd->UserCallback != NULL)
{
// User callback, registered via ImDrawList::AddCallback()
// (ImDrawCallback_ResetRenderState is a special callback value used by the user to request the renderer to reset render state.)
if (pcmd->UserCallback == ImDrawCallback_ResetRenderState)
ImGui_ImplVulkan_SetupRenderState(draw_data, command_buffer, rb, fb_width, fb_height);
else
pcmd->UserCallback(cmd_list, pcmd);
}
else
{
// Project scissor/clipping rectangles into framebuffer space
ImVec4 clip_rect;
clip_rect.x = (pcmd->ClipRect.x - clip_off.x) * clip_scale.x;
clip_rect.y = (pcmd->ClipRect.y - clip_off.y) * clip_scale.y;
clip_rect.z = (pcmd->ClipRect.z - clip_off.x) * clip_scale.x;
clip_rect.w = (pcmd->ClipRect.w - clip_off.y) * clip_scale.y;
if (clip_rect.x < fb_width && clip_rect.y < fb_height && clip_rect.z >= 0.0f && clip_rect.w >= 0.0f)
{
// Negative offsets are illegal for vkCmdSetScissor
if (clip_rect.x < 0.0f)
clip_rect.x = 0.0f;
if (clip_rect.y < 0.0f)
clip_rect.y = 0.0f;
// Apply scissor/clipping rectangle
VkRect2D scissor;
scissor.offset.x = (int32_t)(clip_rect.x);
scissor.offset.y = (int32_t)(clip_rect.y);
scissor.extent.width = (uint32_t)(clip_rect.z - clip_rect.x);
scissor.extent.height = (uint32_t)(clip_rect.w - clip_rect.y);
vkCmdSetScissor(command_buffer, 0, 1, &scissor);
// Draw
vkCmdDrawIndexed(command_buffer, pcmd->ElemCount, 1, pcmd->IdxOffset + global_idx_offset, pcmd->VtxOffset + global_vtx_offset, 0);
}
}
}
global_idx_offset += cmd_list->IdxBuffer.Size;
global_vtx_offset += cmd_list->VtxBuffer.Size;
}`
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Your Guide to React.useCallback() - Dmitri Pavlutin
A functional component wrapped inside React.memo() accepts a function object prop; When the function object is a dependency to other hooks, e.g. ...
Read more >Examples: Metal: Restore state after UserCallback by bear24rw ...
In Metal there doesn't seem to be a way for a UserCallback to save the existing state before changing it so we should...
Read more >User Callback - Libwebsockets
The protocol callback is the primary way lws interacts with user code. For one of a list of a few dozen reasons the...
Read more >C++ Binding Issues - MPI Forum
User callback functions that return integer error codes should not throw exceptions; ... The C++ bindings presented in Annex MPI-1 C++ Language Binding...
Read more >C Bindings: Callbacks - Crystal - W3cubDocs
Callbacks. You can use function types in C declarations: lib X # In C: # # void callback(int (*f)(int)); fun callback(f : Int32...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I got rendering to the ImGui window working via a framebuffer texture.
Awesome, thanks! Greetings,
Thanks, Georgii
On Thu, Feb 11, 2021 at 8:13 PM Duncan Calvert notifications@github.com wrote: