-
-
Notifications
You must be signed in to change notification settings - Fork 460
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
[Renderers/IMGUI] Create minimal ImDrawList example #97
base: main
Are you sure you want to change the base?
Conversation
This is a super cool idea and I will check it out, but just as a heads up I think we'll likely clone in imgui & sokol rather than include them inside the repo 👍 |
I just had a look at this and unfortunately I can't get it to compile on my mac out of the box, will try again tomorrow 🙂 |
@nicbarker Sorry, I forgot to link cocoa and openGL on mac platform. Updated. |
4fd677e
to
338852b
Compare
Hey @THISISAGOODNAME, I just updated to latest and there's something odd going on with clang & cmake on mac. I'm getting errors along the lines of |
Found a few things needed for new api to compile.
Clay_Dimensions measureText(Clay_StringSlice text, Clay_TextElementConfig* config, uintptr_t userData)
{
ImVec2 size = ImGui::CalcTextSize(text.chars, nullptr);
return (Clay_Dimensions)
{
.width = size.x,
.height = size.y,
};
} void initClay()
{
uint64_t totalMemorySize = Clay_MinMemorySize();
Clay_Arena clayMemory = Clay_CreateArenaWithCapacityAndMemory(totalMemorySize, (char*)malloc(totalMemorySize));
Clay_Initialize(clayMemory, Clay_Dimensions{
1280, 720 }, Clay_ErrorHandler{ HandleClayErrors });
Clay_SetMeasureTextFunction(measureText, 0);
Clay_Initialize(clayMemory, (Clay_Dimensions)
{
1280, 720
}, { errorCallback, 0 });
} Optionally, you can use void render(Clay_RenderCommandArray renderCommands)
{
ImDrawList* draw_list = ImGui::GetForegroundDrawList();
// start from 0,0
static ImVec2 p = {};
//...
} |
Here is demo document rendered using this PR and adjustments from this file https://github.com/KosmosisDire/VoxyEnginePlus/blob/8665459f1c394a299e6144af4e9e180f9faebcb7/app-framework/src/clayui/elements/helper/clay-imgui-renderer.hpp ImGuiIO& io = ImGui::GetIO();
ImVec2 mousePosition = io.MousePos;
ImVec2 scrollDelta = { io.MouseWheel ,io.MouseWheel }; |
Inspired by #69