#include <QApplication>
#include <QWidget>
#include <Ogre.h>
#include <QPushButton>
int main(int argc, char *argv[])
{
Ogre::Root* ogre_root;
Ogre::RenderWindow* ogre_render_window;
Ogre::SceneManager* ogre_scene_manager;
Ogre::Camera* ogre_haupt_kamera;
Ogre::Viewport* ogre_viewport;
widget->setAttribute(Qt::WA_NoSystemBackground);
widget->setAttribute(Qt::WA_PaintOnScreen);
widget->setWindowFlags( widget->windowFlags() | Qt::MSWindowsOwnDC );
widget->setFocusPolicy(Qt::StrongFocus);
ogre_root = new Ogre::Root();
ogre_root->addResourceLocation( "resources", "FileSystem", "General" );
Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
ogre_root->loadPlugin( "ogre_plugins/RenderSystem_GL" );
ogre_root->loadPlugin( "ogre_plugins/Plugin_OctreeSceneManager" );
Ogre::RenderSystem* rs = ogre_root->getRenderSystemByName("OpenGL Rendering Subsystem");
if(!(rs->getName() == "OpenGL Rendering Subsystem"))
{
return false; //No RenderSystem found
}
// configure our RenderSystem
rs->setConfigOption("Full Screen", "No");
rs->setConfigOption("VSync", "No");
rs->setConfigOption("Video Mode", "800 x 600 @ 32-bit");
ogre_root->setRenderSystem(rs);
ogre_render_window = ogre_root->initialise( false, "my 3D");
Ogre::NameValuePairList params;
params["useNVPerfHUD"] = "true";
//The external windows handle parameters are platform-specific
Ogre::String externalWindowHandleParams;
#if defined(Q_WS_WIN)
//positive integer for W32 (HWND handle) - According to Ogre Docs
externalWindowHandleParams = Ogre::StringConverter::toString((unsigned long)(widget->winId()));
#endif
#if defined(Q_WS_X11)
//poslong:posint:poslong:poslong (display*:screen:windowHandle:XVisualInfo*) for GLX - According to Ogre Docs
externalWindowHandleParams = Ogre::StringConverter::toString((unsigned long)(info.display()));
externalWindowHandleParams += ":";
externalWindowHandleParams += Ogre::StringConverter::toString((unsigned int)(info.screen()));
externalWindowHandleParams += ":";
externalWindowHandleParams += Ogre::StringConverter::toString((unsigned long)(widget->winId()));
#endif
//Add the external window handle parameters to the existing params set.
#if defined(Q_WS_WIN)
params["externalWindowHandle"] = externalWindowHandleParams;
params["parentWindowHandle"] = externalWindowHandleParams;
#endif
#if defined(Q_WS_X11)
params["parentWindowHandle"] = externalWindowHandleParams;
#endif
ogre_render_window = ogre_root->createRenderWindow("OgreWindow", 600, 400, false, ¶ms);
ogre_render_window->setActive(true);
ogre_render_window->setVisible(true);
ogre_scene_manager = ogre_root->createSceneManager( "OctreeSceneManager" );
ogre_haupt_kamera = ogre_scene_manager->createCamera( "haupt_kamera" );
ogre_haupt_kamera->setPosition( Ogre::Vector3(100,100,100) );
ogre_haupt_kamera->lookAt(Ogre::Vector3(0, 0, 0));
ogre_haupt_kamera->setNearClipDistance(0.1);
if (ogre_root->getRenderSystem()->getCapabilities()->hasCapability(Ogre::RSC_INFINITE_FAR_PLANE))
{
ogre_haupt_kamera->setFarClipDistance(0); // wird eingeschalten wenn die grafikkarte das unterstützt
}
ogre_viewport = ogre_render_window->addViewport( ogre_haupt_kamera );
ogre_viewport->setBackgroundColour( Ogre::ColourValue( 0.9, 0.9, 0.9 ) );
ogre_haupt_kamera->setAspectRatio( Ogre::Real( ogre_viewport->getActualWidth() ) /
Ogre::Real( ogre_viewport->getActualHeight() ) );
ogre_scene_manager->setAmbientLight( Ogre::ColourValue(0.9f, 0.9f, 0.9f) );
ogre_scene_manager->setShadowTechnique( Ogre::SHADOWTYPE_STENCIL_ADDITIVE );
ogre_scene_manager->setShadowColour(Ogre::ColourValue(0.5, 0.5, 0.5));
// ogre_scene_manager->setSkyBox( true, "Himmel", 5000 );
widget->show();
widget->resize(400,300);
b->setParent( widget );
b->move( 10,10 );
b->show();
return app.exec();
}
#include <QApplication>
#include <QWidget>
#include <Ogre.h>
#include <QPushButton>
int main(int argc, char *argv[])
{
Ogre::Root* ogre_root;
Ogre::RenderWindow* ogre_render_window;
Ogre::SceneManager* ogre_scene_manager;
Ogre::Camera* ogre_haupt_kamera;
Ogre::Viewport* ogre_viewport;
QApplication app(argc,argv);
QWidget* widget = new QWidget();
widget->setAttribute(Qt::WA_NoSystemBackground);
widget->setAttribute(Qt::WA_PaintOnScreen);
widget->setWindowFlags( widget->windowFlags() | Qt::MSWindowsOwnDC );
widget->setFocusPolicy(Qt::StrongFocus);
ogre_root = new Ogre::Root();
ogre_root->addResourceLocation( "resources", "FileSystem", "General" );
Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
ogre_root->loadPlugin( "ogre_plugins/RenderSystem_GL" );
ogre_root->loadPlugin( "ogre_plugins/Plugin_OctreeSceneManager" );
Ogre::RenderSystem* rs = ogre_root->getRenderSystemByName("OpenGL Rendering Subsystem");
if(!(rs->getName() == "OpenGL Rendering Subsystem"))
{
return false; //No RenderSystem found
}
// configure our RenderSystem
rs->setConfigOption("Full Screen", "No");
rs->setConfigOption("VSync", "No");
rs->setConfigOption("Video Mode", "800 x 600 @ 32-bit");
ogre_root->setRenderSystem(rs);
ogre_render_window = ogre_root->initialise( false, "my 3D");
Ogre::NameValuePairList params;
params["useNVPerfHUD"] = "true";
//The external windows handle parameters are platform-specific
Ogre::String externalWindowHandleParams;
#if defined(Q_WS_WIN)
//positive integer for W32 (HWND handle) - According to Ogre Docs
externalWindowHandleParams = Ogre::StringConverter::toString((unsigned long)(widget->winId()));
#endif
#if defined(Q_WS_X11)
//poslong:posint:poslong:poslong (display*:screen:windowHandle:XVisualInfo*) for GLX - According to Ogre Docs
QX11Info info = x11Info();
externalWindowHandleParams = Ogre::StringConverter::toString((unsigned long)(info.display()));
externalWindowHandleParams += ":";
externalWindowHandleParams += Ogre::StringConverter::toString((unsigned int)(info.screen()));
externalWindowHandleParams += ":";
externalWindowHandleParams += Ogre::StringConverter::toString((unsigned long)(widget->winId()));
#endif
//Add the external window handle parameters to the existing params set.
#if defined(Q_WS_WIN)
params["externalWindowHandle"] = externalWindowHandleParams;
params["parentWindowHandle"] = externalWindowHandleParams;
#endif
#if defined(Q_WS_X11)
params["parentWindowHandle"] = externalWindowHandleParams;
#endif
ogre_render_window = ogre_root->createRenderWindow("OgreWindow", 600, 400, false, ¶ms);
ogre_render_window->setActive(true);
ogre_render_window->setVisible(true);
ogre_scene_manager = ogre_root->createSceneManager( "OctreeSceneManager" );
ogre_haupt_kamera = ogre_scene_manager->createCamera( "haupt_kamera" );
ogre_haupt_kamera->setPosition( Ogre::Vector3(100,100,100) );
ogre_haupt_kamera->lookAt(Ogre::Vector3(0, 0, 0));
ogre_haupt_kamera->setNearClipDistance(0.1);
if (ogre_root->getRenderSystem()->getCapabilities()->hasCapability(Ogre::RSC_INFINITE_FAR_PLANE))
{
ogre_haupt_kamera->setFarClipDistance(0); // wird eingeschalten wenn die grafikkarte das unterstützt
}
ogre_viewport = ogre_render_window->addViewport( ogre_haupt_kamera );
ogre_viewport->setBackgroundColour( Ogre::ColourValue( 0.9, 0.9, 0.9 ) );
ogre_haupt_kamera->setAspectRatio( Ogre::Real( ogre_viewport->getActualWidth() ) /
Ogre::Real( ogre_viewport->getActualHeight() ) );
ogre_scene_manager->setAmbientLight( Ogre::ColourValue(0.9f, 0.9f, 0.9f) );
ogre_scene_manager->setShadowTechnique( Ogre::SHADOWTYPE_STENCIL_ADDITIVE );
ogre_scene_manager->setShadowColour(Ogre::ColourValue(0.5, 0.5, 0.5));
// ogre_scene_manager->setSkyBox( true, "Himmel", 5000 );
widget->show();
widget->resize(400,300);
QPushButton* b = new QPushButton( "hi" );
b->setParent( widget );
b->move( 10,10 );
b->show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
QPainter::begin: Paint device returned engine
== 0, type
: 1 QPainter::setRenderHint: Painter must be active to set rendering hints
QPainter::begin: Paint device returned engine == 0, type: 1
QPainter::setPen: Painter not active
QPainter::setBrush: Painter not active
QPainter::setRenderHint: Painter must be active to set rendering hints
QPainter::drawRects: Painter not active
QPainter::setBrush: Painter not active
QPainter::drawRects: Painter not active
To copy to clipboard, switch view to plain text mode
Bookmarks