Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ImDrawCmd.UserCallback support #11

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Soreepeong
Copy link

Added to IImGuiRenderer:

  • ResetDrawCmdUserCallback
  • AddDrawCmdUserCallback
  • RemoveDrawCmdUserCallback

Each ImDrawList.AddCallback will cause the current render parameters to be changed for the following operation. ResetDrawCmdUserCallback is provided to reset reset render parameters to the renderer defaults.

Example usage:

DeviceContext deviceContext = (valid_value);
RawDX11Scene scene = (valid_value);
PixelShader pixelShader = (valid_value);
SamplerState samplerState = (valid_value);
nint myCallback;

void Initialize() => myCallback = scene.Renderer.AddDrawCmdUserCallback(MyCallbackBody);

void Uninitialize() => scene.Renderer.RemoveDrawCmdUserCallback(MyCallbackBody);

void MyCallbackBody(ImDrawDataPtr drawData, ImDrawCmdPtr drawCmd) {
    deviceContext.PixelShader.Set(pixelShader);
    deviceContext.PixelShader.SetSampler(0, samplerState);
}

void Draw() {
    ImGui.AddCallback(myCallback, nint.Zero);
    ImGui.Image(someImage, new(1024, 1024));
    ImGui.AddCallback(scene.Renderer.ResetDrawCmdUserCallback, nint.Zero);
}

@Soreepeong
Copy link
Author

Testing some more use cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant