Main Page Namespace List Class Hierarchy Alphabetical List Compound List File List Namespace Members Compound Members File Members Related Pages

# Ogre::Viewport Class Reference

An abstraction of a viewport, i.e. More...

`#include <OgreViewport.h>`

List of all members.

## Public Methods

| Viewport (Camera *camera, RenderTarget *target, float left, float top, float width, float height, int ZOrder)
| The usual constructor.
| ~Viewport ()
| Default destructor.
void | _updateDimensions (void)
| Notifies the viewport of a possible change in dimensions.
void | update (void)
| Instructs the viewport to updates its contents.
RenderTarget * | getTarget (void) const
| Retrieves a pointer to the render target for this viewport.
Camera * | getCamera (void) const
| Retrieves a pointer to the camera for this viewport.
void | setCamera (Camera *cam)
| Sets the camera to use for rendering to this viewport.
int | getZOrder (void) const
| Gets the Z-Order of this viewport.
float | getLeft (void) const
| Gets one of the relative dimensions of the viewport, a value between 0.0 and 1.0.
float | getTop (void) const
| Gets one of the relative dimensions of the viewport, a value between 0.0 and 1.0.
float | getWidth (void) const
| Gets one of the relative dimensions of the viewport, a value between 0.0 and 1.0.
float | getHeight (void) const
| Gets one of the relative dimensions of the viewport, a value between 0.0 and 1.0.
int | getActualLeft (void) const
| Gets one of the actual dimensions of the viewport, a value in pixels.
int | getActualTop (void) const
| Gets one of the actual dimensions of the viewport, a value in pixels.
int | getActualWidth (void) const
| Gets one of the actual dimensions of the viewport, a value in pixels.
int | getActualHeight (void) const
| Gets one of the actual dimensions of the viewport, a value in pixels.
void | setDimensions (float left, float top, float width, float height)
| Sets the dimensions (after creation).
void | setBackgroundColour (const ColourValue &colour)
| Sets the initial background colour of the viewport (before rendering).
const ColourValue & | getBackgroundColour (void) const
| Gets the background colour.
void | setClearEveryFrame (bool clear)
| Determines whether to clear the viewport before rendering.
bool | getClearEveryFrame (void) const
| Determines if the viewport is cleared before every frame.
void | getActualDimensions (int &left, int &top, int &width, int &height) const
| Access to actual dimensions (based on target size).
bool | _isUpdated (void) const
void | _clearUpdatedFlag (void)
unsigned int | _getNumRenderedFaces (void) const
| Gets the number of rendered faces in the last update.
void | setOverlaysEnabled (bool enabled)
| Tells this viewport whether it should display Overlay objects.
bool | getOverlaysEnabled (void) const
| Returns whether or not Overlay objects (created in the SceneManager) are displayed in this viewport.

## Protected Attributes

Camera * | mCamera
RenderTarget * | mTarget
float | mRelLeft
float | mRelTop
float | mRelWidth
float | mRelHeight
int | mActLeft
int | mActTop
int | mActWidth
int | mActHeight
int | mZOrder
| ZOrder.
ColourValue | mBackColour
| Background options.
bool | mClearEveryFrame
bool | mUpdated
bool | mShowOverlays

## Detailed Description

An abstraction of a viewport, i.e.

a rendering region on a render target.

Remarks:
  A viewport is the meeting of a camera and a rendering surface - the camera renders the scene from a viewpoint, and places its results into some subset of a rendering target, which may be the whole surface or just a part of the surface. Each viewport has a single camera as source and a single target as destination. A camera only has 1 viewport, but a render target may have several. A viewport also has a Z-order, i.e. if there is more than one viewport on a single render target and they overlap, one must obscure the other in some predetermined way.

Definition at line 46 of file OgreViewport.h.

## Constructor & Destructor Documentation

Ogre::Viewport::Viewport | ( | Camera * | camera,
|  | RenderTarget * | target,
|  | float | left,
|  | float | top,
|  | float | width,
|  | float | height,
|  | int | ZOrder
| ) |

The usual constructor.

Parameters:

  cam | Pointer to a camera to be the source for the image.
  target | Pointer to the render target to be the destination for the rendering.
  left |
  top |
  width |
  height | Dimensions of the viewport, expressed as a value between 0 and 1. This allows the dimensions to apply irrespective of changes in the target's size: e.g. to fill the whole area, values of 0,0,1,1 are appropriate.
  ZOrder | Relative Z-order on the target. Lower = further to the front.

