1
General discussions / Re: Using SFML 2.1 for Window, Input, ... with Ogre3D Example(Working)
« on: December 01, 2013, 02:24:32 pm »
The example was quite useful to me, thanks.
Unfortunately the code you presented didn't work on Windows. The "currentGLContext" option seems to be ignored. This can be fixed by retrieving the context manually and set options accordingly. The code below works for me on Windows.
Also, I found out how to handle the resize events correctly.
Unfortunately the code you presented didn't work on Windows. The "currentGLContext" option seems to be ignored. This can be fixed by retrieving the context manually and set options accordingly. The code below works for me on Windows.
Ogre::NameValuePairList misc;
#ifdef _WIN32
unsigned long winHandle = reinterpret_cast<unsigned long>(window.getSystemHandle());
unsigned long winGlContext = reinterpret_cast<unsigned long>(wglGetCurrentContext());
misc["externalWindowHandle"] = StringConverter::toString(winHandle);
misc["externalGLContext"] = StringConverter::toString(winGlContext);
misc["externalGLControl"] = String("True");
#else
misc["currentGLContext"] = String("True");
#endif
Ogre::RenderWindow* ogreWindow = ogreRoot->createRenderWindow("Ogre Window", 800, 600, false, &misc);
#ifdef _WIN32
unsigned long winHandle = reinterpret_cast<unsigned long>(window.getSystemHandle());
unsigned long winGlContext = reinterpret_cast<unsigned long>(wglGetCurrentContext());
misc["externalWindowHandle"] = StringConverter::toString(winHandle);
misc["externalGLContext"] = StringConverter::toString(winGlContext);
misc["externalGLControl"] = String("True");
#else
misc["currentGLContext"] = String("True");
#endif
Ogre::RenderWindow* ogreWindow = ogreRoot->createRenderWindow("Ogre Window", 800, 600, false, &misc);
Also, I found out how to handle the resize events correctly.
if (event.type == sf::Event::Resized) {
ogreWindow->windowMovedOrResized();
ogreCamera->setAspectRatio(Ogre::Real(event.size.width) / Ogre::Real(event.size.height));
}
ogreWindow->windowMovedOrResized();
ogreCamera->setAspectRatio(Ogre::Real(event.size.width) / Ogre::Real(event.size.height));
}