diff --git a/CMakeLists.txt b/CMakeLists.txt index 1c2fbdb9b..3c115cdee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -77,6 +77,7 @@ set(OENGINE_OGRE ${LIBDIR}/openengine/ogre/fader.cpp ${LIBDIR}/openengine/ogre/particles.cpp ${LIBDIR}/openengine/ogre/selectionbuffer.cpp + ${LIBDIR}/openengine/ogre/imagerotate.cpp ) set(OENGINE_GUI ${LIBDIR}/openengine/gui/manager.cpp diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index 48561936d..099a59038 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -968,8 +968,9 @@ namespace MWGui Uint8 size_y = imgSetPtr->getSize().height; Uint8 hotspot_x = imgSetPtr->getHotSpot().left; Uint8 hotspot_y = imgSetPtr->getHotSpot().top; + int rotation = imgSetPtr->getRotation(); - mCursorManager->receiveCursorInfo(name, tex, size_x, size_y, hotspot_x, hotspot_y); + mCursorManager->receiveCursorInfo(name, rotation, tex, size_x, size_y, hotspot_x, hotspot_y); } } } diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index e327c3c89..df5293d73 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -16,6 +16,8 @@ #include #include +#include "SDL2/SDL.h" + #include #include @@ -796,8 +798,10 @@ void RenderingManager::processChangedSettings(const Settings::CategorySettingVec if (x != mRendering.getWindow()->getWidth() || y != mRendering.getWindow()->getHeight()) { + SDL_SetWindowSize(mRendering.getSDLWindow(), x, y); mRendering.getWindow()->resize(x, y); } + SDL_SetWindowFullscreen(mRendering.getSDLWindow(), Settings::Manager::getBool("fullscreen", "Video") ? SDL_WINDOW_FULLSCREEN : 0); mRendering.getWindow()->setFullscreen(Settings::Manager::getBool("fullscreen", "Video"), x, y); } diff --git a/extern/sdl4ogre/cursormanager.hpp b/extern/sdl4ogre/cursormanager.hpp index b98d69ce3..1f52eca73 100644 --- a/extern/sdl4ogre/cursormanager.hpp +++ b/extern/sdl4ogre/cursormanager.hpp @@ -22,7 +22,7 @@ public: virtual bool cursorChanged(const std::string &name) = 0; /// \brief Follow up a cursorChanged() call with enough info to create an cursor. - virtual void receiveCursorInfo(const std::string &name, Ogre::TexturePtr tex, Uint8 size_x, Uint8 size_y, Uint8 hotspot_x, Uint8 hotspot_y) = 0; + virtual void receiveCursorInfo(const std::string &name, int rotDegrees, Ogre::TexturePtr tex, Uint8 size_x, Uint8 size_y, Uint8 hotspot_x, Uint8 hotspot_y) = 0; /// \brief Tell the manager when the cursor visibility changed virtual void cursorVisibilityChange(bool visible) = 0; diff --git a/extern/sdl4ogre/sdlcursormanager.cpp b/extern/sdl4ogre/sdlcursormanager.cpp index 4e24696ea..d817ce9c4 100644 --- a/extern/sdl4ogre/sdlcursormanager.cpp +++ b/extern/sdl4ogre/sdlcursormanager.cpp @@ -3,6 +3,8 @@ #include #include +#include + namespace SFO { @@ -96,37 +98,28 @@ namespace SFO _setCursorVisible(visible); } - void SDLCursorManager::receiveCursorInfo(const std::string& name, Ogre::TexturePtr tex, Uint8 size_x, Uint8 size_y, Uint8 hotspot_x, Uint8 hotspot_y) + void SDLCursorManager::receiveCursorInfo(const std::string& name, int rotDegrees, Ogre::TexturePtr tex, Uint8 size_x, Uint8 size_y, Uint8 hotspot_x, Uint8 hotspot_y) { - _createCursorFromResource(name, tex, size_x, size_y, hotspot_x, hotspot_y); + _createCursorFromResource(name, rotDegrees, tex, size_x, size_y, hotspot_x, hotspot_y); } /// \brief creates an SDL cursor from an Ogre texture - void SDLCursorManager::_createCursorFromResource(const std::string& name, Ogre::TexturePtr tex, Uint8 size_x, Uint8 size_y, Uint8 hotspot_x, Uint8 hotspot_y) + void SDLCursorManager::_createCursorFromResource(const std::string& name, int rotDegrees, Ogre::TexturePtr tex, Uint8 size_x, Uint8 size_y, Uint8 hotspot_x, Uint8 hotspot_y) { - //get the surfaces set up - Ogre::HardwarePixelBufferSharedPtr buffer = tex.get()->getBuffer(); - buffer.get()->lock(Ogre::HardwarePixelBuffer::HBL_READ_ONLY); - - std::string tempName = "_" + name + "_processing"; - - //we need to copy this to a temporary texture first because the cursors might be in DDS format, - //and Ogre doesn't have an interface to read DDS - Ogre::TexturePtr tempTexture = Ogre::TextureManager::getSingleton().createManual( - tempName, - Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, - Ogre::TEX_TYPE_2D, - size_x, size_y, - 0, - Ogre::PF_FLOAT16_RGBA, - Ogre::TU_STATIC); - - tempTexture->getBuffer()->blit(buffer); - buffer->unlock(); + if (mCursorMap.find(name) != mCursorMap.end()) + return; + + std::string tempName = tex->getName() + "_rotated"; + + // we use a render target to uncompress the DDS texture + // just blitting doesn't seem to work on D3D9 + OEngine::Render::ImageRotate::rotate(tex->getName(), tempName, -rotDegrees); + + Ogre::TexturePtr resultTexture = Ogre::TextureManager::getSingleton().getByName(tempName); // now blit to memory Ogre::Image destImage; - tempTexture->convertToImage(destImage); + resultTexture->convertToImage(destImage); SDL_Surface* surf = SDL_CreateRGBSurface(0,size_x,size_y,32,0xFF000000,0x00FF0000,0x0000FF00,0x000000FF); diff --git a/extern/sdl4ogre/sdlcursormanager.hpp b/extern/sdl4ogre/sdlcursormanager.hpp index ad371f551..2cfb73a91 100644 --- a/extern/sdl4ogre/sdlcursormanager.hpp +++ b/extern/sdl4ogre/sdlcursormanager.hpp @@ -18,11 +18,11 @@ namespace SFO virtual void setEnabled(bool enabled); virtual bool cursorChanged(const std::string &name); - virtual void receiveCursorInfo(const std::string &name, Ogre::TexturePtr tex, Uint8 size_x, Uint8 size_y, Uint8 hotspot_x, Uint8 hotspot_y); + virtual void receiveCursorInfo(const std::string &name, int rotDegrees, Ogre::TexturePtr tex, Uint8 size_x, Uint8 size_y, Uint8 hotspot_x, Uint8 hotspot_y); virtual void cursorVisibilityChange(bool visible); private: - void _createCursorFromResource(const std::string &name, Ogre::TexturePtr tex, Uint8 size_x, Uint8 size_y, Uint8 hotspot_x, Uint8 hotspot_y); + void _createCursorFromResource(const std::string &name, int rotDegrees, Ogre::TexturePtr tex, Uint8 size_x, Uint8 size_y, Uint8 hotspot_x, Uint8 hotspot_y); void _putPixel(SDL_Surface *surface, int x, int y, Uint32 pixel); void _setGUICursor(const std::string& name); diff --git a/extern/sdl4ogre/sdlinputwrapper.cpp b/extern/sdl4ogre/sdlinputwrapper.cpp index 7977c743e..a500bc531 100644 --- a/extern/sdl4ogre/sdlinputwrapper.cpp +++ b/extern/sdl4ogre/sdlinputwrapper.cpp @@ -167,14 +167,8 @@ namespace SFO //eep, wrap the pointer manually if the input driver doesn't support //relative positioning natively int success = SDL_SetRelativeMouseMode(relative ? SDL_TRUE : SDL_FALSE); - - if(relative) - { - if(success != 0) - { - mWrapPointer = true; - } - } + if(relative && success != 0) + mWrapPointer = true; //now remove all mouse events using the old setting from the queue SDL_PumpEvents(); diff --git a/libs/openengine/ogre/renderer.cpp b/libs/openengine/ogre/renderer.cpp index 596d831d3..66472cda0 100644 --- a/libs/openengine/ogre/renderer.cpp +++ b/libs/openengine/ogre/renderer.cpp @@ -54,6 +54,9 @@ void OgreRenderer::cleanup() delete mRoot; mRoot = NULL; + // If we don't do this, the desktop resolution is not restored on exit + SDL_SetWindowFullscreen(mSDLWindow, 0); + SDL_DestroyWindow(mSDLWindow); mSDLWindow = NULL; @@ -283,7 +286,7 @@ void OgreRenderer::createWindow(const std::string &title, const WindowSettings& settings.window_x, // width, in pixels settings.window_y, // height, in pixels SDL_WINDOW_SHOWN|SDL_WINDOW_RESIZABLE - | (settings.fullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0) + | (settings.fullscreen ? SDL_WINDOW_FULLSCREEN : 0) );