Ogre::Viewport::~Viewport | ( |  | ) |

| Default destructor. Definition at line 68 of file OgreViewport.cpp.

## Member Function Documentation

void Ogre::Viewport::_clearUpdatedFlag | ( | void |  | ) |

| Definition at line 78 of file OgreViewport.cpp. References mUpdated. Referenced by Ogre::GLRenderSystem::_setViewport(), Ogre::D3D9RenderSystem::_setViewport(), and Ogre::D3DRenderSystem::_setViewport().

unsigned int Ogre::Viewport::_getNumRenderedFaces | ( | void |  | ) | const

| Gets the number of rendered faces in the last update. Definition at line 215 of file OgreViewport.cpp. References Ogre::Camera::_getNumRenderedFaces(), and mCamera.

bool Ogre::Viewport::_isUpdated | ( | void |  | ) | const

| Definition at line 73 of file OgreViewport.cpp. References mUpdated. Referenced by Ogre::GLRenderSystem::_setViewport(), Ogre::D3D9RenderSystem::_setViewport(), and Ogre::D3DRenderSystem::_setViewport().

void Ogre::Viewport::_updateDimensions | ( | void |  | ) |

Notifies the viewport of a possible change in dimensions.

Remarks:
  Used by the target to update the viewport's dimensions (usually the result of a change in target size).

Note:
  Internal use by Ogre only.

Definition at line 83 of file OgreViewport.cpp.

References Ogre::Camera::getAutoAspectRatio(), Ogre::RenderTarget::getHeight(), Ogre::Camera::getName(), Ogre::RenderTarget::getWidth(), mActHeight, mActLeft, mActTop, mActWidth, mCamera, mRelHeight, mRelLeft, mRelTop, mRelWidth, mTarget, mUpdated, Ogre::Real, and Ogre::Frustum::setAspectRatio().

void Ogre::Viewport::getActualDimensions | ( | int & | left,
|  | int & | top,
|  | int & | width,
|  | int & | height
| ) | const

| Access to actual dimensions (based on target size). Definition at line 206 of file OgreViewport.cpp. References mActHeight, mActLeft, mActTop, and mActWidth. Referenced by Ogre::SceneManager::renderShadowVolumesToStencil().

int Ogre::Viewport::getActualHeight | ( | void |  | ) | const

Gets one of the actual dimensions of the viewport, a value in pixels.

Definition at line 163 of file OgreViewport.cpp.

References mActHeight.

Referenced by Ogre::TerrainRenderable::_calculateCFactor(), Ogre::OverlayManager::_queueOverlaysForRendering(), Ogre::GLRenderSystem::_setViewport(), Ogre::D3D9RenderSystem::_setViewport(), Ogre::D3DRenderSystem::_setViewport(), and Ogre::GLRenderSystem::setScissorTest().

int Ogre::Viewport::getActualLeft | ( | void |  | ) | const

| Gets one of the actual dimensions of the viewport, a value in pixels. Definition at line 148 of file OgreViewport.cpp. References mActLeft. Referenced by Ogre::GLRenderSystem::_setViewport(), Ogre::D3D9RenderSystem::_setViewport(), Ogre::D3DRenderSystem::_setViewport(), and Ogre::GLRenderSystem::setScissorTest().

int Ogre::Viewport::getActualTop | ( | void |  | ) | const

| Gets one of the actual dimensions of the viewport, a value in pixels. Definition at line 153 of file OgreViewport.cpp. References mActTop. Referenced by Ogre::GLRenderSystem::_setViewport(), Ogre::D3D9RenderSystem::_setViewport(), Ogre::D3DRenderSystem::_setViewport(), and Ogre::GLRenderSystem::setScissorTest().

int Ogre::Viewport::getActualWidth | ( | void |  | ) | const

| Gets one of the actual dimensions of the viewport, a value in pixels. Definition at line 158 of file OgreViewport.cpp. References mActWidth. Referenced by Ogre::OverlayManager::_queueOverlaysForRendering(), Ogre::GLRenderSystem::_setViewport(), Ogre::D3D9RenderSystem::_setViewport(), Ogre::D3DRenderSystem::_setViewport(), and Ogre::GLRenderSystem::setScissorTest().

