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

Imgui with win32 and OpenGl #372

Closed
anshul-soni opened this issue Oct 13, 2015 · 10 comments
Closed

Imgui with win32 and OpenGl #372

anshul-soni opened this issue Oct 13, 2015 · 10 comments

Comments

@anshul-soni
Copy link

So I am using win32 api to create my window and opengl for rendering.
I am little bit confused on how to implement imgui withing my interface. I couldnt find any example which does that.
Can you please help me out with the same ?
Thanks.

@ocornut
Copy link
Owner

ocornut commented Oct 14, 2015

You may want to look at those example too
#281

@anshul-soni
Copy link
Author

Thanks a lot for that, thats really helpful !!
I actually cant do that, because my window is created by my window system and opengl is initialized in my graphics system. But I got it working. 👍

@ocornut
Copy link
Owner

ocornut commented Oct 14, 2015

Good to hear. Anything you stumbled on? Looking for idea on how we can improve the documentation for future users.

@ocornut ocornut closed this as completed Oct 14, 2015
@anshul-soni
Copy link
Author

So I was able to do everything but the input.
My input call back method is inside windows system and its assigned to windows in there.
My editor is using the libraries of my engine to run, so I am not sure how to handle the input yet.

@anshul-soni
Copy link
Author

So this is code of main in my editor, which lets me render the imgui. But still couldnt figure out how to handle inputs in imgui and my engine with this approach. One thing I did was pass the wndproc from the imgui to my window system which lets the imgui handle the inputs, but my engine also needs the input !! Because object picking and movement will be handled by the engine not imgui !!

   enyin::Engine engine;
    engine.Start(hInstance, WndProc);
    HWND hwnd = enyin::WindowSystem::GetInstance().getWindowHandler();
    ImGui_Init(hwnd);
    while (true)
    {
        engine.GameLoop();
        ImGui_Update();
    }
    engine.Release();

@ocornut
Copy link
Owner

ocornut commented Oct 15, 2015

Just call both, maybe call the ImGui wndproc help at the beginning of yours.

Also you probably want ImGui::NewFrame to be called early in your frame (aka inside or before GameLoop) and ImGui::Render() to be called at the very end.

@anshul-soni
Copy link
Author

👍 So in each case inside the callback for imgui, I am in turn calling the callback of my engine.
And it works.
Thanks a lot 😄

@anshul-soni
Copy link
Author

ImGui::GetIO().Framerate doesnt work, its always -1

@ocornut
Copy link
Owner

ocornut commented Oct 16, 2015

You aren't setting DeltaTime every frame.

On 2015/10/16, at 0:36, Anshul Soni [email protected] wrote:

ImGui::GetIO().Framerate doesnt work, its always -1


Reply to this email directly or view it on GitHub.

@anshul-soni
Copy link
Author

Cool !! I didn't see that thing in newframe !!
Now looks like I got everything up and running.

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

No branches or pull requests

2 participants