2010-07-09 19:21:04 +00:00
|
|
|
#ifndef OENGINE_OGRE_RENDERER_H
|
|
|
|
#define OENGINE_OGRE_RENDERER_H
|
|
|
|
|
|
|
|
/*
|
|
|
|
Ogre renderer class
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <string>
|
2015-01-17 02:35:58 +00:00
|
|
|
#include <stdint.h>
|
2010-07-09 19:21:04 +00:00
|
|
|
|
2013-10-30 13:04:33 +00:00
|
|
|
#include <OgreTexture.h>
|
2012-03-15 14:51:39 +00:00
|
|
|
|
2013-06-16 12:25:13 +00:00
|
|
|
|
2013-01-14 01:32:45 +00:00
|
|
|
struct SDL_Window;
|
2013-06-12 14:15:04 +00:00
|
|
|
struct SDL_Surface;
|
2013-01-14 01:32:45 +00:00
|
|
|
|
2010-07-09 19:21:04 +00:00
|
|
|
namespace Ogre
|
|
|
|
{
|
|
|
|
class Root;
|
|
|
|
class RenderWindow;
|
|
|
|
class SceneManager;
|
|
|
|
class Camera;
|
|
|
|
class Viewport;
|
2013-04-13 21:36:24 +00:00
|
|
|
class ParticleEmitterFactory;
|
2013-04-06 07:18:36 +00:00
|
|
|
class ParticleAffectorFactory;
|
2010-07-09 19:21:04 +00:00
|
|
|
}
|
|
|
|
|
2013-12-26 14:57:54 +00:00
|
|
|
namespace OgreInit
|
|
|
|
{
|
|
|
|
class OgreInit;
|
|
|
|
}
|
|
|
|
|
2012-05-22 01:36:03 +00:00
|
|
|
namespace OEngine
|
2010-07-09 19:21:04 +00:00
|
|
|
{
|
2012-05-22 01:36:03 +00:00
|
|
|
namespace Render
|
2012-03-25 19:56:22 +00:00
|
|
|
{
|
2012-05-22 01:36:03 +00:00
|
|
|
struct WindowSettings
|
|
|
|
{
|
|
|
|
bool vsync;
|
|
|
|
bool fullscreen;
|
2014-12-24 14:09:50 +00:00
|
|
|
bool window_border;
|
2012-05-22 01:36:03 +00:00
|
|
|
int window_x, window_y;
|
2013-07-01 01:56:33 +00:00
|
|
|
int screen;
|
2012-05-22 01:36:03 +00:00
|
|
|
std::string fsaa;
|
2013-06-12 14:15:04 +00:00
|
|
|
std::string icon;
|
2012-05-22 01:36:03 +00:00
|
|
|
};
|
|
|
|
|
2013-07-29 00:32:08 +00:00
|
|
|
class WindowSizeListener
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual void windowResized (int x, int y) = 0;
|
|
|
|
};
|
|
|
|
|
2012-05-22 01:36:03 +00:00
|
|
|
class OgreRenderer
|
|
|
|
{
|
|
|
|
Ogre::Root *mRoot;
|
|
|
|
Ogre::RenderWindow *mWindow;
|
2013-01-14 01:32:45 +00:00
|
|
|
SDL_Window *mSDLWindow;
|
2012-05-22 01:36:03 +00:00
|
|
|
Ogre::SceneManager *mScene;
|
|
|
|
Ogre::Camera *mCamera;
|
|
|
|
Ogre::Viewport *mView;
|
2013-10-30 13:04:33 +00:00
|
|
|
|
2013-12-26 14:57:54 +00:00
|
|
|
OgreInit::OgreInit* mOgreInit;
|
2013-10-30 13:04:33 +00:00
|
|
|
|
2013-07-29 00:32:08 +00:00
|
|
|
WindowSizeListener* mWindowListener;
|
2013-06-12 14:15:04 +00:00
|
|
|
|
2014-03-29 14:49:48 +00:00
|
|
|
int mWindowWidth;
|
|
|
|
int mWindowHeight;
|
|
|
|
bool mOutstandingResize;
|
|
|
|
|
2014-12-30 15:33:11 +00:00
|
|
|
// Store system gamma ramp on window creation. Restore system gamma ramp on exit
|
|
|
|
uint16_t mOldSystemGammaRamp[256*3];
|
|
|
|
|
2012-05-22 01:36:03 +00:00
|
|
|
public:
|
|
|
|
OgreRenderer()
|
|
|
|
: mRoot(NULL)
|
|
|
|
, mWindow(NULL)
|
2013-01-14 01:32:45 +00:00
|
|
|
, mSDLWindow(NULL)
|
2012-05-22 01:36:03 +00:00
|
|
|
, mScene(NULL)
|
|
|
|
, mCamera(NULL)
|
|
|
|
, mView(NULL)
|
2013-12-30 20:47:06 +00:00
|
|
|
, mOgreInit(NULL)
|
|
|
|
, mWindowListener(NULL)
|
2014-03-29 14:49:48 +00:00
|
|
|
, mWindowWidth(0)
|
|
|
|
, mWindowHeight(0)
|
|
|
|
, mOutstandingResize(false)
|
2012-05-22 01:36:03 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-12-30 15:33:11 +00:00
|
|
|
~OgreRenderer();
|
2012-05-22 01:36:03 +00:00
|
|
|
|
|
|
|
/** 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,
|
2013-10-30 13:04:33 +00:00
|
|
|
const std::string &rttMode); // Enable or disable logging
|
2012-05-22 01:36:03 +00:00
|
|
|
|
|
|
|
/// Create a window with the given title
|
|
|
|
void createWindow(const std::string &title, const WindowSettings& settings);
|
|
|
|
|
2014-12-30 15:33:11 +00:00
|
|
|
void setWindowGammaContrast(float gamma, float contrast);
|
2014-12-31 15:40:01 +00:00
|
|
|
void restoreWindowGammaRamp();
|
2014-12-30 15:33:11 +00:00
|
|
|
|
2012-05-22 01:36:03 +00:00
|
|
|
/// Set up the scene manager, camera and viewport
|
2013-08-27 13:48:13 +00:00
|
|
|
void adjustCamera(
|
2012-05-22 01:36:03 +00:00
|
|
|
float fov=55, // Field of view angle
|
|
|
|
float nearClip=5 // Near clip distance
|
|
|
|
);
|
|
|
|
|
2012-05-29 02:54:54 +00:00
|
|
|
void setFov(float fov);
|
|
|
|
|
2012-05-22 01:36:03 +00:00
|
|
|
/// Kill the renderer.
|
|
|
|
void cleanup();
|
|
|
|
|
|
|
|
void update(float dt);
|
|
|
|
|
|
|
|
/// Write a screenshot to file
|
2014-09-11 02:28:14 +00:00
|
|
|
void screenshot(const std::string &file, const std::string& imageFormat);
|
2012-05-22 01:36:03 +00:00
|
|
|
|
2013-07-29 00:32:08 +00:00
|
|
|
void windowResized(int x, int y);
|
|
|
|
|
2012-05-22 01:36:03 +00:00
|
|
|
/// Get the Root
|
|
|
|
Ogre::Root *getRoot() { return mRoot; }
|
|
|
|
|
|
|
|
/// Get the rendering window
|
|
|
|
Ogre::RenderWindow *getWindow() { return mWindow; }
|
|
|
|
|
2013-01-14 01:32:45 +00:00
|
|
|
/// Get the SDL Window
|
|
|
|
SDL_Window *getSDLWindow() { return mSDLWindow; }
|
|
|
|
|
2012-05-22 01:36:03 +00:00
|
|
|
/// Get the scene manager
|
|
|
|
Ogre::SceneManager *getScene() { return mScene; }
|
|
|
|
|
|
|
|
/// Camera
|
|
|
|
Ogre::Camera *getCamera() { return mCamera; }
|
|
|
|
|
|
|
|
/// Viewport
|
|
|
|
Ogre::Viewport *getViewport() { return mView; }
|
2012-05-27 19:39:18 +00:00
|
|
|
|
2014-03-29 14:49:48 +00:00
|
|
|
void setWindowListener(WindowSizeListener* listener);
|
2013-07-29 00:32:08 +00:00
|
|
|
|
2012-05-28 07:19:25 +00:00
|
|
|
void adjustViewport();
|
2012-05-22 01:36:03 +00:00
|
|
|
};
|
2012-03-25 19:56:22 +00:00
|
|
|
}
|
2012-05-22 01:36:03 +00:00
|
|
|
}
|
2010-07-09 19:21:04 +00:00
|
|
|
#endif
|