Texture filtering... why didn't I think of that?

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 );
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);
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;
}
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...
Code: Select all
//! Initialize IMGui
Ogre::ImguiManager::createSingleton();
Ogre::ImguiManager::getSingleton().init(mSceneMgr);
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;
}
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;
}
Code: Select all
Ogre::TextureManager::getSingleton().load("MyTex.png","MyResourceGroup");
Code: Select all
Ogre::ResourceHandle texHandle = Ogre::TextureManager::getSingleton().getByName("MyTex.png")->getHandle();
ImGui::Image((ImTextureID)texHandle , ImVec2(32, 32));
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 ) );
Code: Select all
if(drawCmd->TextureId != 0 )
{
Ogre::ResourceHandle handle = (Ogre::ResourceHandle)drawCmd->TextureId;
Code: Select all
if(true )
{
Ogre::ResourceHandle handle = 185;
Code: Select all
TexturePtr t2 = TextureManager::getSingleton().getByName( "MyGrass.jpg", "My" );
ResourceHandle hdl = t2->getHandle();
textureHandle = hdl;
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
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);
}
}
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);
}
I see the post for the other version. I will try that.I'm using it with Ogre 2.0 and GL3+/D3D11 render systems