#include <wxOgreControl.h>
Public Member Functions | |
| wxOgreControl (Ogre::Root &root, Ogre::SceneManager &sceneManager, wxWindow &parent, Ogre::NameValuePairList *miscParams=0, wxPoint const &pos=wxDefaultPosition, wxWindowID id=wxID_ANY, long style=0, wxValidator const &validator=wxDefaultValidator, wxString const &name=wxT("OgreControl")) | |
| Creates a new control that embeds Ogre in it. | |
| virtual | ~wxOgreControl (void) |
| Destroys the render window and the camera. | |
| Ogre::RenderWindow *const | getRenderWindow () const |
| Ogre::Camera *const | getCamera () const |
| Ogre::Viewport *const | getViewport () const |
| Ogre::SceneManager *const | getSceneManager () const |
| void | pause (bool const pause) |
| Pauses and unpauses the rendering. | |
| bool | isPaused (void) const |
| void | setRenderTimerInterval (unsigned int interval) |
| Sets the time, in milliseconds, between renderings. | |
| unsigned int | getRenderTimerInterval () const |
| virtual bool | Show (bool show=true) |
| Shows or hides the control. | |
| virtual bool | addListener (wxOgreControlListener *const listener) |
| Adds a new listener to the control. | |
| virtual bool | removeListener (wxOgreControlListener *const listener) |
| Removes a listener from the control. | |
| virtual void | removeAllListeners () |
| Removes all listeners from the control. | |
Static Public Member Functions | |
| static std::string | getHandleAsString (wxWindow *const window) |
| Returns the string identifying the handle of a window. | |
Protected Types | |
| typedef std::set< wxOgreControlListener * > | ListenerList |
Protected Member Functions | |
| virtual void | initRenderWindow (Ogre::Root &root, wxSize const &size, Ogre::NameValuePairList *miscParams) |
| Creates an Ogre render window, camera, and viewport. | |
| virtual void | onSize (wxSizeEvent &evt) |
| Handles the size event by letting Ogre know that the window was resized and adjusting the camera's aspect ratio. | |
| virtual void | onEraseBackground (wxEraseEvent &evt) |
| Overrides the default background erasing of the control. | |
| virtual void | onClose (wxCloseEvent &evt) |
| Destroys the render window and the camera, but first calls all listeners. | |
| virtual void | onMouseMotion (wxMouseEvent &evt) |
| Listens for mouse motion on the window and forwards the event to the listeners. | |
| virtual void | captureMouse (wxMouseEvent &evt) |
| Called when either the left, right, or middle mouse button is clicked. This captures the mouse so dragging outside the bounds of the control still directs input to the control, a common way of handling input. | |
| virtual void | releaseMouse (wxMouseEvent &evt) |
| Called when either the left, right, or middle mouse button is release. This releases the mouse capture. | |
| virtual void | onRenderTimer (wxTimerEvent &evt) |
| Called when the render timer expires. This updates the render window. | |
| virtual void | destroy (void) |
| Destroys the render window and the camera. | |
Protected Attributes | |
| Ogre::RenderWindow * | m_renderWindow |
| The render window created for the control. | |
| Ogre::Camera * | m_camera |
| The camera created for the control. | |
| Ogre::Viewport * | m_viewport |
| The viewport that was created by adding the camera to the render window. | |
| Ogre::SceneManager * | m_sceneManager |
| The scene manager used to create the camera used by this control. | |
| wxTimer | m_renderTimer |
| The timer used to render. | |
| int | m_timerInterval |
| The time interval used to render with. | |
| bool | m_paused |
| Determines if the rendering is paused. | |
| long const | ID_RENDER_TIMER |
| The wxWidgets ID of the render timer. | |
| wxCoord | m_lastX |
| The last X position of the mouse, used for calculating relative mouse motion. | |
| wxCoord | m_lastY |
| The last Y position of the mouse, used for calculating relative mouse motion. | |
| ListenerList | m_listeners |
| The listeners that listen for events of this control. | |
Static Protected Attributes | |
| static int const | DEFAULT_TIMER_INTERVAL |
| The default interval for the render timer. The value is 33 milliseconds. | |
typedef std::set<wxOgreControlListener*> PWOgreBox::wxOgreControl::ListenerList [protected] |
| PWOgreBox::wxOgreControl::wxOgreControl | ( | Ogre::Root & | root, | |
| Ogre::SceneManager & | sceneManager, | |||
| wxWindow & | parent, | |||
| Ogre::NameValuePairList * | miscParams = 0, |
|||
| wxPoint const & | pos = wxDefaultPosition, |
|||
| wxWindowID | id = wxID_ANY, |
|||
| long | style = 0, |
|||
| wxValidator const & | validator = wxDefaultValidator, |
|||
| wxString const & | name = wxT("OgreControl") | |||
| ) |
Creates a new control that embeds Ogre in it.
Upon creation, the control will create a new Ogre render window. Users are allowed to pass custom parameters for the creation of the Ogre render window. After creation, miscParams will contain a new entry with key "externalWindowHandle" with the value equal to the handle of the control.
During creation, a new camera is created for the render window. The camera is positioned at the world orgin. A new viewport is added to the render window. wxOgreControl gives you access to the render window, camera, and viewport that are created.
The control is updated periodically, based on a configurable timer. Controls are independent, so each control could have different refresh rates. Controls can also be paused.
wxOgreControl implements some actions for common events. To hook into these events, a listener interface is provided. For other events, the Connect function of wxWidgets can be used.
| root | The root of Ogre | |
| sceneManager | An Ogre scene manager which will be used to create a camera for the control | |
| parent | The parent window of this control | |
| miscParams | A NameValuePairList describing the other parameters for the new rendering window. See the Ogre::Root::createRenderWindow documentation for details. | |
| id | Window ID | |
| pos | Window position | |
| size | Window size | |
| style | Window style | |
| validator | Window validator | |
| name | Window name |
| virtual PWOgreBox::wxOgreControl::~wxOgreControl | ( | void | ) | [virtual] |
Destroys the render window and the camera.
| Ogre::RenderWindow* const PWOgreBox::wxOgreControl::getRenderWindow | ( | ) | const [inline] |
| Ogre::Camera* const PWOgreBox::wxOgreControl::getCamera | ( | ) | const [inline] |
| Ogre::Viewport* const PWOgreBox::wxOgreControl::getViewport | ( | ) | const [inline] |
| Ogre::SceneManager* const PWOgreBox::wxOgreControl::getSceneManager | ( | ) | const [inline] |
| void PWOgreBox::wxOgreControl::pause | ( | bool const | pause | ) |
Pauses and unpauses the rendering.
| pause | true if the rendering should be paused, false otherwise |
| bool PWOgreBox::wxOgreControl::isPaused | ( | void | ) | const [inline] |
true if rendering is paused, false otherwise | void PWOgreBox::wxOgreControl::setRenderTimerInterval | ( | unsigned int | interval | ) |
Sets the time, in milliseconds, between renderings.
The timer defaults to 33 ms, which is about 30 frames per second
| unsigned int PWOgreBox::wxOgreControl::getRenderTimerInterval | ( | ) | const [inline] |
| virtual bool PWOgreBox::wxOgreControl::Show | ( | bool | show = true |
) | [virtual] |
Shows or hides the control.
Hiding a window does not stop the render timer, but it does call setVisible on the Ogre render window.
| show | true if the control should be shown, false otherwise |
| virtual bool PWOgreBox::wxOgreControl::addListener | ( | wxOgreControlListener *const | listener | ) | [virtual] |
Adds a new listener to the control.
| listener | The listener to add to the control |
true if the listener was added, false if the listener was already in the set of listeners. | virtual bool PWOgreBox::wxOgreControl::removeListener | ( | wxOgreControlListener *const | listener | ) | [virtual] |
Removes a listener from the control.
| listener | The listener to remove |
true if the listener was removed, false if the listener was not in the set of listeners. | virtual void PWOgreBox::wxOgreControl::removeAllListeners | ( | ) | [virtual] |
Removes all listeners from the control.
Memory management is left to the user. If the listener is a wxWidgets frame, it will get cleaned up automatically when wxWidgets cleans up the frame.
| static std::string PWOgreBox::wxOgreControl::getHandleAsString | ( | wxWindow *const | window | ) | [static] |
Returns the string identifying the handle of a window.
In Linux, this function will also take the opportunity to make the window double-buffered for you to prevent flickering.
| window | The window to retrieve the handle from |
| virtual void PWOgreBox::wxOgreControl::initRenderWindow | ( | Ogre::Root & | root, | |
| wxSize const & | size, | |||
| Ogre::NameValuePairList * | miscParams | |||
| ) | [protected, virtual] |
Creates an Ogre render window, camera, and viewport.
The size of the render window must match the size of the frame, or on linux the render window will be too small until the frame is resized.
| root | The Ogre::Root object | |
| size | The size of the render window. | |
| miscParams | Miscellaneous parameters passed to the render window |
| virtual void PWOgreBox::wxOgreControl::onSize | ( | wxSizeEvent & | evt | ) | [protected, virtual] |
Handles the size event by letting Ogre know that the window was resized and adjusting the camera's aspect ratio.
| evt | The wxWidgets event that was generated |
| virtual void PWOgreBox::wxOgreControl::onEraseBackground | ( | wxEraseEvent & | evt | ) | [protected, virtual] |
Overrides the default background erasing of the control.
If the render timer is not paused, this does nothing to avoid flickering. If the render timer is paused, this will do the default action for wxControl::OnEraseBackground
| evt | The wxWidgets event that was generated |
| virtual void PWOgreBox::wxOgreControl::onClose | ( | wxCloseEvent & | evt | ) | [protected, virtual] |
Destroys the render window and the camera, but first calls all listeners.
| evt | The wxWidgets event that was generated |
| virtual void PWOgreBox::wxOgreControl::onMouseMotion | ( | wxMouseEvent & | evt | ) | [protected, virtual] |
Listens for mouse motion on the window and forwards the event to the listeners.
Relative mouse coordinates are calculated internally and passed on to the listeners.
| evt | The wxWidgets event that was generated |
| virtual void PWOgreBox::wxOgreControl::captureMouse | ( | wxMouseEvent & | evt | ) | [protected, virtual] |
Called when either the left, right, or middle mouse button is clicked. This captures the mouse so dragging outside the bounds of the control still directs input to the control, a common way of handling input.
This behavior can be disabled by calling Disconnect
| The | wxWidgets event that was generated |
| virtual void PWOgreBox::wxOgreControl::releaseMouse | ( | wxMouseEvent & | evt | ) | [protected, virtual] |
Called when either the left, right, or middle mouse button is release. This releases the mouse capture.
This behavior can be disabled by calling Disconnect
| The | wxWidgets event that was generated |
| virtual void PWOgreBox::wxOgreControl::onRenderTimer | ( | wxTimerEvent & | evt | ) | [protected, virtual] |
Called when the render timer expires. This updates the render window.
If an error occurs updating the render window an exception will be thrown and the render timer will be paused.
| evt | The wxWidgets event that was generated |
| virtual void PWOgreBox::wxOgreControl::destroy | ( | void | ) | [protected, virtual] |
Destroys the render window and the camera.
It is safe to call this function multiple times.
Ogre::RenderWindow* PWOgreBox::wxOgreControl::m_renderWindow [protected] |
The render window created for the control.
Ogre::Camera* PWOgreBox::wxOgreControl::m_camera [protected] |
The camera created for the control.
Ogre::Viewport* PWOgreBox::wxOgreControl::m_viewport [protected] |
The viewport that was created by adding the camera to the render window.
Ogre::SceneManager* PWOgreBox::wxOgreControl::m_sceneManager [protected] |
The scene manager used to create the camera used by this control.
wxTimer PWOgreBox::wxOgreControl::m_renderTimer [protected] |
The timer used to render.
int PWOgreBox::wxOgreControl::m_timerInterval [protected] |
The time interval used to render with.
bool PWOgreBox::wxOgreControl::m_paused [protected] |
Determines if the rendering is paused.
long const PWOgreBox::wxOgreControl::ID_RENDER_TIMER [protected] |
The wxWidgets ID of the render timer.
wxCoord PWOgreBox::wxOgreControl::m_lastX [protected] |
The last X position of the mouse, used for calculating relative mouse motion.
wxCoord PWOgreBox::wxOgreControl::m_lastY [protected] |
The last Y position of the mouse, used for calculating relative mouse motion.
int const PWOgreBox::wxOgreControl::DEFAULT_TIMER_INTERVAL [static, protected] |
The default interval for the render timer. The value is 33 milliseconds.
ListenerList PWOgreBox::wxOgreControl::m_listeners [protected] |
The listeners that listen for events of this control.
1.5.1