mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-03 07:39:41 +00:00
Restored HW cursor rotation and resolution/fullscreen switching
This commit is contained in:
parent
495aeb5d3b
commit
918a1655bb
8 changed files with 29 additions and 33 deletions
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
#include <OgreControllerManager.h>
|
||||
#include <OgreMeshManager.h>
|
||||
|
||||
#include "SDL2/SDL.h"
|
||||
|
||||
#include <extern/shiny/Main/Factory.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())
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
2
extern/sdl4ogre/cursormanager.hpp
vendored
2
extern/sdl4ogre/cursormanager.hpp
vendored
|
@ -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;
|
||||
|
|
33
extern/sdl4ogre/sdlcursormanager.cpp
vendored
33
extern/sdl4ogre/sdlcursormanager.cpp
vendored
|
@ -3,6 +3,8 @@
|
|||
#include <OgreHardwarePixelBuffer.h>
|
||||
#include <OgreRoot.h>
|
||||
|
||||
#include <openengine/ogre/imagerotate.hpp>
|
||||
|
||||
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);
|
||||
if (mCursorMap.find(name) != mCursorMap.end())
|
||||
return;
|
||||
|
||||
std::string tempName = "_" + name + "_processing";
|
||||
std::string tempName = tex->getName() + "_rotated";
|
||||
|
||||
//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);
|
||||
// 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);
|
||||
|
||||
tempTexture->getBuffer()->blit(buffer);
|
||||
buffer->unlock();
|
||||
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);
|
||||
|
||||
|
|
4
extern/sdl4ogre/sdlcursormanager.hpp
vendored
4
extern/sdl4ogre/sdlcursormanager.hpp
vendored
|
@ -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);
|
||||
|
|
10
extern/sdl4ogre/sdlinputwrapper.cpp
vendored
10
extern/sdl4ogre/sdlinputwrapper.cpp
vendored
|
@ -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();
|
||||
|
|
|
@ -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)
|
||||
);
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue