Restored HW cursor rotation and resolution/fullscreen switching

actorid
scrawl 12 years ago
parent 495aeb5d3b
commit 918a1655bb

@ -77,6 +77,7 @@ set(OENGINE_OGRE
${LIBDIR}/openengine/ogre/fader.cpp ${LIBDIR}/openengine/ogre/fader.cpp
${LIBDIR}/openengine/ogre/particles.cpp ${LIBDIR}/openengine/ogre/particles.cpp
${LIBDIR}/openengine/ogre/selectionbuffer.cpp ${LIBDIR}/openengine/ogre/selectionbuffer.cpp
${LIBDIR}/openengine/ogre/imagerotate.cpp
) )
set(OENGINE_GUI set(OENGINE_GUI
${LIBDIR}/openengine/gui/manager.cpp ${LIBDIR}/openengine/gui/manager.cpp

@ -968,8 +968,9 @@ namespace MWGui
Uint8 size_y = imgSetPtr->getSize().height; Uint8 size_y = imgSetPtr->getSize().height;
Uint8 hotspot_x = imgSetPtr->getHotSpot().left; Uint8 hotspot_x = imgSetPtr->getHotSpot().left;
Uint8 hotspot_y = imgSetPtr->getHotSpot().top; 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);
} }
} }
} }

@ -16,6 +16,8 @@
#include <OgreControllerManager.h> #include <OgreControllerManager.h>
#include <OgreMeshManager.h> #include <OgreMeshManager.h>
#include "SDL2/SDL.h"
#include <extern/shiny/Main/Factory.hpp> #include <extern/shiny/Main/Factory.hpp>
#include <extern/shiny/Platforms/Ogre/OgrePlatform.hpp> #include <extern/shiny/Platforms/Ogre/OgrePlatform.hpp>
@ -796,8 +798,10 @@ void RenderingManager::processChangedSettings(const Settings::CategorySettingVec
if (x != mRendering.getWindow()->getWidth() || y != mRendering.getWindow()->getHeight()) if (x != mRendering.getWindow()->getWidth() || y != mRendering.getWindow()->getHeight())
{ {
SDL_SetWindowSize(mRendering.getSDLWindow(), x, y);
mRendering.getWindow()->resize(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); mRendering.getWindow()->setFullscreen(Settings::Manager::getBool("fullscreen", "Video"), x, y);
} }

@ -22,7 +22,7 @@ public:
virtual bool cursorChanged(const std::string &name) = 0; virtual bool cursorChanged(const std::string &name) = 0;
/// \brief Follow up a cursorChanged() call with enough info to create an cursor. /// \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 /// \brief Tell the manager when the cursor visibility changed
virtual void cursorVisibilityChange(bool visible) = 0; virtual void cursorVisibilityChange(bool visible) = 0;

@ -3,6 +3,8 @@
#include <OgreHardwarePixelBuffer.h> #include <OgreHardwarePixelBuffer.h>
#include <OgreRoot.h> #include <OgreRoot.h>
#include <openengine/ogre/imagerotate.hpp>
namespace SFO namespace SFO
{ {
@ -96,37 +98,28 @@ namespace SFO
_setCursorVisible(visible); _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 /// \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 if (mCursorMap.find(name) != mCursorMap.end())
Ogre::HardwarePixelBufferSharedPtr buffer = tex.get()->getBuffer(); return;
buffer.get()->lock(Ogre::HardwarePixelBuffer::HBL_READ_ONLY);
std::string tempName = tex->getName() + "_rotated";
std::string tempName = "_" + name + "_processing";
// we use a render target to uncompress the DDS texture
//we need to copy this to a temporary texture first because the cursors might be in DDS format, // just blitting doesn't seem to work on D3D9
//and Ogre doesn't have an interface to read DDS OEngine::Render::ImageRotate::rotate(tex->getName(), tempName, -rotDegrees);
Ogre::TexturePtr tempTexture = Ogre::TextureManager::getSingleton().createManual(
tempName, Ogre::TexturePtr resultTexture = Ogre::TextureManager::getSingleton().getByName(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();
// now blit to memory // now blit to memory
Ogre::Image destImage; Ogre::Image destImage;
tempTexture->convertToImage(destImage); resultTexture->convertToImage(destImage);
SDL_Surface* surf = SDL_CreateRGBSurface(0,size_x,size_y,32,0xFF000000,0x00FF0000,0x0000FF00,0x000000FF); SDL_Surface* surf = SDL_CreateRGBSurface(0,size_x,size_y,32,0xFF000000,0x00FF0000,0x0000FF00,0x000000FF);

@ -18,11 +18,11 @@ namespace SFO
virtual void setEnabled(bool enabled); virtual void setEnabled(bool enabled);
virtual bool cursorChanged(const std::string &name); 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); virtual void cursorVisibilityChange(bool visible);
private: 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 _putPixel(SDL_Surface *surface, int x, int y, Uint32 pixel);
void _setGUICursor(const std::string& name); void _setGUICursor(const std::string& name);

@ -167,14 +167,8 @@ namespace SFO
//eep, wrap the pointer manually if the input driver doesn't support //eep, wrap the pointer manually if the input driver doesn't support
//relative positioning natively //relative positioning natively
int success = SDL_SetRelativeMouseMode(relative ? SDL_TRUE : SDL_FALSE); int success = SDL_SetRelativeMouseMode(relative ? SDL_TRUE : SDL_FALSE);
if(relative && success != 0)
if(relative) mWrapPointer = true;
{
if(success != 0)
{
mWrapPointer = true;
}
}
//now remove all mouse events using the old setting from the queue //now remove all mouse events using the old setting from the queue
SDL_PumpEvents(); SDL_PumpEvents();

@ -54,6 +54,9 @@ void OgreRenderer::cleanup()
delete mRoot; delete mRoot;
mRoot = NULL; mRoot = NULL;
// If we don't do this, the desktop resolution is not restored on exit
SDL_SetWindowFullscreen(mSDLWindow, 0);
SDL_DestroyWindow(mSDLWindow); SDL_DestroyWindow(mSDLWindow);
mSDLWindow = NULL; mSDLWindow = NULL;
@ -283,7 +286,7 @@ void OgreRenderer::createWindow(const std::string &title, const WindowSettings&
settings.window_x, // width, in pixels settings.window_x, // width, in pixels
settings.window_y, // height, in pixels settings.window_y, // height, in pixels
SDL_WINDOW_SHOWN|SDL_WINDOW_RESIZABLE SDL_WINDOW_SHOWN|SDL_WINDOW_RESIZABLE
| (settings.fullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0) | (settings.fullscreen ? SDL_WINDOW_FULLSCREEN : 0)
); );

Loading…
Cancel
Save