mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-30 21:06:43 +00:00
Dead code removal
This commit is contained in:
parent
9e177df61b
commit
26766b8e0a
9 changed files with 15 additions and 413 deletions
|
@ -370,7 +370,7 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings)
|
|||
//mEnvironment.setInputManager (input);
|
||||
|
||||
MWGui::WindowManager* window = new MWGui::WindowManager(
|
||||
mExtensions, NULL, mCfgMgr.getLogPath().string() + std::string("/"),
|
||||
mExtensions, mCfgMgr.getLogPath().string() + std::string("/"),
|
||||
mCfgMgr.getCachePath ().string(), mScriptConsoleMode, mTranslationDataStorage, mEncoding, mExportFonts, mFallbackMap);
|
||||
mEnvironment.setWindowManager (window);
|
||||
|
||||
|
|
|
@ -24,8 +24,6 @@
|
|||
#include <SDL_keyboard.h>
|
||||
#include <SDL_clipboard.h>
|
||||
|
||||
#include <openengine/ogre/renderer.hpp>
|
||||
|
||||
#include <extern/sdl4ogre/sdlcursormanager.hpp>
|
||||
|
||||
#include <components/fontloader/fontloader.hpp>
|
||||
|
@ -99,12 +97,10 @@ namespace MWGui
|
|||
{
|
||||
|
||||
WindowManager::WindowManager(
|
||||
const Compiler::Extensions& extensions, OEngine::Render::OgreRenderer *ogre,
|
||||
const std::string& logpath, const std::string& cacheDir, bool consoleOnlyScripts,
|
||||
const Compiler::Extensions& extensions, const std::string& logpath, const std::string& cacheDir, bool consoleOnlyScripts,
|
||||
Translation::Storage& translationDataStorage, ToUTF8::FromType encoding, bool exportFonts, const std::map<std::string, std::string>& fallbackMap)
|
||||
: mConsoleOnlyScripts(consoleOnlyScripts)
|
||||
//, mGuiManager(NULL)
|
||||
, mRendering(ogre)
|
||||
, mHud(NULL)
|
||||
, mMap(NULL)
|
||||
, mMenu(NULL)
|
||||
|
@ -838,7 +834,7 @@ namespace MWGui
|
|||
mMessageBoxManager->onFrame(0.f);
|
||||
MWBase::Environment::get().getInputManager()->update(0, true, false);
|
||||
|
||||
mRendering->getWindow()->update();
|
||||
//mRendering->getWindow()->update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1714,6 +1710,7 @@ namespace MWGui
|
|||
}
|
||||
|
||||
// Turn off all rendering except for the GUI
|
||||
/*
|
||||
mRendering->getScene()->clearSpecialCaseRenderQueues();
|
||||
// SCRQM_INCLUDE with RENDER_QUEUE_OVERLAY does not work?
|
||||
for(int i = 0;i < Ogre::RENDER_QUEUE_MAX;++i)
|
||||
|
@ -1722,6 +1719,7 @@ namespace MWGui
|
|||
mRendering->getScene()->addSpecialCaseRenderQueue(i);
|
||||
}
|
||||
mRendering->getScene()->setSpecialCaseRenderQueueMode(Ogre::SceneManager::SCRQM_EXCLUDE);
|
||||
*/
|
||||
|
||||
MyGUI::IntSize screenSize = MyGUI::RenderManager::getInstance().getViewSize();
|
||||
sizeVideo(screenSize.width, screenSize.height);
|
||||
|
@ -1741,7 +1739,7 @@ namespace MWGui
|
|||
{
|
||||
MWBase::Environment::get().getInputManager()->update(0, true, false);
|
||||
|
||||
mRendering->getWindow()->update();
|
||||
//mRendering->getWindow()->update();
|
||||
}
|
||||
mVideoWidget->stop();
|
||||
|
||||
|
@ -1750,8 +1748,8 @@ namespace MWGui
|
|||
setCursorVisible(cursorWasVisible);
|
||||
|
||||
// Restore normal rendering
|
||||
mRendering->getScene()->clearSpecialCaseRenderQueues();
|
||||
mRendering->getScene()->setSpecialCaseRenderQueueMode(Ogre::SceneManager::SCRQM_EXCLUDE);
|
||||
//mRendering->getScene()->clearSpecialCaseRenderQueues();
|
||||
//mRendering->getScene()->setSpecialCaseRenderQueueMode(Ogre::SceneManager::SCRQM_EXCLUDE);
|
||||
|
||||
mVideoBackground->setVisible(false);
|
||||
}
|
||||
|
|
|
@ -99,8 +99,7 @@ namespace MWGui
|
|||
typedef std::pair<std::string, int> Faction;
|
||||
typedef std::vector<Faction> FactionList;
|
||||
|
||||
WindowManager(const Compiler::Extensions& extensions,
|
||||
OEngine::Render::OgreRenderer *mOgre, const std::string& logpath,
|
||||
WindowManager(const Compiler::Extensions& extensions, const std::string& logpath,
|
||||
const std::string& cacheDir, bool consoleOnlyScripts,
|
||||
Translation::Storage& translationDataStorage, ToUTF8::FromType encoding, bool exportFonts, const std::map<std::string,std::string>& fallbackMap);
|
||||
virtual ~WindowManager();
|
||||
|
@ -366,7 +365,6 @@ namespace MWGui
|
|||
CustomMarkerCollection mCustomMarkers;
|
||||
|
||||
OEngine::GUI::MyGUIManager *mGuiManager;
|
||||
OEngine::Render::OgreRenderer *mRendering;
|
||||
HUD *mHud;
|
||||
MapWindow *mMap;
|
||||
MainMenu *mMenu;
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
#define GAME_RENDER_MWSCENE_H
|
||||
|
||||
#include <utility>
|
||||
#include <openengine/ogre/renderer.hpp>
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
|
@ -29,6 +29,7 @@ namespace Ogre
|
|||
class RaySceneQuery;
|
||||
class Quaternion;
|
||||
class Vector3;
|
||||
class ManualObject;
|
||||
}
|
||||
|
||||
namespace MWWorld
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
#include <openengine/bullet/trace.h>
|
||||
#include <openengine/bullet/physic.hpp>
|
||||
#include <openengine/bullet/BtOgreExtras.h>
|
||||
#include <openengine/ogre/renderer.hpp>
|
||||
//#include <openengine/bullet/BulletShapeLoader.h>
|
||||
|
||||
#include <components/nifbullet/bulletnifloader.hpp>
|
||||
|
@ -499,8 +498,8 @@ namespace MWWorld
|
|||
};
|
||||
|
||||
|
||||
PhysicsSystem::PhysicsSystem(OEngine::Render::OgreRenderer &_rend) :
|
||||
mRender(_rend), mEngine(0), mTimeAccum(0.0f), mWaterEnabled(false), mWaterHeight(0)
|
||||
PhysicsSystem::PhysicsSystem() :
|
||||
mEngine(0), mTimeAccum(0.0f), mWaterEnabled(false), mWaterHeight(0)
|
||||
{
|
||||
// Create physics. shapeLoader is deleted by the physic engine
|
||||
//NifBullet::ManualBulletShapeLoader* shapeLoader = new NifBullet::ManualBulletShapeLoader();
|
||||
|
|
|
@ -12,10 +12,6 @@
|
|||
|
||||
namespace OEngine
|
||||
{
|
||||
namespace Render
|
||||
{
|
||||
class OgreRenderer;
|
||||
}
|
||||
namespace Physic
|
||||
{
|
||||
class PhysicEngine;
|
||||
|
@ -31,7 +27,7 @@ namespace MWWorld
|
|||
class PhysicsSystem
|
||||
{
|
||||
public:
|
||||
PhysicsSystem (OEngine::Render::OgreRenderer &_rend);
|
||||
PhysicsSystem ();
|
||||
~PhysicsSystem ();
|
||||
|
||||
void enableWater(float height);
|
||||
|
@ -116,7 +112,6 @@ namespace MWWorld
|
|||
|
||||
void updateWater();
|
||||
|
||||
OEngine::Render::OgreRenderer &mRender;
|
||||
OEngine::Physic::PhysicEngine* mEngine;
|
||||
std::map<std::string, std::string> handleToMesh;
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
set(OENGINE_OGRE
|
||||
#ogre/renderer.cpp
|
||||
ogre/lights.cpp
|
||||
#ogre/lights.cpp
|
||||
)
|
||||
|
||||
set(OENGINE_GUI
|
||||
|
|
|
@ -1,241 +0,0 @@
|
|||
#include "renderer.hpp"
|
||||
|
||||
#include <SDL.h>
|
||||
|
||||
#include <OgreRoot.h>
|
||||
#include <OgreRenderWindow.h>
|
||||
#include <OgreTextureManager.h>
|
||||
#include <OgreTexture.h>
|
||||
#include <OgreHardwarePixelBuffer.h>
|
||||
#include <OgreCamera.h>
|
||||
#include <OgreViewport.h>
|
||||
|
||||
#include <extern/sdl4ogre/sdlwindowhelper.hpp>
|
||||
|
||||
#include <components/ogreinit/ogreinit.hpp>
|
||||
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include <boost/filesystem/fstream.hpp>
|
||||
|
||||
#include <cassert>
|
||||
#include <stdexcept>
|
||||
|
||||
using namespace Ogre;
|
||||
using namespace OEngine::Render;
|
||||
|
||||
OgreRenderer::~OgreRenderer()
|
||||
{
|
||||
cleanup();
|
||||
restoreWindowGammaRamp();
|
||||
}
|
||||
|
||||
void OgreRenderer::cleanup()
|
||||
{
|
||||
if (mWindow)
|
||||
Ogre::Root::getSingleton().destroyRenderTarget(mWindow);
|
||||
mWindow = NULL;
|
||||
|
||||
delete mOgreInit;
|
||||
mOgreInit = NULL;
|
||||
|
||||
// If we don't do this, the desktop resolution is not restored on exit
|
||||
SDL_SetWindowFullscreen(mSDLWindow, 0);
|
||||
|
||||
SDL_DestroyWindow(mSDLWindow);
|
||||
mSDLWindow = NULL;
|
||||
}
|
||||
|
||||
void OgreRenderer::update(float dt)
|
||||
{
|
||||
}
|
||||
|
||||
void OgreRenderer::screenshot(const std::string &file, const std::string& imageFormat)
|
||||
{
|
||||
/* Since Ogre uses narrow character interfaces, it does not support
|
||||
Unicode paths on Windows. Therefore we had to implement screenshot
|
||||
saving manually.
|
||||
*/
|
||||
namespace bfs = boost::filesystem;
|
||||
bfs::ofstream out(bfs::path(file), std::ios::binary);
|
||||
|
||||
Ogre::Image image;
|
||||
|
||||
Ogre::PixelFormat pf = mWindow->suggestPixelFormat();
|
||||
int w = mWindow->getWidth();
|
||||
int h = mWindow->getHeight();
|
||||
|
||||
image.loadDynamicImage(
|
||||
OGRE_ALLOC_T(Ogre::uchar, w * h * Ogre::PixelUtil::getNumElemBytes(pf), Ogre::MEMCATEGORY_GENERAL),
|
||||
w, h, 1, pf, true
|
||||
);
|
||||
mWindow->copyContentsToMemory(image.getPixelBox());
|
||||
|
||||
Ogre::DataStreamPtr stream = image.encode(imageFormat);
|
||||
Ogre::MemoryDataStream *mem = dynamic_cast<Ogre::MemoryDataStream *>(stream.get());
|
||||
if (mem != 0) { // likely
|
||||
const char *ptr = reinterpret_cast<char *>(mem->getCurrentPtr());
|
||||
out.write(ptr, mem->size());
|
||||
}
|
||||
else {
|
||||
char buf[4096];
|
||||
size_t size = stream->size();
|
||||
while (size > 0) {
|
||||
size_t chunk = (size > sizeof(buf)) ? sizeof(buf) : size;
|
||||
stream->read(buf, chunk);
|
||||
out.write(buf, chunk);
|
||||
size -= chunk;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OgreRenderer::configure(const std::string &logPath,
|
||||
const std::string& renderSystem,
|
||||
const std::string& rttMode
|
||||
)
|
||||
{
|
||||
mOgreInit = new OgreInit::OgreInit();
|
||||
mRoot = mOgreInit->init(logPath + "/ogre.log");
|
||||
|
||||
RenderSystem* rs = mRoot->getRenderSystemByName(renderSystem);
|
||||
if (rs == 0)
|
||||
throw std::runtime_error ("RenderSystem with name " + renderSystem + " not found, make sure the plugins are loaded");
|
||||
mRoot->setRenderSystem(rs);
|
||||
|
||||
if (rs->getName().find("OpenGL") != std::string::npos)
|
||||
rs->setConfigOption ("RTT Preferred Mode", rttMode);
|
||||
}
|
||||
|
||||
void OgreRenderer::createWindow(const std::string &title, const WindowSettings& settings)
|
||||
{
|
||||
assert(mRoot);
|
||||
mRoot->initialise(false);
|
||||
|
||||
NameValuePairList params;
|
||||
params.insert(std::make_pair("title", title));
|
||||
params.insert(std::make_pair("FSAA", settings.fsaa));
|
||||
params.insert(std::make_pair("vsync", settings.vsync ? "true" : "false"));
|
||||
|
||||
int pos_x = SDL_WINDOWPOS_CENTERED_DISPLAY(settings.screen),
|
||||
pos_y = SDL_WINDOWPOS_CENTERED_DISPLAY(settings.screen);
|
||||
|
||||
if(settings.fullscreen)
|
||||
{
|
||||
pos_x = SDL_WINDOWPOS_UNDEFINED_DISPLAY(settings.screen);
|
||||
pos_y = SDL_WINDOWPOS_UNDEFINED_DISPLAY(settings.screen);
|
||||
}
|
||||
|
||||
|
||||
// Create an application window with the following settings:
|
||||
mSDLWindow = SDL_CreateWindow(
|
||||
"OpenMW", // window title
|
||||
pos_x, // initial x position
|
||||
pos_y, // initial y position
|
||||
settings.window_x, // width, in pixels
|
||||
settings.window_y, // height, in pixels
|
||||
SDL_WINDOW_SHOWN
|
||||
| SDL_WINDOW_RESIZABLE
|
||||
| (settings.fullscreen ? SDL_WINDOW_FULLSCREEN : 0)
|
||||
| (settings.window_border ? 0 : SDL_WINDOW_BORDERLESS)
|
||||
);
|
||||
if (mSDLWindow == 0)
|
||||
throw std::runtime_error("Failed to create window: " + std::string(SDL_GetError()));
|
||||
|
||||
SFO::SDLWindowHelper helper(mSDLWindow, settings.window_x, settings.window_y, title, settings.fullscreen, params);
|
||||
if (settings.icon != "")
|
||||
helper.setWindowIcon(settings.icon);
|
||||
mWindow = helper.getWindow();
|
||||
|
||||
SDL_GetWindowGammaRamp(mSDLWindow, mOldSystemGammaRamp, &mOldSystemGammaRamp[256], &mOldSystemGammaRamp[512]);
|
||||
|
||||
// create the semi-transparent black background texture used by the GUI.
|
||||
// has to be created in code with TU_DYNAMIC_WRITE_ONLY param
|
||||
// so that it can be modified at runtime.
|
||||
Ogre::TextureManager::getSingleton().createManual(
|
||||
"transparent.png",
|
||||
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
|
||||
Ogre::TEX_TYPE_2D,
|
||||
1, 1,
|
||||
0,
|
||||
Ogre::PF_A8R8G8B8,
|
||||
Ogre::TU_WRITE_ONLY);
|
||||
|
||||
mScene = mRoot->createSceneManager(ST_GENERIC);
|
||||
|
||||
mCamera = mScene->createCamera("cam");
|
||||
|
||||
// Create one viewport, entire window
|
||||
mView = mWindow->addViewport(mCamera);
|
||||
// Alter the camera aspect ratio to match the viewport
|
||||
mCamera->setAspectRatio(Real(mView->getActualWidth()) / Real(mView->getActualHeight()));
|
||||
}
|
||||
|
||||
void OgreRenderer::setWindowGammaContrast(float gamma, float contrast)
|
||||
{
|
||||
if (mSDLWindow == NULL) return;
|
||||
|
||||
Uint16 red[256], green[256], blue[256];
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
float k = i/256.0f;
|
||||
k = (k - 0.5f) * contrast + 0.5f;
|
||||
k = pow(k, 1.f/gamma);
|
||||
k *= 256;
|
||||
float value = k*256;
|
||||
if (value > 65535) value = 65535;
|
||||
else if (value < 0) value = 0;
|
||||
|
||||
red[i] = green[i] = blue[i] = static_cast<Uint16>(value);
|
||||
}
|
||||
if (SDL_SetWindowGammaRamp(mSDLWindow, red, green, blue) < 0)
|
||||
std::cout << "Couldn't set gamma: " << SDL_GetError() << std::endl;
|
||||
}
|
||||
|
||||
void OgreRenderer::restoreWindowGammaRamp()
|
||||
{
|
||||
if (mSDLWindow != NULL)
|
||||
{
|
||||
SDL_SetWindowGammaRamp(mSDLWindow, mOldSystemGammaRamp, &mOldSystemGammaRamp[256], &mOldSystemGammaRamp[512]);
|
||||
}
|
||||
}
|
||||
|
||||
void OgreRenderer::adjustCamera(float fov, float nearClip)
|
||||
{
|
||||
mCamera->setNearClipDistance(nearClip);
|
||||
mCamera->setFOVy(Degree(fov));
|
||||
}
|
||||
|
||||
void OgreRenderer::adjustViewport()
|
||||
{
|
||||
// Alter the camera aspect ratio to match the viewport
|
||||
if(mCamera != NULL)
|
||||
{
|
||||
mView->setDimensions(0, 0, 1, 1);
|
||||
mCamera->setAspectRatio(Real(mView->getActualWidth()) / Real(mView->getActualHeight()));
|
||||
}
|
||||
}
|
||||
|
||||
void OgreRenderer::setFov(float fov)
|
||||
{
|
||||
mCamera->setFOVy(Degree(fov));
|
||||
}
|
||||
|
||||
void OgreRenderer::windowResized(int x, int y)
|
||||
{
|
||||
if (mWindowListener) {
|
||||
mWindowListener->windowResized(x,y);
|
||||
}
|
||||
else {
|
||||
mWindowWidth = x;
|
||||
mWindowHeight = y;
|
||||
mOutstandingResize = true;
|
||||
}
|
||||
}
|
||||
|
||||
void OgreRenderer::setWindowListener(WindowSizeListener* listener)
|
||||
{
|
||||
mWindowListener = listener;
|
||||
if (mOutstandingResize) {
|
||||
windowResized(mWindowWidth, mWindowHeight);
|
||||
mOutstandingResize = false;
|
||||
}
|
||||
}
|
|
@ -1,147 +0,0 @@
|
|||
#ifndef OENGINE_OGRE_RENDERER_H
|
||||
#define OENGINE_OGRE_RENDERER_H
|
||||
|
||||
/*
|
||||
Ogre renderer class
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <OgreTexture.h>
|
||||
|
||||
|
||||
struct SDL_Window;
|
||||
struct SDL_Surface;
|
||||
|
||||
namespace Ogre
|
||||
{
|
||||
class Root;
|
||||
class RenderWindow;
|
||||
class SceneManager;
|
||||
class Camera;
|
||||
class Viewport;
|
||||
class ParticleEmitterFactory;
|
||||
class ParticleAffectorFactory;
|
||||
}
|
||||
|
||||
namespace OgreInit
|
||||
{
|
||||
class OgreInit;
|
||||
}
|
||||
|
||||
namespace OEngine
|
||||
{
|
||||
namespace Render
|
||||
{
|
||||
struct WindowSettings
|
||||
{
|
||||
bool vsync;
|
||||
bool fullscreen;
|
||||
bool window_border;
|
||||
int window_x, window_y;
|
||||
int screen;
|
||||
std::string fsaa;
|
||||
std::string icon;
|
||||
};
|
||||
|
||||
class WindowSizeListener
|
||||
{
|
||||
public:
|
||||
virtual void windowResized (int x, int y) = 0;
|
||||
};
|
||||
|
||||
class OgreRenderer
|
||||
{
|
||||
Ogre::Root *mRoot;
|
||||
Ogre::RenderWindow *mWindow;
|
||||
SDL_Window *mSDLWindow;
|
||||
Ogre::SceneManager *mScene;
|
||||
Ogre::Camera *mCamera;
|
||||
Ogre::Viewport *mView;
|
||||
|
||||
OgreInit::OgreInit* mOgreInit;
|
||||
|
||||
WindowSizeListener* mWindowListener;
|
||||
|
||||
int mWindowWidth;
|
||||
int mWindowHeight;
|
||||
bool mOutstandingResize;
|
||||
|
||||
// Store system gamma ramp on window creation. Restore system gamma ramp on exit
|
||||
uint16_t mOldSystemGammaRamp[256*3];
|
||||
|
||||
public:
|
||||
OgreRenderer()
|
||||
: mRoot(NULL)
|
||||
, mWindow(NULL)
|
||||
, mSDLWindow(NULL)
|
||||
, mScene(NULL)
|
||||
, mCamera(NULL)
|
||||
, mView(NULL)
|
||||
, mOgreInit(NULL)
|
||||
, mWindowListener(NULL)
|
||||
, mWindowWidth(0)
|
||||
, mWindowHeight(0)
|
||||
, mOutstandingResize(false)
|
||||
{
|
||||
}
|
||||
|
||||
~OgreRenderer();
|
||||
|
||||
/** Configure the renderer. This will load configuration files and
|
||||
set up the Root and logging classes. */
|
||||
void configure(
|
||||
const std::string &logPath, // Path to directory where to store log files
|
||||
const std::string &renderSystem,
|
||||
const std::string &rttMode); // Enable or disable logging
|
||||
|
||||
/// Create a window with the given title
|
||||
void createWindow(const std::string &title, const WindowSettings& settings);
|
||||
|
||||
void setWindowGammaContrast(float gamma, float contrast);
|
||||
void restoreWindowGammaRamp();
|
||||
|
||||
/// Set up the scene manager, camera and viewport
|
||||
void adjustCamera(
|
||||
float fov=55, // Field of view angle
|
||||
float nearClip=5 // Near clip distance
|
||||
);
|
||||
|
||||
void setFov(float fov);
|
||||
|
||||
/// Kill the renderer.
|
||||
void cleanup();
|
||||
|
||||
void update(float dt);
|
||||
|
||||
/// Write a screenshot to file
|
||||
void screenshot(const std::string &file, const std::string& imageFormat);
|
||||
|
||||
void windowResized(int x, int y);
|
||||
|
||||
/// Get the Root
|
||||
Ogre::Root *getRoot() { return mRoot; }
|
||||
|
||||
/// Get the rendering window
|
||||
Ogre::RenderWindow *getWindow() { return mWindow; }
|
||||
|
||||
/// Get the SDL Window
|
||||
SDL_Window *getSDLWindow() { return mSDLWindow; }
|
||||
|
||||
/// Get the scene manager
|
||||
Ogre::SceneManager *getScene() { return mScene; }
|
||||
|
||||
/// Camera
|
||||
Ogre::Camera *getCamera() { return mCamera; }
|
||||
|
||||
/// Viewport
|
||||
Ogre::Viewport *getViewport() { return mView; }
|
||||
|
||||
void setWindowListener(WindowSizeListener* listener);
|
||||
|
||||
void adjustViewport();
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif
|
Loading…
Reference in a new issue