const ColourValue & Ogre::Viewport::getBackgroundColour | ( | void |  | ) | const

| Gets the background colour. Definition at line 191 of file OgreViewport.cpp. References mBackColour. Referenced by Ogre::GLRenderSystem::_beginFrame(), Ogre::D3D9RenderSystem::_beginFrame(), and Ogre::D3DRenderSystem::_beginFrame().

Camera * Ogre::Viewport::getCamera | ( | void |  | ) | const

| Retrieves a pointer to the camera for this viewport. Definition at line 123 of file OgreViewport.cpp. References mCamera. Referenced by Ogre::RenderTarget::_notifyCameraRemoved(), Ogre::SceneManager::createShadowTextures(), Ogre::SceneManager::prepareShadowTextures(), and Ogre::SceneManager::renderModulativeTextureShadowedQueueGroupObjects().

bool Ogre::Viewport::getClearEveryFrame | ( | void |  | ) | const

| Determines if the viewport is cleared before every frame. Definition at line 201 of file OgreViewport.cpp. References mClearEveryFrame. Referenced by Ogre::GLRenderSystem::_beginFrame(), Ogre::D3D9RenderSystem::_beginFrame(), and Ogre::D3DRenderSystem::_beginFrame().

Real Ogre::Viewport::getHeight | ( | void |  | ) | const

| Gets one of the relative dimensions of the viewport, a value between 0.0 and 1.0. Definition at line 143 of file OgreViewport.cpp. References mRelHeight, and Ogre::Real.

Real Ogre::Viewport::getLeft | ( | void |  | ) | const

| Gets one of the relative dimensions of the viewport, a value between 0.0 and 1.0. Definition at line 128 of file OgreViewport.cpp. References mRelLeft, and Ogre::Real.

bool Ogre::Viewport::getOverlaysEnabled | ( | void |  | ) | const

| Returns whether or not Overlay objects (created in the SceneManager) are displayed in this viewport. Definition at line 231 of file OgreViewport.cpp. References mShowOverlays. Referenced by Ogre::SceneManager::_renderScene().

RenderTarget * Ogre::Viewport::getTarget | ( | void |  | ) | const

| Retrieves a pointer to the render target for this viewport. Definition at line 118 of file OgreViewport.cpp. References mTarget. Referenced by Ogre::SceneManager::_renderScene(), Ogre::GLRenderSystem::_setViewport(), Ogre::D3D9RenderSystem::_setViewport(), and Ogre::D3DRenderSystem::_setViewport().

Real Ogre::Viewport::getTop | ( | void |  | ) | const

| Gets one of the relative dimensions of the viewport, a value between 0.0 and 1.0. Definition at line 133 of file OgreViewport.cpp. References mRelTop, and Ogre::Real.

Real Ogre::Viewport::getWidth | ( | void |  | ) | const

| Gets one of the relative dimensions of the viewport, a value between 0.0 and 1.0. Definition at line 138 of file OgreViewport.cpp. References mRelWidth, and Ogre::Real.

int Ogre::Viewport::getZOrder | ( | void |  | ) | const

| Gets the Z-Order of this viewport. Definition at line 113 of file OgreViewport.cpp. References mZOrder.

void Ogre::Viewport::setBackgroundColour | ( | const ColourValue & | colour | ) |

| Sets the initial background colour of the viewport (before rendering). Definition at line 186 of file OgreViewport.cpp. References mBackColour. Referenced by Ogre::SceneManager::prepareShadowTextures().

void Ogre::Viewport::setCamera | ( | Camera * | cam | ) |

| Sets the camera to use for rendering to this viewport. Definition at line 220 of file OgreViewport.cpp. References mCamera. Referenced by Ogre::RenderTarget::_notifyCameraRemoved().

void Ogre::Viewport::setClearEveryFrame | ( | bool | clear | ) |

Determines whether to clear the viewport before rendering.

Remarks:
  If you expecting every pixel on the viewport to be redrawn every frame, you can save a little time by not clearing the viewport before every frame. Do so by passing 'false' to this method (the default is to clear every frame).

Definition at line 196 of file OgreViewport.cpp.

References mClearEveryFrame.

