forked from teamnwah/openmw-tes3coop
Use openmw.png for SDL_SetWindowIcon
This commit is contained in:
parent
705488ddfb
commit
403704b92a
6 changed files with 78 additions and 5 deletions
|
@ -421,6 +421,7 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings)
|
||||||
windowSettings.window_x = settings.getInt("resolution x", "Video");
|
windowSettings.window_x = settings.getInt("resolution x", "Video");
|
||||||
windowSettings.window_y = settings.getInt("resolution y", "Video");
|
windowSettings.window_y = settings.getInt("resolution y", "Video");
|
||||||
windowSettings.vsync = settings.getBool("vsync", "Video");
|
windowSettings.vsync = settings.getBool("vsync", "Video");
|
||||||
|
windowSettings.icon = "openmw.png";
|
||||||
std::string aa = settings.getString("antialiasing", "Video");
|
std::string aa = settings.getString("antialiasing", "Video");
|
||||||
windowSettings.fsaa = (aa.substr(0, 4) == "MSAA") ? aa.substr(5, aa.size()-5) : "0";
|
windowSettings.fsaa = (aa.substr(0, 4) == "MSAA") ? aa.substr(5, aa.size()-5) : "0";
|
||||||
|
|
||||||
|
|
|
@ -131,7 +131,7 @@ RenderingManager::RenderingManager(OEngine::Render::OgreRenderer& _rend, const b
|
||||||
Ogre::TextureManager::getSingleton().setMemoryBudget(126*1024*1024);
|
Ogre::TextureManager::getSingleton().setMemoryBudget(126*1024*1024);
|
||||||
Ogre::MeshManager::getSingleton().setMemoryBudget(64*1024*1024);
|
Ogre::MeshManager::getSingleton().setMemoryBudget(64*1024*1024);
|
||||||
|
|
||||||
ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
|
Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
|
||||||
|
|
||||||
// disable unsupported effects
|
// disable unsupported effects
|
||||||
if (!Settings::Manager::getBool("shaders", "Objects"))
|
if (!Settings::Manager::getBool("shaders", "Objects"))
|
||||||
|
@ -312,7 +312,7 @@ void RenderingManager::update (float duration, bool paused)
|
||||||
MWWorld::Ptr player = world->getPlayer().getPlayer();
|
MWWorld::Ptr player = world->getPlayer().getPlayer();
|
||||||
|
|
||||||
int blind = MWWorld::Class::get(player).getCreatureStats(player).getMagicEffects().get(MWMechanics::EffectKey(ESM::MagicEffect::Blind)).mMagnitude;
|
int blind = MWWorld::Class::get(player).getCreatureStats(player).getMagicEffects().get(MWMechanics::EffectKey(ESM::MagicEffect::Blind)).mMagnitude;
|
||||||
mRendering.getFader()->setFactor(1.f-(blind / 100.f));
|
mRendering.getFader()->setFactor(std::max(0.f, 1.f-(blind / 100.f)));
|
||||||
setAmbientMode();
|
setAmbientMode();
|
||||||
|
|
||||||
// player position
|
// player position
|
||||||
|
|
4
extern/sdl4ogre/sdlinputwrapper.cpp
vendored
4
extern/sdl4ogre/sdlinputwrapper.cpp
vendored
|
@ -205,8 +205,8 @@ namespace SFO
|
||||||
|
|
||||||
SDL_GetWindowSize(mSDLWindow, &width, &height);
|
SDL_GetWindowSize(mSDLWindow, &width, &height);
|
||||||
|
|
||||||
const int FUDGE_FACTOR_X = width / 8;
|
const int FUDGE_FACTOR_X = width;
|
||||||
const int FUDGE_FACTOR_Y = height / 8;
|
const int FUDGE_FACTOR_Y = height;
|
||||||
|
|
||||||
//warp the mouse if it's about to go outside the window
|
//warp the mouse if it's about to go outside the window
|
||||||
if(evt.x - FUDGE_FACTOR_X < 0 || evt.x + FUDGE_FACTOR_X > width
|
if(evt.x - FUDGE_FACTOR_X < 0 || evt.x + FUDGE_FACTOR_X > width
|
||||||
|
|
|
@ -84,6 +84,7 @@ set(MYGUI_FILES
|
||||||
smallbars.png
|
smallbars.png
|
||||||
DejaVuLGCSansMono.ttf
|
DejaVuLGCSansMono.ttf
|
||||||
markers.png
|
markers.png
|
||||||
|
../launcher/images/openmw.png
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -54,6 +54,9 @@ void OgreRenderer::cleanup()
|
||||||
delete mRoot;
|
delete mRoot;
|
||||||
mRoot = NULL;
|
mRoot = NULL;
|
||||||
|
|
||||||
|
if (mWindowIconSurface)
|
||||||
|
SDL_FreeSurface(mWindowIconSurface);
|
||||||
|
|
||||||
// If we don't do this, the desktop resolution is not restored on exit
|
// If we don't do this, the desktop resolution is not restored on exit
|
||||||
SDL_SetWindowFullscreen(mSDLWindow, 0);
|
SDL_SetWindowFullscreen(mSDLWindow, 0);
|
||||||
|
|
||||||
|
@ -289,7 +292,6 @@ void OgreRenderer::createWindow(const std::string &title, const WindowSettings&
|
||||||
| (settings.fullscreen ? SDL_WINDOW_FULLSCREEN : 0)
|
| (settings.fullscreen ? SDL_WINDOW_FULLSCREEN : 0)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
//get the native whnd
|
//get the native whnd
|
||||||
struct SDL_SysWMinfo wmInfo;
|
struct SDL_SysWMinfo wmInfo;
|
||||||
SDL_VERSION(&wmInfo.version);
|
SDL_VERSION(&wmInfo.version);
|
||||||
|
@ -330,6 +332,13 @@ void OgreRenderer::createWindow(const std::string &title, const WindowSettings&
|
||||||
|
|
||||||
mWindow = mRoot->createRenderWindow(title, settings.window_x, settings.window_y, settings.fullscreen, ¶ms);
|
mWindow = mRoot->createRenderWindow(title, settings.window_x, settings.window_y, settings.fullscreen, ¶ms);
|
||||||
|
|
||||||
|
// Set the window icon
|
||||||
|
if (settings.icon != "")
|
||||||
|
{
|
||||||
|
mWindowIconSurface = ogreTextureToSDLSurface(settings.icon);
|
||||||
|
SDL_SetWindowIcon(mSDLWindow, mWindowIconSurface);
|
||||||
|
}
|
||||||
|
|
||||||
// create the semi-transparent black background texture used by the GUI.
|
// create the semi-transparent black background texture used by the GUI.
|
||||||
// has to be created in code with TU_DYNAMIC_WRITE_ONLY param
|
// has to be created in code with TU_DYNAMIC_WRITE_ONLY param
|
||||||
// so that it can be modified at runtime.
|
// so that it can be modified at runtime.
|
||||||
|
@ -388,3 +397,59 @@ void OgreRenderer::setFov(float fov)
|
||||||
{
|
{
|
||||||
mCamera->setFOVy(Degree(fov));
|
mCamera->setFOVy(Degree(fov));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SDL_Surface* OgreRenderer::ogreTextureToSDLSurface(const std::string& name)
|
||||||
|
{
|
||||||
|
Ogre::TexturePtr texture = Ogre::TextureManager::getSingleton().load(name, Ogre::ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME);
|
||||||
|
if (texture.isNull())
|
||||||
|
{
|
||||||
|
std::stringstream error;
|
||||||
|
error << "Window icon not found: " << name;
|
||||||
|
throw std::runtime_error(error.str());
|
||||||
|
}
|
||||||
|
Ogre::Image image;
|
||||||
|
texture->convertToImage(image);
|
||||||
|
|
||||||
|
SDL_Surface* surface = SDL_CreateRGBSurface(0,texture->getWidth(),texture->getHeight(),32,0xFF000000,0x00FF0000,0x0000FF00,0x000000FF);
|
||||||
|
|
||||||
|
//copy the Ogre texture to an SDL surface
|
||||||
|
for(size_t x = 0; x < texture->getWidth(); ++x)
|
||||||
|
{
|
||||||
|
for(size_t y = 0; y < texture->getHeight(); ++y)
|
||||||
|
{
|
||||||
|
Ogre::ColourValue clr = image.getColourAt(x, y, 0);
|
||||||
|
|
||||||
|
//set the pixel on the SDL surface to the same value as the Ogre texture's
|
||||||
|
int bpp = surface->format->BytesPerPixel;
|
||||||
|
/* Here p is the address to the pixel we want to set */
|
||||||
|
Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp;
|
||||||
|
Uint32 pixel = SDL_MapRGBA(surface->format, clr.r*255, clr.g*255, clr.b*255, clr.a*255);
|
||||||
|
switch(bpp) {
|
||||||
|
case 1:
|
||||||
|
*p = pixel;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
*(Uint16 *)p = pixel;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 3:
|
||||||
|
if(SDL_BYTEORDER == SDL_BIG_ENDIAN) {
|
||||||
|
p[0] = (pixel >> 16) & 0xff;
|
||||||
|
p[1] = (pixel >> 8) & 0xff;
|
||||||
|
p[2] = pixel & 0xff;
|
||||||
|
} else {
|
||||||
|
p[0] = pixel & 0xff;
|
||||||
|
p[1] = (pixel >> 8) & 0xff;
|
||||||
|
p[2] = (pixel >> 16) & 0xff;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 4:
|
||||||
|
*(Uint32 *)p = pixel;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return surface;
|
||||||
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct SDL_Window;
|
struct SDL_Window;
|
||||||
|
struct SDL_Surface;
|
||||||
|
|
||||||
namespace Ogre
|
namespace Ogre
|
||||||
{
|
{
|
||||||
|
@ -56,6 +57,7 @@ namespace OEngine
|
||||||
bool fullscreen;
|
bool fullscreen;
|
||||||
int window_x, window_y;
|
int window_x, window_y;
|
||||||
std::string fsaa;
|
std::string fsaa;
|
||||||
|
std::string icon;
|
||||||
};
|
};
|
||||||
|
|
||||||
#if defined(__APPLE__) && !defined(__LP64__)
|
#if defined(__APPLE__) && !defined(__LP64__)
|
||||||
|
@ -80,6 +82,7 @@ namespace OEngine
|
||||||
#endif
|
#endif
|
||||||
Ogre::RenderWindow *mWindow;
|
Ogre::RenderWindow *mWindow;
|
||||||
SDL_Window *mSDLWindow;
|
SDL_Window *mSDLWindow;
|
||||||
|
SDL_Surface *mWindowIconSurface;
|
||||||
Ogre::SceneManager *mScene;
|
Ogre::SceneManager *mScene;
|
||||||
Ogre::Camera *mCamera;
|
Ogre::Camera *mCamera;
|
||||||
Ogre::Viewport *mView;
|
Ogre::Viewport *mView;
|
||||||
|
@ -103,6 +106,8 @@ namespace OEngine
|
||||||
std::vector<Ogre::ParticleAffectorFactory*> mAffectorFactories;
|
std::vector<Ogre::ParticleAffectorFactory*> mAffectorFactories;
|
||||||
bool logging;
|
bool logging;
|
||||||
|
|
||||||
|
SDL_Surface* ogreTextureToSDLSurface(const std::string& name);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
OgreRenderer()
|
OgreRenderer()
|
||||||
: mRoot(NULL)
|
: mRoot(NULL)
|
||||||
|
@ -111,6 +116,7 @@ namespace OEngine
|
||||||
, mScene(NULL)
|
, mScene(NULL)
|
||||||
, mCamera(NULL)
|
, mCamera(NULL)
|
||||||
, mView(NULL)
|
, mView(NULL)
|
||||||
|
, mWindowIconSurface(NULL)
|
||||||
#ifdef ENABLE_PLUGIN_CgProgramManager
|
#ifdef ENABLE_PLUGIN_CgProgramManager
|
||||||
, mCgPlugin(NULL)
|
, mCgPlugin(NULL)
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue