Page 2 of 3

Re: Ogre ImGui binding

Posted: Sun Jun 18, 2017 11:48 pm
by only_a_ptr
[SOLVED] - It's working perfectly under both OpenGL and DirectX9 for me.

Texture filtering... why didn't I think of that? :D Thanks!

Re: Ogre ImGui binding

Posted: Mon Jul 10, 2017 10:21 am
by only_a_ptr
BUMP!

@Crashy Any reason why you set required GLSL version to "150"? This appears to be causing issues for users with OGRE 1.9 and linux: https://github.com/RigsOfRods/rigs-of-r ... -310236651

I'm under impression a much lower version requirement would do: https://github.com/RigsOfRods/rigs-of-r ... -310245578 I'm going to research further, but I'd still like to ask.

Re: Ogre ImGui binding

Posted: Mon Jul 10, 2017 10:29 am
by Crashy
No, if it's working on lower version, you can change it. The shader is really simple, it shouldn't be a problem.

Re: Ogre ImGui binding

Posted: Mon Aug 21, 2017 3:27 pm
by Garibalde
Hi

I am trying to integrate imgui into my basic Ogre application. I don't have OIS as I am using SDL.
I tried ChaosCreate 2.1 ogre integration however this version Ogre 1.10.8 doe snot seem to have
OgreFastArray.h so I cant compile (I guess its a 2.1 upgrade).

If there a way to integrate it into Ogre 1.10.8. Seem some have it working in 1.9 is that with OIS? or SDL?

Thanks

Re: Ogre ImGui binding

Posted: Mon Aug 21, 2017 3:40 pm
by Crashy
Hi, you'll need to use my version when using Ogre 1.x, however, some changes are required to use SDL instead of OIS. It should be easy though.
Input related functions are

Code: Select all

 virtual bool mouseMoved( const OIS::MouseEvent &arg );
		virtual bool mousePressed( const OIS::MouseEvent &arg, OIS::MouseButtonID id );
		virtual bool mouseReleased( const OIS::MouseEvent &arg, OIS::MouseButtonID id );
        //Inherhited from OIS::KeyListener
		virtual bool keyPressed( const OIS::KeyEvent &arg );
		virtual bool keyReleased( const OIS::KeyEvent &arg );
Just change them to take SDL input events instead of OIS.

Re: Ogre ImGui binding

Posted: Tue Aug 22, 2017 2:58 am
by Garibalde
Ok I have tried to make the change from OIS to SDL as i am using Ogre 1.10.8

However i have some strange issues. I am implementing the default GUIs in the Demo in the Ogre application.
I see the menus but interaction with it is messed up. I cant pickup the windows and move them and i can click
on any of the buttons. I was able to do this in the demo application in IMGUI.
Ogrewindow.png
I have made changes to the virtual functions to pass in SDL events.

Code: Select all

		
                //Inherhited from OIS::MouseListener
		virtual bool mouseMoved(const OgreBites::MouseMotionEvent &arg);
		virtual bool mouseWheelRolled(const OgreBites::MouseWheelEvent& arg);
		virtual bool mousePressed(const OgreBites::MouseButtonEvent &arg);
		virtual bool mouseReleased(const OgreBites::MouseButtonEvent &arg);
		//Inherhited from OIS::KeyListener
		virtual bool keyPressed(const OgreBites::KeyboardEvent& evt);
		virtual bool keyReleased(const OgreBites::KeyboardEvent& evt);
I have changes the code the in the function to reflect this in ImguiManager.cpp:

Code: Select all

 //Inherhited from OIS::MouseListener
bool ImguiManager::mouseMoved(const OgreBites::MouseMotionEvent &arg)
{

    ImGuiIO& io = ImGui::GetIO();

    io.MousePos.x = arg.x;
    io.MousePos.y = arg.y;

    //io.MouseWheel = Ogre::Math::Sign(arg.state.Z.rel);

    return true;
}