Referenced by Ogre::SceneManager::createShadowTextures().

void Ogre::Viewport::setDimensions | ( | float | left,
|  | float | top,
|  | float | width,
|  | float | height
| ) |

Sets the dimensions (after creation).

Parameters:

  left |
  top |
  width |
  height | Dimensions relative to the size of the target, represented as real values between 0 and 1. i.e. the full target area is 0, 0, 1, 1.

void Ogre::Viewport::setOverlaysEnabled | ( | bool | enabled | ) |

Tells this viewport whether it should display Overlay objects.

Remarks:
  Overlay objects are layers which appear on top of the scene. They are created via SceneManager::createOverlay and every viewport displays these by default. However, you probably don't want this if you're using multiple viewports, because one of them is probably a picture-in-picture which is not supposed to have overlays of it's own. In this case you can turn off overlays on this viewport by calling this method.

Parameters:

  enabled | If true, any overlays are displayed, if false they are not.

Definition at line 226 of file OgreViewport.cpp.

References mShowOverlays.

Referenced by Ogre::SceneManager::createShadowTextures().

void Ogre::Viewport::update | ( | void |  | ) |

| Instructs the viewport to updates its contents. Definition at line 177 of file OgreViewport.cpp. References Ogre::Camera::_renderScene(), mCamera, and mShowOverlays.

## Member Data Documentation

int Ogre::Viewport::mActHeight`[protected]`

| Definition at line 219 of file OgreViewport.h. Referenced by _updateDimensions(), getActualDimensions(), and getActualHeight().

int Ogre::Viewport::mActLeft`[protected]`

| Definition at line 219 of file OgreViewport.h. Referenced by _updateDimensions(), getActualDimensions(), and getActualLeft().

int Ogre::Viewport::mActTop`[protected]`

| Definition at line 219 of file OgreViewport.h. Referenced by _updateDimensions(), getActualDimensions(), and getActualTop().

int Ogre::Viewport::mActWidth`[protected]`

| Definition at line 219 of file OgreViewport.h. Referenced by _updateDimensions(), getActualDimensions(), and getActualWidth().

ColourValue Ogre::Viewport::mBackColour`[protected]`

| Background options. Definition at line 223 of file OgreViewport.h. Referenced by getBackgroundColour(), and setBackgroundColour().

Camera* Ogre::Viewport::mCamera`[protected]`

| Definition at line 214 of file OgreViewport.h. Referenced by _getNumRenderedFaces(), _updateDimensions(), getCamera(), setCamera(), and update().

bool Ogre::Viewport::mClearEveryFrame`[protected]`

| Definition at line 224 of file OgreViewport.h. Referenced by getClearEveryFrame(), and setClearEveryFrame().

float Ogre::Viewport::mRelHeight`[protected]`

| Definition at line 217 of file OgreViewport.h. Referenced by _updateDimensions(), and getHeight().

float Ogre::Viewport::mRelLeft`[protected]`

| Definition at line 217 of file OgreViewport.h. Referenced by _updateDimensions(), and getLeft().

float Ogre::Viewport::mRelTop`[protected]`

| Definition at line 217 of file OgreViewport.h. Referenced by _updateDimensions(), and getTop().

float Ogre::Viewport::mRelWidth`[protected]`

| Definition at line 217 of file OgreViewport.h. Referenced by _updateDimensions(), and getWidth().

bool Ogre::Viewport::mShowOverlays`[protected]`

| Definition at line 226 of file OgreViewport.h. Referenced by getOverlaysEnabled(), setOverlaysEnabled(), and update().

RenderTarget* Ogre::Viewport::mTarget`[protected]`

| Definition at line 215 of file OgreViewport.h. Referenced by _updateDimensions(), and getTarget().

bool Ogre::Viewport::mUpdated`[protected]`

| Definition at line 225 of file OgreViewport.h. Referenced by _clearUpdatedFlag(), _isUpdated(), and _updateDimensions().

int Ogre::Viewport::mZOrder`[protected]`

| ZOrder. Definition at line 221 of file OgreViewport.h. Referenced by getZOrder().

The documentation for this class was generated from the following files:

- OgreViewport.h
- OgreViewport.cpp

Copyright © 2002-2003 by The OGRE Team
Last modified Sun Nov 28 19:51:47 2004