From 298b3ed2efbf52ba2887aa8acacf4677b3cf0532 Mon Sep 17 00:00:00 2001 From: scrawl Date: Wed, 13 May 2015 15:08:47 +0200 Subject: [PATCH] Create the GraphicsWindowSDL2 directly --- apps/openmw/engine.cpp | 8 +- components/sdlutil/sdlgraphicswindow.cpp | 106 ----------------------- components/sdlutil/sdlgraphicswindow.hpp | 2 - 3 files changed, 3 insertions(+), 113 deletions(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 7f98f6ad7f..98e1c5a282 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -352,8 +352,6 @@ void OMW::Engine::createWindow(Settings::Manager& settings) setWindowIcon(); - SDLUtil::setupWindowingSystemInterface(); - osg::ref_ptr traits = new osg::GraphicsContext::Traits; SDL_GetWindowPosition(mWindow, &traits->x, &traits->y); SDL_GetWindowSize(mWindow, &traits->width, &traits->height); @@ -371,11 +369,11 @@ void OMW::Engine::createWindow(Settings::Manager& settings) traits->doubleBuffer = true; traits->inheritedWindowData = new SDLUtil::GraphicsWindowSDL2::WindowData(mWindow); - osg::ref_ptr gc = osg::GraphicsContext::createGraphicsContext(traits.get()); - if(!gc.valid()) throw std::runtime_error("Failed to create GraphicsContext"); + osg::ref_ptr graphicsWindow = new SDLUtil::GraphicsWindowSDL2(traits); + if(!graphicsWindow->valid()) throw std::runtime_error("Failed to create GraphicsContext"); osg::ref_ptr camera = mViewer->getCamera(); - camera->setGraphicsContext(gc.get()); + camera->setGraphicsContext(graphicsWindow); camera->setViewport(0, 0, width, height); mViewer->realize(); diff --git a/components/sdlutil/sdlgraphicswindow.cpp b/components/sdlutil/sdlgraphicswindow.cpp index 1424337ab6..6c7bac12eb 100644 --- a/components/sdlutil/sdlgraphicswindow.cpp +++ b/components/sdlutil/sdlgraphicswindow.cpp @@ -163,110 +163,4 @@ void GraphicsWindowSDL2::raiseWindow() SDL_RaiseWindow(mWindow); } - -class SDL2WindowingSystemInterface : public osg::GraphicsContext::WindowingSystemInterface -{ -public: - SDL2WindowingSystemInterface() - { - OSG_INFO<< "SDL2WindowingSystemInterface()" <setNumFramesToRetainObjects(0); - osg::Referenced::getDeleteHandler()->flushAll(); - } - - //OSG_NOTICE<< "~SDL2WindowingSystemInterface()" <pbuffer) - return NULL; - - osg::ref_ptr window = new GraphicsWindowSDL2(traits); - if(window->valid()) return window.release(); - return NULL; - } -}; - -void setupWindowingSystemInterface() -{ - osg::GraphicsContext::setWindowingSystemInterface(new SDL2WindowingSystemInterface); -} - } diff --git a/components/sdlutil/sdlgraphicswindow.hpp b/components/sdlutil/sdlgraphicswindow.hpp index cfe40d98e9..45cf470028 100644 --- a/components/sdlutil/sdlgraphicswindow.hpp +++ b/components/sdlutil/sdlgraphicswindow.hpp @@ -101,8 +101,6 @@ public: }; }; -void setupWindowingSystemInterface(); - } #endif /* OSGGRAPHICSWINDOW_H */