bool ImguiManager::mouseWheelRolled(const OgreBites::MouseWheelEvent& arg)
{
	ImGuiIO& io = ImGui::GetIO();

	io.MouseWheel = Ogre::Math::Sign(arg.y);

	return true;
}

bool ImguiManager::mousePressed(const OgreBites::MouseButtonEvent &arg)
{
    ImGuiIO& io = ImGui::GetIO();
    if(arg.button<5)
    {
        io.MouseDown[arg.button] = true;
    }
    return true;
}
bool ImguiManager::mouseReleased(const OgreBites::MouseButtonEvent &arg)
{
    ImGuiIO& io = ImGui::GetIO();
    if(arg.button<5)
    {
        io.MouseDown[arg.button] = false;
    }
    return true;
}
//Inherhited from OIS::KeyListener
bool ImguiManager::keyPressed(const OgreBites::KeyboardEvent& evt)
{
    ImGuiIO& io = ImGui::GetIO();
    io.KeysDown[evt.keysym.sym] = true;
    
    //VM++ if(evt.text>0)
    //VM++ {
    //VM++     io.AddInputCharacter((unsigned short)arg.text);
    //VM++ }

    return true;
}
bool ImguiManager::keyReleased(const OgreBites::KeyboardEvent& evt)
{
    ImGuiIO& io = ImGui::GetIO();
    io.KeysDown[evt.keysym.sym] = false;
    return true;
}
I then called these functions from my OGRE class which handles inputs

Code: Select all

bool SurSimMain::mouseMoved(const OgreBites::MouseMotionEvent &arg)
{
	//! Update SDL with the mouse moved
	Ogre::ImguiManager::getSingleton().mouseMoved(arg);
}

bool SurSimMain::mouseWheelRolled(const OgreBites::MouseWheelEvent& evt)
{
	//! Update SDL with the mouse Wheel rolled.
	Ogre::ImguiManager::getSingleton().mouseWheelRolled(evt);
}

bool SurSimMain::mousePressed(const OgreBites::MouseButtonEvent &arg)
{
	//! Update SDL with the mouse pressed.
	Ogre::ImguiManager::getSingleton().mousePressed(arg);
}

etc...
In the OGRE Setup() I create an instance and initialised it.

Code: Select all

	//! Initialize IMGui
	Ogre::ImguiManager::createSingleton();
	Ogre::ImguiManager::getSingleton().init(mSceneMgr);
Finally in the frameRenderingQueued() I create newframe() on each pass.
and call my GUI code (Copy of the example code).

Code: Select all


void SurSimMain::LoadGUIInterfaces()
{
	{
		static float f = 0.0f;
		ImGui::Text("Hello, world!");
		ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
		ImGui::ColorEdit3("clear color", (float*)&clear_color);
		if (ImGui::Button("Test Window")) show_test_window ^= 1;
		if (ImGui::Button("Another Window")) show_another_window ^= 1;
		ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
	}

	// 2. Show another simple window, this time using an explicit Begin/End pair
	if (show_another_window)
	{
		ImGui::SetNextWindowSize(ImVec2(200, 100), ImGuiCond_FirstUseEver);
		ImGui::Begin("Another Window", &show_another_window);
		ImGui::Text("Hello");
		ImGui::End();
	}

	// 3. Show the ImGui test window. Most of the sample code is in ImGui::ShowTestWindow()
	if (show_test_window)
	{
		ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiCond_FirstUseEver);
		ImGui::ShowTestWindow(&show_test_window);
	}
}

bool SurSimMain::frameRenderingQueued(const Ogre::FrameEvent& evt)
{
	Ogre::ImguiManager::getSingleton().newFrame(evt.timeSinceLastFrame, Ogre::Rect(0,0, getRenderWindow()->getWidth(), getRenderWindow()->getHeight()));

	LoadGUIInterfaces();

	for (std::set<InputListener*>::iterator it = mInputListeners.begin();
		it != mInputListeners.end(); ++it) {
		(*it)->frameRendered(evt);
	}

	return true;
}
My interaction with the gui pages are nothing like that of the demo. It seems my inputs are not registering or are random.
I am unable to move the windows around or click on any of the menu buttons. A few highlight as i pass over them.

What am i missing?

Thanks

Re: Ogre ImGui binding

Posted: Tue Aug 22, 2017 8:57 pm
by Garibalde
I resolved the issue:

Seems SDL mouse buttons start from 1-5 and in Imgui assumes 0-4

So I changed the following in ImguiManager.cpp

Code: Select all

bool ImguiManager::mousePressed(const OgreBites::MouseButtonEvent &arg)
{
    ImGuiIO& io = ImGui::GetIO();
    if(arg.button<=5)
    {
        io.MouseDown[arg.button-1] = true;
    }
    return true;
}

bool ImguiManager::mouseReleased(const OgreBites::MouseButtonEvent &arg)
{
    ImGuiIO& io = ImGui::GetIO();
    if(arg.button<=5)
    {
        io.MouseDown[arg.button-1] = false;
    }
    return true;
}

Re: Ogre ImGui binding

Posted: Tue Sep 19, 2017 10:42 am
by only_a_ptr
There's one last nuissance about this GUI integration: it doesn't do window content clipping (or 'scissoring', I'm not sure of the proper term). All elements which don't completely fit into a scrollable region "pop out", as seen on the following screenshots:
imgui-OGRE-clipping-issues.png
User 'ChaosCreator' mentioned that before: http://www.ogre3d.org/forums/viewtopic. ... 59#p531059 - it's on the bottom of his post. I looked into his code shortly - seems easy enough to get right: https://bitbucket.org/ChaosCreator/imgu ... er.cpp-175

[UPDATE]: Done. Code available in my testbed repo: https://github.com/only-a-ptr/ogre-imgu ... /ror-style

Re: Ogre ImGui binding

Posted: Tue Oct 31, 2017 6:47 pm
by Garibalde
I posted this in a different thread. But I think this maybe better for ImGUi issues.

i am using ImGui with Ogre 1.10.8

I have split my viewport into quads (4 viewport in a single screen) so I can render different camera views in each quad.
However my ImGui windows are all locked to the first viewport and shrunk (Scaled). Mouse control is still full window (Position).

I would like the gui to overlay over all the viewports (Complete window). How can i do this with ImGUI?

In CEUGUI I think we created a "Sheet" and assigned the root rendernode and attached CEGUI dui elements to this "Sheet"
I am guessing I need to render a overlay over the viewports. How do i achieve this?

Re: Ogre ImGui binding

Posted: Thu Feb 22, 2018 7:17 pm
by paroj
ported to Ogre 1.10/ SDL2 style input and added build and example:
https://github.com/OGRECave/ogre-imgui

Re: Ogre ImGui binding

Posted: Thu Feb 22, 2018 8:04 pm
by Crashy
Hi,
Nice, I think I'll put the current code in a branch named 1.9x/OIS and merge your pull request in the default afterwards.

On my side I added a quick way to use textures, using the Ogre::Texture handle as ImGui texture Id. It could be more optimal, but at least, it works.

Usage:
1-be sure your texture is loaded (as it may not be used by anything else than your Imgui widget)

Code: Select all

 Ogre::TextureManager::getSingleton().load("MyTex.png","MyResourceGroup");
2-Retrieve the handle and use it as a ImTextureID

Code: Select all

Ogre::ResourceHandle texHandle = Ogre::TextureManager::getSingleton().getByName("MyTex.png")->getHandle();
ImGui::Image((ImTextureID)texHandle , ImVec2(32, 32));

Re: Ogre ImGui binding

Posted: Sun Aug 05, 2018 8:41 am
by z80
Hello,

I'm trying using images with your IMGUI binding. I use the latest (commit sha256: e953853814fb83754b50eed8ee2dedc3e5d83f30) of https://github.com/OGRECave/ogre-imgui binding. My Ogre3d version is 1.11 build on Ubuntu linux machine (if it matters).
In order to see an image I try doing similar thing to the example above.

Code: Select all

        Ogre::TextureManager::getSingleton().load("MyGrass.jpg","My");
        TexturePtr t = TextureManager::getSingleton().getByName( "MyGrass.jpg", "My" );
        ResourceHandle hdl = t->getHandle();
        int w = t->getWidth();
        int h = t->getHeight();
        ImGui::Image( (ImTextureID)hdl, ImVec2( w, h ) );
        ImGui::ImageButton( (ImTextureID)hdl, ImVec2( w, h ) );
Image size does correspond to the right one. However, the image itself is always the "default" font image (with letters and numbers, see the image attached to this post).
On the other hand, if I change lines of code in ImguiManager.cpp responsible for texture from

Code: Select all

            if(drawCmd->TextureId != 0 )
            {
                Ogre::ResourceHandle handle = (Ogre::ResourceHandle)drawCmd->TextureId;
to

Code: Select all

            if(true )
            {
                Ogre::ResourceHandle handle = 185;
I do see the result. Of course, in this case all textures are replaced with the one I hard-code with handle 185. But so far this is the only way to see anything other that the font texture due to some reason.

Would one, please, help me out with this issue I met? I'd appreciate any help! Thank you!
Image

Re: Ogre ImGui binding

Posted: Mon Aug 06, 2018 6:03 am
by Crashy
MMhhh, I don't see why this is not working.

What happens if you only call Ogre::TextureManager::getSingleton().load("MyGrass.jpg","My"); once at the beginning of your program, and not every frame ?

Re: Ogre ImGui binding

Posted: Tue Aug 07, 2018 6:16 am
by z80
Hello,

It seems it doesn't matter. I moved texture loading and getting it's handle to setup() method. But I still see the same font texture only in all places (see details below).
Can it be Ogre3d version related thing? May I know what version you used in the example you've provided three messages above?

Thank you!


In setup():

Code: Select all

        TexturePtr t2 = TextureManager::getSingleton().getByName( "MyGrass.jpg", "My" );
        ResourceHandle hdl = t2->getHandle();
        textureHandle = hdl;
In window drawing routine:

Code: Select all

        ImGui::Begin( "Texture view" ); // begin window
        ImGui::TextWrapped( "Here I expect to see my texture, but got these :) However, texture size is orrect. But the content is always the default \'font\' one." );
        int w = 128;
        int h = 128;
        ImGui::Image( (ImTextureID)textureHandle, ImVec2( w, h ) );
        ImGui::ImageButton( (ImTextureID)textureHandle, ImVec2( w, h ) );

        ImGui::End(); // end window

As I see this code in ImguiManager.cpp seems to have no effect regardless of texture handle. If handle is valid, "mTexUnit->setTexture(tex);" is called. And if I place some random number instead of a valid handle "mTexUnit->setTexture(tex);" is not called. But result is always the same font texture even in the case of intentionally placed invalid texture handle.

Code: Select all

            if(drawCmd->TextureId != 0 )
            {
                Ogre::ResourceHandle handle = (Ogre::ResourceHandle)drawCmd->TextureId;
                Ogre::TexturePtr tex = Ogre::static_pointer_cast<Ogre::Texture>(
                    Ogre::TextureManager::getSingleton().getByHandle(handle));
                if (tex)
                {
                    mTexUnit->setTexture(tex);
                    mTexUnit->setTextureFiltering(Ogre::TFO_TRILINEAR);
                }
            }

Re: Ogre ImGui binding

Posted: Tue Aug 07, 2018 6:48 am
by Crashy
I'm using Ogre 2.0.
So the setTexture is called but it doesn't change anything ?
Which RenderSystem are you using ?
You might need to check two thing
-Is the changed texture unit the one used in mPass (it should)
-When RenderSystem::_setTextureUnitSettings is called (in SceneManager::_setPass, called by _injectRenderWithPass), is it the right texture ?

Re: Ogre ImGui binding

Posted: Wed Aug 08, 2018 2:46 am
by z80
Hello,

Thank you so much for your support! Your two hints guided me to the following.

Due to some reason Pass is not the same as the one used to retrieve TextureUnitState in createMaterial() method. Due to that changes don't take effect. The following two lines before choosing a texture in ImguiManager.cpp solve the problem:

Code: Select all

            Pass * mPass = mRenderable.mMaterial->getBestTechnique()->getPass(0);
            TextureUnitState * st = mPass->getTextureUnitState( 0 );
            if(drawCmd->TextureId != 0 )
            {
                Ogre::ResourceHandle handle = (Ogre::ResourceHandle)drawCmd->TextureId;
                Ogre::TexturePtr tex = Ogre::static_pointer_cast<Ogre::Texture>(
                    Ogre::TextureManager::getSingleton().getByHandle(handle));
                if (tex)
                {
                    st->setTexture(tex);
                    st->setTextureFiltering(Ogre::TFO_TRILINEAR);
                }
            }
            else
            {
                st->setTexture(mFontTex);
                st->setTextureFiltering(Ogre::TFO_NONE);
            }
Thank you again!

Re: Ogre ImGui binding

Posted: Wed Aug 08, 2018 2:51 am
by z80
See the screenshot attached.
Image

Re: Ogre ImGui binding

Posted: Wed Aug 08, 2018 6:41 am
by Crashy
Thanks, I think I understand: you're using RTSS, aren't you ?
Anyway, here is the patch commit.

(didn't compiled nor tested it as I'm using another branch, I know it's really bad, but it should be ok)

Re: Ogre ImGui binding

Posted: Thu Aug 09, 2018 4:55 am
by z80
Hello,
Yes, I did attach RTSS to scene manager. I didn't know that I shouldn't. It must be I'm missing something.
Thank you so much! So far it looks like it works as expected.

Re: Ogre ImGui binding

Posted: Thu Aug 09, 2018 6:01 am
by Crashy
Oh no you can use it, it's jut that I never tested this feature with RTSS enabled ;)

Re: Ogre ImGui binding

Posted: Sun Sep 02, 2018 10:10 am
by Slicky
I am playing around with Ogre 2.1 and thought I'd try this.

I have a problem in that the ImGuiManager.h references OgreBites. Isn't that a 1.11 set of classes to make it easier to start using 1.11? I created the EmptyProject as suggested when starting to use Ogre 2.1.

I am looking at the default branch https://bitbucket.org/LMCrashy/ogreimgui/src/default/. The other fork seems to be for Ogre 1.9 so I should be looking at the right version of code.

Help

Re: Ogre ImGui binding

Posted: Sun Sep 02, 2018 10:13 am
by Crashy
No, this repository is Ogre 1.x only :)


The 2.1 fork is hosted somewhere else, I think it's on a github repository. There should be a link somewhere on this topic.

Edit: here it is https://bitbucket.org/ChaosCreator/imgu ... rc/master/

Re: Ogre ImGui binding

Posted: Sun Sep 02, 2018 10:19 am
by Slicky
Thanks for the reply. I thought maybe the versions where both finalised and hosted on yours since you have branches. Also, in the first post you say:
I'm using it with Ogre 2.0 and GL3+/D3D11 render systems
I see the post for the other version. I will try that.

Thanks

Re: Ogre ImGui binding

Posted: Sun Sep 02, 2018 10:21 am
by Crashy
Yes, but 2.0 is really different from the 2.1+, and in some cases closer to the 1.x ;)

Re: Ogre ImGui binding

Posted: Sun Sep 02, 2018 10:24 am
by Slicky
Oh didn't know that. I have been trying to update things from 1.09 to 1.11 and had problems so am trying 2.1 and apparently having some problems too. :D I will skip 2.0.