[1809] | 1 | /*
|
---|
| 2 | -----------------------------------------------------------------------------
|
---|
| 3 | This source file is part of OGRE
|
---|
| 4 | (Object-oriented Graphics Rendering Engine)
|
---|
| 5 | For the latest info, see http://ogre.sourceforge.net/
|
---|
| 6 |
|
---|
| 7 | Copyright (c) 2000-2005 The OGRE Team
|
---|
| 8 | Also see acknowledgements in Readme.html
|
---|
| 9 |
|
---|
| 10 | This program is free software; you can redistribute it and/or modify it under
|
---|
| 11 | the terms of the GNU Lesser General Public License as published by the Free Software
|
---|
| 12 | Foundation; either version 2 of the License, or (at your option) any later
|
---|
| 13 | version.
|
---|
| 14 |
|
---|
| 15 | This program is distributed in the hope that it will be useful, but WITHOUT
|
---|
| 16 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
---|
| 17 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
---|
| 18 |
|
---|
| 19 | You should have received a copy of the GNU Lesser General Public License along with
|
---|
| 20 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
---|
| 21 | Place - Suite 330, Boston, MA 02111-1307, USA, or go to
|
---|
| 22 | http://www.gnu.org/copyleft/lesser.txt.
|
---|
| 23 | -----------------------------------------------------------------------------
|
---|
| 24 | */
|
---|
| 25 | #ifndef __RenderSystem_H_
|
---|
| 26 | #define __RenderSystem_H_
|
---|
| 27 |
|
---|
| 28 | // Precompiler options
|
---|
| 29 | #include "OgrePrerequisites.h"
|
---|
| 30 |
|
---|
| 31 | #include "OgreString.h"
|
---|
| 32 |
|
---|
| 33 | #include "OgreTextureUnitState.h"
|
---|
| 34 | #include "OgreCommon.h"
|
---|
| 35 |
|
---|
| 36 | #include "OgreRenderOperation.h"
|
---|
| 37 | #include "OgreRenderSystemCapabilities.h"
|
---|
| 38 | #include "OgreRenderTarget.h"
|
---|
| 39 | #include "OgreRenderTexture.h"
|
---|
| 40 | #include "OgreFrameListener.h"
|
---|
| 41 | #include "OgreConfigOptionMap.h"
|
---|
| 42 | #include "OgreGpuProgram.h"
|
---|
| 43 | #include "OgrePlane.h"
|
---|
| 44 | #include "OgreIteratorWrappers.h"
|
---|
| 45 |
|
---|
| 46 | namespace Ogre
|
---|
| 47 | {
|
---|
| 48 | typedef std::map< String, RenderTarget * > RenderTargetMap;
|
---|
| 49 | typedef std::multimap<uchar, RenderTarget * > RenderTargetPriorityMap;
|
---|
| 50 |
|
---|
| 51 | class TextureManager;
|
---|
| 52 | /// Enum describing the ways to generate texture coordinates
|
---|
| 53 | enum TexCoordCalcMethod
|
---|
| 54 | {
|
---|
| 55 | /// No calculated texture coordinates
|
---|
| 56 | TEXCALC_NONE,
|
---|
| 57 | /// Environment map based on vertex normals
|
---|
| 58 | TEXCALC_ENVIRONMENT_MAP,
|
---|
| 59 | /// Environment map based on vertex positions
|
---|
| 60 | TEXCALC_ENVIRONMENT_MAP_PLANAR,
|
---|
| 61 | TEXCALC_ENVIRONMENT_MAP_REFLECTION,
|
---|
| 62 | TEXCALC_ENVIRONMENT_MAP_NORMAL,
|
---|
| 63 | /// Projective texture
|
---|
| 64 | TEXCALC_PROJECTIVE_TEXTURE
|
---|
| 65 | };
|
---|
| 66 | /// Enum describing the various actions which can be taken onthe stencil buffer
|
---|
| 67 | enum StencilOperation
|
---|
| 68 | {
|
---|
| 69 | /// Leave the stencil buffer unchanged
|
---|
| 70 | SOP_KEEP,
|
---|
| 71 | /// Set the stencil value to zero
|
---|
| 72 | SOP_ZERO,
|
---|
| 73 | /// Set the stencil value to the reference value
|
---|
| 74 | SOP_REPLACE,
|
---|
| 75 | /// Increase the stencil value by 1, clamping at the maximum value
|
---|
| 76 | SOP_INCREMENT,
|
---|
| 77 | /// Decrease the stencil value by 1, clamping at 0
|
---|
| 78 | SOP_DECREMENT,
|
---|
| 79 | /// Increase the stencil value by 1, wrapping back to 0 when incrementing the maximum value
|
---|
| 80 | SOP_INCREMENT_WRAP,
|
---|
| 81 | /// Decrease the stencil value by 1, wrapping when decrementing 0
|
---|
| 82 | SOP_DECREMENT_WRAP,
|
---|
| 83 | /// Invert the bits of the stencil buffer
|
---|
| 84 | SOP_INVERT
|
---|
| 85 | };
|
---|
| 86 |
|
---|
| 87 | /** Defines the functionality of a 3D API
|
---|
| 88 | @remarks
|
---|
| 89 | The RenderSystem class provides a base interface
|
---|
| 90 | which abstracts the general functionality of the 3D API
|
---|
| 91 | e.g. Direct3D or OpenGL. Whilst a few of the general
|
---|
| 92 | methods have implementations, most of this class is
|
---|
| 93 | abstract, requiring a subclass based on a specific API
|
---|
| 94 | to be constructed to provide the full functionality.
|
---|
| 95 | Note there are 2 levels to the interface - one which
|
---|
| 96 | will be used often by the caller of the Ogre library,
|
---|
| 97 | and one which is at a lower level and will be used by the
|
---|
| 98 | other classes provided by Ogre. These lower level
|
---|
| 99 | methods are prefixed with '_' to differentiate them.
|
---|
| 100 | The advanced user of the library may use these lower
|
---|
| 101 | level methods to access the 3D API at a more fundamental
|
---|
| 102 | level (dealing direct with render states and rendering
|
---|
| 103 | primitives), but still benefitting from Ogre's abstraction
|
---|
| 104 | of exactly which 3D API is in use.
|
---|
| 105 | @author
|
---|
| 106 | Steven Streeting
|
---|
| 107 | @version
|
---|
| 108 | 1.0
|
---|
| 109 | */
|
---|
| 110 | class _OgreExport RenderSystem
|
---|
| 111 | {
|
---|
| 112 | public:
|
---|
| 113 | /** Default Constructor.
|
---|
| 114 | */
|
---|
| 115 | RenderSystem();
|
---|
| 116 |
|
---|
| 117 | /** Destructor.
|
---|
| 118 | */
|
---|
| 119 | virtual ~RenderSystem();
|
---|
| 120 |
|
---|
| 121 | /** Returns the name of the rendering system.
|
---|
| 122 | */
|
---|
| 123 | virtual const String& getName(void) const = 0;
|
---|
| 124 |
|
---|
| 125 | /** Returns the details of this API's configuration options
|
---|
| 126 | @remarks
|
---|
| 127 | Each render system must be able to inform the world
|
---|
| 128 | of what options must/can be specified for it's
|
---|
| 129 | operation.
|
---|
| 130 | @par
|
---|
| 131 | These are passed as strings for portability, but
|
---|
| 132 | grouped into a structure (_ConfigOption) which includes
|
---|
| 133 | both options and current value.
|
---|
| 134 | @par
|
---|
| 135 | Note that the settings returned from this call are
|
---|
| 136 | affected by the options that have been set so far,
|
---|
| 137 | since some options are interdependent.
|
---|
| 138 | @par
|
---|
| 139 | This routine is called automatically by the default
|
---|
| 140 | configuration dialogue produced by Root::showConfigDialog
|
---|
| 141 | or may be used by the caller for custom settings dialogs
|
---|
| 142 | @returns
|
---|
| 143 | A 'map' of options, i.e. a list of options which is also
|
---|
| 144 | indexed by option name.
|
---|
| 145 | */
|
---|
| 146 | virtual ConfigOptionMap& getConfigOptions(void) = 0;
|
---|
| 147 |
|
---|
| 148 | /** Sets an option for this API
|
---|
| 149 | @remarks
|
---|
| 150 | Used to confirm the settings (normally chosen by the user) in
|
---|
| 151 | order to make the renderer able to initialise with the settings as required.
|
---|
| 152 | This may be video mode, D3D driver, full screen / windowed etc.
|
---|
| 153 | Called automatically by the default configuration
|
---|
| 154 | dialog, and by the restoration of saved settings.
|
---|
| 155 | These settings are stored and only activated when
|
---|
| 156 | RenderSystem::initialise or RenderSystem::reinitialise
|
---|
| 157 | are called.
|
---|
| 158 | @par
|
---|
| 159 | If using a custom configuration dialog, it is advised that the
|
---|
| 160 | caller calls RenderSystem::getConfigOptions
|
---|
| 161 | again, since some options can alter resulting from a selection.
|
---|
| 162 | @param
|
---|
| 163 | name The name of the option to alter.
|
---|
| 164 | @param
|
---|
| 165 | value The value to set the option to.
|
---|
| 166 | */
|
---|
| 167 | virtual void setConfigOption(const String &name, const String &value) = 0;
|
---|
| 168 |
|
---|
| 169 | /** Create an object for performing hardware occlusion queries.
|
---|
| 170 | */
|
---|
| 171 | virtual HardwareOcclusionQuery* createHardwareOcclusionQuery(void) = 0;
|
---|
| 172 |
|
---|
| 173 | /** Destroy a hardware occlusion query object.
|
---|
| 174 | */
|
---|
| 175 | virtual void destroyHardwareOcclusionQuery(HardwareOcclusionQuery *hq);
|
---|
| 176 |
|
---|
| 177 | /** Validates the options set for the rendering system, returning a message if there are problems.
|
---|
| 178 | @note
|
---|
| 179 | If the returned string is empty, there are no problems.
|
---|
| 180 | */
|
---|
| 181 | virtual String validateConfigOptions(void) = 0;
|
---|
| 182 |
|
---|
| 183 | /** Start up the renderer using the settings selected (Or the defaults if none have been selected).
|
---|
| 184 | @remarks
|
---|
| 185 | Called by Root::setRenderSystem. Shouldn't really be called
|
---|
| 186 | directly, although this can be done if the app wants to.
|
---|
| 187 | @param
|
---|
| 188 | autoCreateWindow If true, creates a render window
|
---|
| 189 | automatically, based on settings chosen so far. This saves
|
---|
| 190 | an extra call to RenderSystem::createRenderWindow
|
---|
| 191 | for the main render window.
|
---|
| 192 | @par
|
---|
| 193 | If an application has more specific window requirements,
|
---|
| 194 | however (e.g. a level design app), it should specify false
|
---|
| 195 | for this parameter and do it manually.
|
---|
| 196 | @returns
|
---|
| 197 | A pointer to the automatically created window, if requested, otherwise null.
|
---|
| 198 | */
|
---|
| 199 | virtual RenderWindow* initialise(bool autoCreateWindow, const String& windowTitle = "OGRE Render Window");
|
---|
| 200 |
|
---|
| 201 | /** Restart the renderer (normally following a change in settings).
|
---|
| 202 | */
|
---|
| 203 | virtual void reinitialise(void) = 0;
|
---|
| 204 |
|
---|
| 205 | /** Shutdown the renderer and cleanup resources.
|
---|
| 206 | */
|
---|
| 207 | virtual void shutdown(void);
|
---|
| 208 |
|
---|
| 209 |
|
---|
| 210 | /** Sets the colour & strength of the ambient (global directionless) light in the world.
|
---|
| 211 | */
|
---|
| 212 | virtual void setAmbientLight(float r, float g, float b) = 0;
|
---|
| 213 |
|
---|
| 214 | /** Sets the type of light shading required (default = Gouraud).
|
---|
| 215 | */
|
---|
| 216 | virtual void setShadingType(ShadeOptions so) = 0;
|
---|
| 217 |
|
---|
| 218 | /** Sets whether or not dynamic lighting is enabled.
|
---|
| 219 | @param
|
---|
| 220 | enabled If true, dynamic lighting is performed on geometry with normals supplied, geometry without
|
---|
| 221 | normals will not be displayed. If false, no lighting is applied and all geometry will be full brightness.
|
---|
| 222 | */
|
---|
| 223 | virtual void setLightingEnabled(bool enabled) = 0;
|
---|
| 224 |
|
---|
| 225 | /** Sets whether or not W-buffers are enabled if they are avalible for this renderer.
|
---|
| 226 | @param
|
---|
| 227 | enabled If true and the renderer supports them W-buffers will be used. If false
|
---|
| 228 | W-buffers will not be used even if avalible. W-buffers are enabled by default
|
---|
| 229 | for 16bit depth buffers and disabled for all other depths.
|
---|
| 230 | */
|
---|
| 231 | void setWBufferEnabled(bool enabled);
|
---|
| 232 |
|
---|
| 233 | /** Returns true if the renderer will try to use W-buffers when avalible.
|
---|
| 234 | */
|
---|
| 235 | bool getWBufferEnabled(void) const;
|
---|
| 236 |
|
---|
| 237 | /** Creates a new rendering window.
|
---|
| 238 | @remarks
|
---|
| 239 | This method creates a new rendering window as specified
|
---|
| 240 | by the paramteters. The rendering system could be
|
---|
| 241 | responible for only a single window (e.g. in the case
|
---|
| 242 | of a game), or could be in charge of multiple ones (in the
|
---|
| 243 | case of a level editor). The option to create the window
|
---|
| 244 | as a child of another is therefore given.
|
---|
| 245 | This method will create an appropriate subclass of
|
---|
| 246 | RenderWindow depending on the API and platform implementation.
|
---|
| 247 | @par
|
---|
| 248 | After creation, this window can be retrieved using getRenderTarget().
|
---|
| 249 | @param
|
---|
| 250 | name The name of the window. Used in other methods
|
---|
| 251 | later like setRenderTarget and getRenderWindow.
|
---|
| 252 | @param
|
---|
| 253 | width The width of the new window.
|
---|
| 254 | @param
|
---|
| 255 | height The height of the new window.
|
---|
| 256 | @param
|
---|
| 257 | fullScreen Specify true to make the window full screen
|
---|
| 258 | without borders, title bar or menu bar.
|
---|
| 259 | @param
|
---|
| 260 | miscParams A NameValuePairList describing the other parameters for the new rendering window.
|
---|
| 261 | Options are case sensitive. Unrecognised parameters will be ignored silently.
|
---|
| 262 | These values might be platform dependent, but these are present for all platorms unless
|
---|
| 263 | indicated otherwise:
|
---|
| 264 | **
|
---|
| 265 | Key: "title"
|
---|
| 266 | Description: The title of the window that will appear in the title bar
|
---|
| 267 | Values: string
|
---|
| 268 | Default: RenderTarget name
|
---|
| 269 | **
|
---|
| 270 | Key: "colourDepth"
|
---|
| 271 | Description: Colour depth of the resulting rendering window; only applies if fullScreen
|
---|
| 272 | is set.
|
---|
| 273 | Values: 16 or 32
|
---|
| 274 | Default: desktop depth
|
---|
| 275 | Notes: [W32 specific]
|
---|
| 276 | **
|
---|
| 277 | Key: "left"
|
---|
| 278 | Description: screen x coordinate from left
|
---|
| 279 | Values: positive integers
|
---|
| 280 | Default: 'center window on screen'
|
---|
| 281 | Notes: Ignored in case of full screen
|
---|
| 282 | **
|
---|
| 283 | Key: "top"
|
---|
| 284 | Description: screen y coordinate from top
|
---|
| 285 | Values: positive integers
|
---|
| 286 | Default: 'center window on screen'
|
---|
| 287 | Notes: Ignored in case of full screen
|
---|
| 288 | **
|
---|
| 289 | Key: "depthBuffer" [DX9 specific]
|
---|
| 290 | Description: Use depth buffer
|
---|
| 291 | Values: false or true
|
---|
| 292 | Default: true
|
---|
| 293 | **
|
---|
| 294 | Key: "externalWindowHandle" [API specific]
|
---|
| 295 | Description: External window handle, for embedding the OGRE context
|
---|
| 296 | Values: positive integer for W32 (HWND handle)
|
---|
| 297 | poslong:posint:poslong (display*:screen:windowHandle) or
|
---|
| 298 | poslong:posint:poslong:poslong (display*:screen:windowHandle:XVisualInfo*) for GLX
|
---|
| 299 | Default: 0 (None)
|
---|
| 300 | **
|
---|
| 301 | Key: "parentWindowHandle" [API specific]
|
---|
| 302 | Description: Parent window handle, for embedding the OGRE context
|
---|
| 303 | Values: positive integer for W32 (HWND handle)
|
---|
| 304 | poslong:posint:poslong for GLX (display*:screen:windowHandle)
|
---|
| 305 | Default: 0 (None)
|
---|
| 306 | **
|
---|
| 307 | Key: "FSAA"
|
---|
| 308 | Description: Full screen antialiasing factor
|
---|
| 309 | Values: 0,2,4,6,...
|
---|
| 310 | Default: 0
|
---|
| 311 | **
|
---|
| 312 | Key: "displayFrequency"
|
---|
| 313 | Description: Display frequency rate, for fullscreen mode
|
---|
| 314 | Values: 60...?
|
---|
| 315 | Default: Desktop vsync rate
|
---|
| 316 | **
|
---|
| 317 | Key: "vsync"
|
---|
| 318 | Description: Synchronize buffer swaps to vsync
|
---|
| 319 | Values: true, false
|
---|
| 320 | Default: 0
|
---|
| 321 | **
|
---|
| 322 | Key: "border"
|
---|
| 323 | Description: The type of window border (in windowed mode)
|
---|
| 324 | Values: none, fixed, resize
|
---|
| 325 | Default: resize
|
---|
| 326 | **
|
---|
| 327 | Key: "outerDimensions"
|
---|
| 328 | Description: Whether the width/height is expressed as the size of the
|
---|
| 329 | outer window, rather than the content area
|
---|
| 330 | Values: true, false
|
---|
| 331 | Default: false
|
---|
| 332 | **
|
---|
| 333 | Key: "useNVPerfHUD" [DX9 specific]
|
---|
| 334 | Description: Enable the use of nVidia NVPerfHUD
|
---|
| 335 | Values: true, false
|
---|
| 336 | Default: false
|
---|
| 337 | */
|
---|
| 338 | virtual RenderWindow* createRenderWindow(const String &name, unsigned int width, unsigned int height,
|
---|
| 339 | bool fullScreen, const NameValuePairList *miscParams = 0) = 0;
|
---|
| 340 |
|
---|
| 341 | /** Creates and registers a render texture object.
|
---|
| 342 | @param name
|
---|
| 343 | The name for the new render texture. Note that names must be unique.
|
---|
| 344 | @param width
|
---|
| 345 | The requested width for the render texture. See Remarks for more info.
|
---|
| 346 | @param height
|
---|
| 347 | The requested width for the render texture. See Remarks for more info.
|
---|
| 348 | @param texType
|
---|
| 349 | The type of texture; defaults to TEX_TYPE_2D
|
---|
| 350 | @param internalFormat
|
---|
| 351 | The internal format of the texture; defaults to PF_X8R8G8B8
|
---|
| 352 | @param miscParams This parameter is ignored.
|
---|
| 353 | @returns
|
---|
| 354 | On succes, a pointer to a new platform-dependernt, RenderTexture-derived
|
---|
| 355 | class is returned. On failiure, NULL is returned.
|
---|
| 356 | @remarks
|
---|
| 357 | Because a render texture is basically a wrapper around a texture object,
|
---|
| 358 | the width and height parameters of this method just hint the preferred
|
---|
| 359 | size for the texture. Depending on the hardware driver or the underlying
|
---|
| 360 | API, these values might change when the texture is created. The same applies
|
---|
| 361 | to the internalFormat parameter.
|
---|
| 362 | @deprecated
|
---|
| 363 | This method is deprecated, and exists only for backward compatibility. You can create
|
---|
| 364 | arbitrary rendertextures with the TextureManager::createManual call with usage
|
---|
| 365 | TU_RENDERTEXTURE.
|
---|
| 366 | */
|
---|
| 367 | RenderTexture * createRenderTexture( const String & name, unsigned int width, unsigned int height,
|
---|
| 368 | TextureType texType = TEX_TYPE_2D, PixelFormat internalFormat = PF_X8R8G8B8,
|
---|
| 369 | const NameValuePairList *miscParams = 0 );
|
---|
| 370 |
|
---|
| 371 | /** Create a MultiRenderTarget, which is a render target that renders to multiple RenderTextures
|
---|
| 372 | at once. Surfaces can be bound and unbound at will.
|
---|
| 373 | This fails if mCapabilities->numMultiRenderTargets() is smaller than 2.
|
---|
| 374 | */
|
---|
| 375 | virtual MultiRenderTarget * createMultiRenderTarget(const String & name) = 0;
|
---|
| 376 |
|
---|
| 377 | /** Destroys a render window */
|
---|
| 378 | virtual void destroyRenderWindow(const String& name);
|
---|
| 379 | /** Destroys a render texture */
|
---|
| 380 | virtual void destroyRenderTexture(const String& name);
|
---|
| 381 | /** Destroys a render target of any sort */
|
---|
| 382 | virtual void destroyRenderTarget(const String& name);
|
---|
| 383 |
|
---|
| 384 | /** Attaches the passed render target to the render system.
|
---|
| 385 | */
|
---|
| 386 | virtual void attachRenderTarget( RenderTarget &target );
|
---|
| 387 | /** Returns a pointer to the render target with the passed name, or NULL if that
|
---|
| 388 | render target cannot be found.
|
---|
| 389 | */
|
---|
| 390 | virtual RenderTarget * getRenderTarget( const String &name );
|
---|
| 391 | /** Detaches the render target with the passed name from the render system and
|
---|
| 392 | returns a pointer to it.
|
---|
| 393 | @note
|
---|
| 394 | If the render target cannot be found, NULL is returned.
|
---|
| 395 | */
|
---|
| 396 | virtual RenderTarget * detachRenderTarget( const String &name );
|
---|
| 397 |
|
---|
| 398 | /// Iterator over RenderTargets
|
---|
| 399 | typedef MapIterator<Ogre::RenderTargetMap> RenderTargetIterator;
|
---|
| 400 |
|
---|
| 401 | /** Returns a specialised MapIterator over all render targets attached to the RenderSystem. */
|
---|
| 402 | virtual RenderTargetIterator getRenderTargetIterator(void) {
|
---|
| 403 | return RenderTargetIterator( mRenderTargets.begin(), mRenderTargets.end() );
|
---|
| 404 | }
|
---|
| 405 | /** Returns a description of an error code.
|
---|
| 406 | */
|
---|
| 407 | virtual String getErrorDescription(long errorNumber) const = 0;
|
---|
| 408 |
|
---|
| 409 | /** Defines whether or now fullscreen render windows wait for the vertical blank before flipping buffers.
|
---|
| 410 | @remarks
|
---|
| 411 | By default, all rendering windows wait for a vertical blank (when the CRT beam turns off briefly to move
|
---|
| 412 | from the bottom right of the screen back to the top left) before flipping the screen buffers. This ensures
|
---|
| 413 | that the image you see on the screen is steady. However it restricts the frame rate to the refresh rate of
|
---|
| 414 | the monitor, and can slow the frame rate down. You can speed this up by not waiting for the blank, but
|
---|
| 415 | this has the downside of introducing 'tearing' artefacts where part of the previous frame is still displayed
|
---|
| 416 | as the buffers are switched. Speed vs quality, you choose.
|
---|
| 417 | @note
|
---|
| 418 | Has NO effect on windowed mode render targets. Only affects fullscreen mode.
|
---|
| 419 | @param
|
---|
| 420 | enabled If true, the system waits for vertical blanks - quality over speed. If false it doesn't - speed over quality.
|
---|
| 421 | */
|
---|
| 422 | void setWaitForVerticalBlank(bool enabled);
|
---|
| 423 |
|
---|
| 424 | /** Returns true if the system is synchronising frames with the monitor vertical blank.
|
---|
| 425 | */
|
---|
| 426 | bool getWaitForVerticalBlank(void) const;
|
---|
| 427 |
|
---|
| 428 | // ------------------------------------------------------------------------
|
---|
| 429 | // Internal Rendering Access
|
---|
| 430 | // All methods below here are normally only called by other OGRE classes
|
---|
| 431 | // They can be called by library user if required
|
---|
| 432 | // ------------------------------------------------------------------------
|
---|
| 433 |
|
---|
| 434 |
|
---|
| 435 | /** Tells the rendersystem to use the attached set of lights (and no others)
|
---|
| 436 | up to the number specified (this allows the same list to be used with different
|
---|
| 437 | count limits) */
|
---|
| 438 | virtual void _useLights(const LightList& lights, unsigned short limit) = 0;
|
---|
| 439 | /** Sets the world transform matrix. */
|
---|
| 440 | virtual void _setWorldMatrix(const Matrix4 &m) = 0;
|
---|
| 441 | /** Sets multiple world matrices (vertex blending). */
|
---|
| 442 | virtual void _setWorldMatrices(const Matrix4* m, unsigned short count);
|
---|
| 443 | /** Sets the view transform matrix */
|
---|
| 444 | virtual void _setViewMatrix(const Matrix4 &m) = 0;
|
---|
| 445 | /** Sets the projection transform matrix */
|
---|
| 446 | virtual void _setProjectionMatrix(const Matrix4 &m) = 0;
|
---|
| 447 | /** Utility function for setting all the properties of a texture unit at once.
|
---|
| 448 | This method is also worth using over the individual texture unit settings because it
|
---|
| 449 | only sets those settings which are different from the current settings for this
|
---|
| 450 | unit, thus minimising render state changes.
|
---|
| 451 | */
|
---|
| 452 | virtual void _setTextureUnitSettings(size_t texUnit, TextureUnitState& tl);
|
---|
| 453 | /** Turns off a texture unit. */
|
---|
| 454 | virtual void _disableTextureUnit(size_t texUnit);
|
---|
| 455 | /** Disables all texture units from the given unit upwards */
|
---|
| 456 | virtual void _disableTextureUnitsFrom(size_t texUnit);
|
---|
| 457 | /** Sets the surface properties to be used for future rendering.
|
---|
| 458 |
|
---|
| 459 | This method sets the the properties of the surfaces of objects
|
---|
| 460 | to be rendered after it. In this context these surface properties
|
---|
| 461 | are the amount of each type of light the object reflects (determining
|
---|
| 462 | it's colour under different types of light), whether it emits light
|
---|
| 463 | itself, and how shiny it is. Textures are not dealt with here,
|
---|
| 464 | see the _setTetxure method for details.
|
---|
| 465 | This method is used by _setMaterial so does not need to be called
|
---|
| 466 | direct if that method is being used.
|
---|
| 467 |
|
---|
| 468 | @param ambient The amount of ambient (sourceless and directionless)
|
---|
| 469 | light an object reflects. Affected by the colour/amount of ambient light in the scene.
|
---|
| 470 | @param diffuse The amount of light from directed sources that is
|
---|
| 471 | reflected (affected by colour/amount of point, directed and spot light sources)
|
---|
| 472 | @param specular The amount of specular light reflected. This is also
|
---|
| 473 | affected by directed light sources but represents the colour at the
|
---|
| 474 | highlights of the object.
|
---|
| 475 | @param emissive The colour of light emitted from the object. Note that
|
---|
| 476 | this will make an object seem brighter and not dependent on lights in
|
---|
| 477 | the scene, but it will not act as a light, so will not illuminate other
|
---|
| 478 | objects. Use a light attached to the same SceneNode as the object for this purpose.
|
---|
| 479 | @param shininess A value which only has an effect on specular highlights (so
|
---|
| 480 | specular must be non-black). The higher this value, the smaller and crisper the
|
---|
| 481 | specular highlights will be, imitating a more highly polished surface.
|
---|
| 482 | This value is not constrained to 0.0-1.0, in fact it is likely to
|
---|
| 483 | be more (10.0 gives a modest sheen to an object).
|
---|
| 484 | @param tracking A bit field that describes which of the ambient, diffuse, specular
|
---|
| 485 | and emissive colours follow the vertex colour of the primitive. When a bit in this field is set
|
---|
| 486 | its ColourValue is ignored. This is a combination of TVC_AMBIENT, TVC_DIFFUSE, TVC_SPECULAR(note that the shininess value is still
|
---|
| 487 | taken from shininess) and TVC_EMISSIVE. TVC_NONE means that there will be no material property
|
---|
| 488 | tracking the vertex colours.
|
---|
| 489 | */
|
---|
| 490 | virtual void _setSurfaceParams(const ColourValue &ambient,
|
---|
| 491 | const ColourValue &diffuse, const ColourValue &specular,
|
---|
| 492 | const ColourValue &emissive, Real shininess,
|
---|
| 493 | TrackVertexColourType tracking = TVC_NONE) = 0;
|
---|
| 494 |
|
---|
| 495 | /** Sets whether or not rendering points using OT_POINT_LIST will
|
---|
| 496 | render point sprites (textured quads) or plain points.
|
---|
| 497 | @param enabled True enables point sprites, false returns to normal
|
---|
| 498 | point rendering.
|
---|
| 499 | */
|
---|
| 500 | virtual void _setPointSpritesEnabled(bool enabled) = 0;
|
---|
| 501 |
|
---|
| 502 | /** Sets the size of points and how they are attenuated with distance.
|
---|
| 503 | @remarks
|
---|
| 504 | When performing point rendering or point sprite rendering,
|
---|
| 505 | point size can be attenuated with distance. The equation for
|
---|
| 506 | doing this is attenuation = 1 / (constant + linear * dist + quadratic * d^2) .
|
---|
| 507 | @par
|
---|
| 508 | For example, to disable distance attenuation (constant screensize)
|
---|
| 509 | you would set constant to 1, and linear and quadratic to 0. A
|
---|
| 510 | standard perspective attenuation would be 0, 1, 0 respectively.
|
---|
| 511 | */
|
---|
| 512 | virtual void _setPointParameters(Real size, bool attenuationEnabled,
|
---|
| 513 | Real constant, Real linear, Real quadratic, Real minSize, Real maxSize) = 0;
|
---|
| 514 |
|
---|
| 515 |
|
---|
| 516 | /**
|
---|
| 517 | Sets the status of a single texture stage.
|
---|
| 518 |
|
---|
| 519 | Sets the details of a texture stage, to be used for all primitives
|
---|
| 520 | rendered afterwards. User processes would
|
---|
| 521 | not normally call this direct unless rendering
|
---|
| 522 | primitives themselves - the SubEntity class
|
---|
| 523 | is designed to manage materials for objects.
|
---|
| 524 | Note that this method is called by _setMaterial.
|
---|
| 525 |
|
---|
| 526 | @param unit The index of the texture unit to modify. Multitexturing hardware
|
---|
| 527 | can support multiple units (see RenderSystemCapabilites::numTextureUnits)
|
---|
| 528 | @param enabled Boolean to turn the unit on/off
|
---|
| 529 | @param texname The name of the texture to use - this should have
|
---|
| 530 | already been loaded with TextureManager::load.
|
---|
| 531 | */
|
---|
| 532 | virtual void _setTexture(size_t unit, bool enabled, const String &texname) = 0;
|
---|
| 533 |
|
---|
| 534 | /**
|
---|
| 535 | Sets the texture coordinate set to use for a texture unit.
|
---|
| 536 |
|
---|
| 537 | Meant for use internally - not generally used directly by apps - the Material and TextureUnitState
|
---|
| 538 | classes let you manage textures far more easily.
|
---|
| 539 |
|
---|
| 540 | @param unit Texture unit as above
|
---|
| 541 | @param index The index of the texture coordinate set to use.
|
---|
| 542 | */
|
---|
| 543 | virtual void _setTextureCoordSet(size_t unit, size_t index) = 0;
|
---|
| 544 |
|
---|
| 545 | /**
|
---|
| 546 | Sets a method for automatically calculating texture coordinates for a stage.
|
---|
| 547 | Should not be used by apps - for use by Ogre only.
|
---|
| 548 | @param unit Texture unit as above
|
---|
| 549 | @param m Calculation method to use
|
---|
| 550 | @param frustum Optional Frustum param, only used for projective effects
|
---|
| 551 | */
|
---|
| 552 | virtual void _setTextureCoordCalculation(size_t unit, TexCoordCalcMethod m,
|
---|
| 553 | const Frustum* frustum = 0) = 0;
|
---|
| 554 |
|
---|
| 555 | /** Sets the texture blend modes from a TextureUnitState record.
|
---|
| 556 | Meant for use internally only - apps should use the Material
|
---|
| 557 | and TextureUnitState classes.
|
---|
| 558 | @param unit Texture unit as above
|
---|
| 559 | @param bm Details of the blending mode
|
---|
| 560 | */
|
---|
| 561 | virtual void _setTextureBlendMode(size_t unit, const LayerBlendModeEx& bm) = 0;
|
---|
| 562 |
|
---|
| 563 | /** Sets the filtering options for a given texture unit.
|
---|
| 564 | @param unit The texture unit to set the filtering options for
|
---|
| 565 | @param minFilter The filter used when a texture is reduced in size
|
---|
| 566 | @param magFilter The filter used when a texture is magnified
|
---|
| 567 | @param mipFilter The filter used between mipmap levels, FO_NONE disables mipmapping
|
---|
| 568 | */
|
---|
| 569 | virtual void _setTextureUnitFiltering(size_t unit, FilterOptions minFilter,
|
---|
| 570 | FilterOptions magFilter, FilterOptions mipFilter);
|
---|
| 571 |
|
---|
| 572 | /** Sets a single filter for a given texture unit.
|
---|
| 573 | @param unit The texture unit to set the filtering options for
|
---|
| 574 | @param ftype The filter type
|
---|
| 575 | @param filter The filter to be used
|
---|
| 576 | */
|
---|
| 577 | virtual void _setTextureUnitFiltering(size_t unit, FilterType ftype, FilterOptions filter) = 0;
|
---|
| 578 |
|
---|
| 579 | /** Sets the maximal anisotropy for the specified texture unit.*/
|
---|
| 580 | virtual void _setTextureLayerAnisotropy(size_t unit, unsigned int maxAnisotropy) = 0;
|
---|
| 581 |
|
---|
| 582 | /** Sets the texture addressing mode for a texture unit.*/
|
---|
| 583 | virtual void _setTextureAddressingMode(size_t unit, const TextureUnitState::UVWAddressingMode& uvw) = 0;
|
---|
| 584 |
|
---|
| 585 | /** Sets the texture border colour for a texture unit.*/
|
---|
| 586 | virtual void _setTextureBorderColour(size_t unit, const ColourValue& colour) = 0;
|
---|
| 587 |
|
---|
| 588 | /** Sets the texture coordinate transformation matrix for a texture unit.
|
---|
| 589 | @param unit Texture unit to affect
|
---|
| 590 | @param xform The 4x4 matrix
|
---|
| 591 | */
|
---|
| 592 | virtual void _setTextureMatrix(size_t unit, const Matrix4& xform) = 0;
|
---|
| 593 |
|
---|
| 594 | /** Sets the global blending factors for combining subsequent renders with the existing frame contents.
|
---|
| 595 | The result of the blending operation is:</p>
|
---|
| 596 | <p align="center">final = (texture * sourceFactor) + (pixel * destFactor)</p>
|
---|
| 597 | Each of the factors is specified as one of a number of options, as specified in the SceneBlendFactor
|
---|
| 598 | enumerated type.
|
---|
| 599 | @param sourceFactor The source factor in the above calculation, i.e. multiplied by the texture colour components.
|
---|
| 600 | @param destFactor The destination factor in the above calculation, i.e. multiplied by the pixel colour components.
|
---|
| 601 | */
|
---|
| 602 | virtual void _setSceneBlending(SceneBlendFactor sourceFactor, SceneBlendFactor destFactor) = 0;
|
---|
| 603 |
|
---|
| 604 | /** Sets the global alpha rejection approach for future renders.
|
---|
| 605 | By default images are rendered regardless of texture alpha. This method lets you change that.
|
---|
| 606 | @param func The comparison function which must pass for a pixel to be written.
|
---|
| 607 | @param val The value to compare each pixels alpha value to (0-255)
|
---|
| 608 | */
|
---|
| 609 | virtual void _setAlphaRejectSettings(CompareFunction func, unsigned char value) = 0;
|
---|
| 610 | /**
|
---|
| 611 | * Signifies the beginning of a frame, ie the start of rendering on a single viewport. Will occur
|
---|
| 612 | * several times per complete frame if multiple viewports exist.
|
---|
| 613 | */
|
---|
| 614 | virtual void _beginFrame(void) = 0;
|
---|
| 615 |
|
---|
| 616 |
|
---|
| 617 | /**
|
---|
| 618 | * Ends rendering of a frame to the current viewport.
|
---|
| 619 | */
|
---|
| 620 | virtual void _endFrame(void) = 0;
|
---|
| 621 | /**
|
---|
| 622 | Sets the provided viewport as the active one for future
|
---|
| 623 | rendering operations. This viewport is aware of it's own
|
---|
| 624 | camera and render target. Must be implemented by subclass.
|
---|
| 625 |
|
---|
| 626 | @param target Pointer to the appropriate viewport.
|
---|
| 627 | */
|
---|
| 628 | virtual void _setViewport(Viewport *vp) = 0;
|
---|
| 629 | /** Get the current active viewport for rendering. */
|
---|
| 630 | virtual Viewport* _getViewport(void);
|
---|
| 631 |
|
---|
| 632 | /** Sets the culling mode for the render system based on the 'vertex winding'.
|
---|
| 633 | A typical way for the rendering engine to cull triangles is based on the
|
---|
| 634 | 'vertex winding' of triangles. Vertex winding refers to the direction in
|
---|
| 635 | which the vertices are passed or indexed to in the rendering operation as viewed
|
---|
| 636 | from the camera, and will wither be clockwise or anticlockwise (that's 'counterclockwise' for
|
---|
| 637 | you Americans out there ;) The default is CULL_CLOCKWISE i.e. that only triangles whose vertices
|
---|
| 638 | are passed/indexed in anticlockwise order are rendered - this is a common approach and is used in 3D studio models
|
---|
| 639 | for example. You can alter this culling mode if you wish but it is not advised unless you know what you are doing.
|
---|
| 640 | You may wish to use the CULL_NONE option for mesh data that you cull yourself where the vertex
|
---|
| 641 | winding is uncertain.
|
---|
| 642 | */
|
---|
| 643 | virtual void _setCullingMode(CullingMode mode) = 0;
|
---|
| 644 |
|
---|
| 645 | virtual CullingMode _getCullingMode(void) const;
|
---|
| 646 |
|
---|
| 647 | /** Sets the mode of operation for depth buffer tests from this point onwards.
|
---|
| 648 | Sometimes you may wish to alter the behaviour of the depth buffer to achieve
|
---|
| 649 | special effects. Because it's unlikely that you'll set these options for an entire frame,
|
---|
| 650 | but rather use them to tweak settings between rendering objects, this is an internal
|
---|
| 651 | method (indicated by the '_' prefix) which will be used by a SceneManager implementation
|
---|
| 652 | rather than directly from the client application.
|
---|
| 653 | If this method is never called the settings are automatically the same as the default parameters.
|
---|
| 654 | @param depthTest If true, the depth buffer is tested for each pixel and the frame buffer is only updated
|
---|
| 655 | if the depth function test succeeds. If false, no test is performed and pixels are always written.
|
---|
| 656 | @param depthWrite If true, the depth buffer is updated with the depth of the new pixel if the depth test succeeds.
|
---|
| 657 | If false, the depth buffer is left unchanged even if a new pixel is written.
|
---|
| 658 | @param depthFunction Sets the function required for the depth test.
|
---|
| 659 | */
|
---|
| 660 | virtual void _setDepthBufferParams(bool depthTest = true, bool depthWrite = true, CompareFunction depthFunction = CMPF_LESS_EQUAL) = 0;
|
---|
| 661 |
|
---|
| 662 | /** Sets whether or not the depth buffer check is performed before a pixel write.
|
---|
| 663 | @param enabled If true, the depth buffer is tested for each pixel and the frame buffer is only updated
|
---|
| 664 | if the depth function test succeeds. If false, no test is performed and pixels are always written.
|
---|
| 665 | */
|
---|
| 666 | virtual void _setDepthBufferCheckEnabled(bool enabled = true) = 0;
|
---|
| 667 | /** Sets whether or not the depth buffer is updated after a pixel write.
|
---|
| 668 | @param enabled If true, the depth buffer is updated with the depth of the new pixel if the depth test succeeds.
|
---|
| 669 | If false, the depth buffer is left unchanged even if a new pixel is written.
|
---|
| 670 | */
|
---|
| 671 | virtual void _setDepthBufferWriteEnabled(bool enabled = true) = 0;
|
---|
| 672 | /** Sets the comparison function for the depth buffer check.
|
---|
| 673 | Advanced use only - allows you to choose the function applied to compare the depth values of
|
---|
| 674 | new and existing pixels in the depth buffer. Only an issue if the deoth buffer check is enabled
|
---|
| 675 | (see _setDepthBufferCheckEnabled)
|
---|
| 676 | @param func The comparison between the new depth and the existing depth which must return true
|
---|
| 677 | for the new pixel to be written.
|
---|
| 678 | */
|
---|
| 679 | virtual void _setDepthBufferFunction(CompareFunction func = CMPF_LESS_EQUAL) = 0;
|
---|
| 680 | /** Sets whether or not colour buffer writing is enabled, and for which channels.
|
---|
| 681 | @remarks
|
---|
| 682 | For some advanced effects, you may wish to turn off the writing of certain colour
|
---|
| 683 | channels, or even all of the colour channels so that only the depth buffer is updated
|
---|
| 684 | in a rendering pass. However, the chances are that you really want to use this option
|
---|
| 685 | through the Material class.
|
---|
| 686 | @param red, green, blue, alpha Whether writing is enabled for each of the 4 colour channels. */
|
---|
| 687 | virtual void _setColourBufferWriteEnabled(bool red, bool green, bool blue, bool alpha) = 0;
|
---|
| 688 | /** Sets the depth bias, NB you should use the Material version of this.
|
---|
| 689 | @remarks
|
---|
| 690 | When polygons are coplanar, you can get problems with 'depth fighting' where
|
---|
| 691 | the pixels from the two polys compete for the same screen pixel. This is particularly
|
---|
| 692 | a problem for decals (polys attached to another surface to represent details such as
|
---|
| 693 | bulletholes etc.).
|
---|
| 694 | @par
|
---|
| 695 | A way to combat this problem is to use a depth bias to adjust the depth buffer value
|
---|
| 696 | used for the decal such that it is slightly higher than the true value, ensuring that
|
---|
| 697 | the decal appears on top.
|
---|
| 698 | @param bias The bias value, should be between 0 and 16.
|
---|
| 699 | */
|
---|
| 700 | virtual void _setDepthBias(ushort bias) = 0;
|
---|
| 701 | /** Sets the fogging mode for future geometry.
|
---|
| 702 | @param mode Set up the mode of fog as described in the FogMode enum, or set to FOG_NONE to turn off.
|
---|
| 703 | @param colour The colour of the fog. Either set this to the same as your viewport background colour,
|
---|
| 704 | or to blend in with a skydome or skybox.
|
---|
| 705 | @param expDensity The density of the fog in FOG_EXP or FOG_EXP2 mode, as a value between 0 and 1. The default is 1. i.e. completely opaque, lower values can mean
|
---|
| 706 | that fog never completely obscures the scene.
|
---|
| 707 | @param linearStart Distance at which linear fog starts to encroach. The distance must be passed
|
---|
| 708 | as a parametric value between 0 and 1, with 0 being the near clipping plane, and 1 being the far clipping plane. Only applicable if mode is FOG_LINEAR.
|
---|
| 709 | @param linearEnd Distance at which linear fog becomes completely opaque.The distance must be passed
|
---|
| 710 | as a parametric value between 0 and 1, with 0 being the near clipping plane, and 1 being the far clipping plane. Only applicable if mode is FOG_LINEAR.
|
---|
| 711 | */
|
---|
| 712 | virtual void _setFog(FogMode mode = FOG_NONE, const ColourValue& colour = ColourValue::White, Real expDensity = 1.0, Real linearStart = 0.0, Real linearEnd = 1.0) = 0;
|
---|
| 713 |
|
---|
| 714 |
|
---|
| 715 | /** The RenderSystem will keep a count of tris rendered, this resets the count. */
|
---|
| 716 | virtual void _beginGeometryCount(void);
|
---|
| 717 | /** Reports the number of tris rendered since the last _beginGeometryCount call. */
|
---|
| 718 | virtual unsigned int _getFaceCount(void) const;
|
---|
| 719 | /** Reports the number of vertices passed to the renderer since the last _beginGeometryCount call. */
|
---|
| 720 | virtual unsigned int _getVertexCount(void) const;
|
---|
| 721 |
|
---|
| 722 | /** Generates a packed data version of the passed in ColourValue suitable for
|
---|
| 723 | use as with this RenderSystem.
|
---|
| 724 | @remarks
|
---|
| 725 | Since different render systems have different colour data formats (eg
|
---|
| 726 | RGBA for GL, ARGB for D3D) this method allows you to use 1 method for all.
|
---|
| 727 | @param colour The colour to convert
|
---|
| 728 | @param pDest Pointer to location to put the result.
|
---|
| 729 | */
|
---|
| 730 | virtual void convertColourValue(const ColourValue& colour, uint32* pDest);
|
---|
| 731 | /** Get the native VertexElementType for a compact 32-bit colour value
|
---|
| 732 | for this rendersystem.
|
---|
| 733 | */
|
---|
| 734 | virtual VertexElementType getColourVertexElementType(void) const = 0;
|
---|
| 735 |
|
---|
| 736 | /** Converts a uniform projection matrix to suitable for this render system.
|
---|
| 737 | @remarks
|
---|
| 738 | Because different APIs have different requirements (some incompatible) for the
|
---|
| 739 | projection matrix, this method allows each to implement their own correctly and pass
|
---|
| 740 | back a generic OGRE matrix for storage in the engine.
|
---|
| 741 | */
|
---|
| 742 | virtual void _convertProjectionMatrix(const Matrix4& matrix,
|
---|
| 743 | Matrix4& dest, bool forGpuProgram = false) = 0;
|
---|
| 744 |
|
---|
| 745 | /** Builds a perspective projection matrix suitable for this render system.
|
---|
| 746 | @remarks
|
---|
| 747 | Because different APIs have different requirements (some incompatible) for the
|
---|
| 748 | projection matrix, this method allows each to implement their own correctly and pass
|
---|
| 749 | back a generic OGRE matrix for storage in the engine.
|
---|
| 750 | */
|
---|
| 751 | virtual void _makeProjectionMatrix(const Radian& fovy, Real aspect, Real nearPlane, Real farPlane,
|
---|
| 752 | Matrix4& dest, bool forGpuProgram = false) = 0;
|
---|
| 753 |
|
---|
| 754 | /** Builds a perspective projection matrix for the case when frustum is
|
---|
| 755 | not centered around camera.
|
---|
| 756 | @remarks
|
---|
| 757 | Viewport coordinates are in camera coordinate frame, i.e. camera is
|
---|
| 758 | at the origin.
|
---|
| 759 | */
|
---|
| 760 | virtual void _makeProjectionMatrix(Real left, Real right, Real bottom, Real top,
|
---|
| 761 | Real nearPlane, Real farPlane, Matrix4& dest, bool forGpuProgram = false) = 0;
|
---|
| 762 | /** Builds an orthographic projection matrix suitable for this render system.
|
---|
| 763 | @remarks
|
---|
| 764 | Because different APIs have different requirements (some incompatible) for the
|
---|
| 765 | projection matrix, this method allows each to implement their own correctly and pass
|
---|
| 766 | back a generic OGRE matrix for storage in the engine.
|
---|
| 767 | */
|
---|
| 768 | virtual void _makeOrthoMatrix(const Radian& fovy, Real aspect, Real nearPlane, Real farPlane,
|
---|
| 769 | Matrix4& dest, bool forGpuProgram = false) = 0;
|
---|
| 770 |
|
---|
| 771 | /** Update a perspective projection matrix to use 'oblique depth projection'.
|
---|
| 772 | @remarks
|
---|
| 773 | This method can be used to change the nature of a perspective
|
---|
| 774 | transform in order to make the near plane not perpendicular to the
|
---|
| 775 | camera view direction, but to be at some different orientation.
|
---|
| 776 | This can be useful for performing arbitrary clipping (e.g. to a
|
---|
| 777 | reflection plane) which could otherwise only be done using user
|
---|
| 778 | clip planes, which are more expensive, and not necessarily supported
|
---|
| 779 | on all cards.
|
---|
| 780 | @param matrix The existing projection matrix. Note that this must be a
|
---|
| 781 | perspective transform (not orthographic), and must not have already
|
---|
| 782 | been altered by this method. The matrix will be altered in-place.
|
---|
| 783 | @param plane The plane which is to be used as the clipping plane. This
|
---|
| 784 | plane must be in CAMERA (view) space.
|
---|
| 785 | @param forGpuProgram Is this for use with a Gpu program or fixed-function
|
---|
| 786 | */
|
---|
| 787 | virtual void _applyObliqueDepthProjection(Matrix4& matrix, const Plane& plane,
|
---|
| 788 | bool forGpuProgram) = 0;
|
---|
| 789 |
|
---|
| 790 | /** Sets how to rasterise triangles, as points, wireframe or solid polys. */
|
---|
| 791 | virtual void _setPolygonMode(PolygonMode level) = 0;
|
---|
| 792 |
|
---|
| 793 | /** Turns stencil buffer checking on or off.
|
---|
| 794 | @remarks
|
---|
| 795 | Stencilling (masking off areas of the rendering target based on the stencil
|
---|
| 796 | buffer) canbe turned on or off using this method. By default, stencilling is
|
---|
| 797 | disabled.
|
---|
| 798 | */
|
---|
| 799 | virtual void setStencilCheckEnabled(bool enabled) = 0;
|
---|
| 800 | /** Determines if this system supports hardware accelerated stencil buffer.
|
---|
| 801 | @remarks
|
---|
| 802 | Note that the lack of this function doesn't mean you can't do stencilling, but
|
---|
| 803 | the stencilling operations will be provided in software, which will NOT be
|
---|
| 804 | fast.
|
---|
| 805 | @par
|
---|
| 806 | Generally hardware stencils are only supported in 32-bit colour modes, because
|
---|
| 807 | the stencil buffer shares the memory of the z-buffer, and in most cards the
|
---|
| 808 | z-buffer has to be the same depth as the colour buffer. This means that in 32-bit
|
---|
| 809 | mode, 24 bits of the z-buffer are depth and 8 bits are stencil. In 16-bit mode there
|
---|
| 810 | is no room for a stencil (although some cards support a 15:1 depth:stencil option,
|
---|
| 811 | this isn't useful for very much) so 8 bits of stencil are provided in software.
|
---|
| 812 | This can mean that if you use stencilling, your applications may be faster in
|
---|
| 813 | 32-but colour than in 16-bit, which may seem odd to some people.
|
---|
| 814 | */
|
---|
| 815 | /*virtual bool hasHardwareStencil(void) = 0;*/
|
---|
| 816 |
|
---|
| 817 | /** This method allows you to set all the stencil buffer parameters in one call.
|
---|
| 818 | @remarks
|
---|
| 819 | The stencil buffer is used to mask out pixels in the render target, allowing
|
---|
| 820 | you to do effects like mirrors, cut-outs, stencil shadows and more. Each of
|
---|
| 821 | your batches of rendering is likely to ignore the stencil buffer,
|
---|
| 822 | update it with new values, or apply it to mask the output of the render.
|
---|
| 823 | The stencil test is:<PRE>
|
---|
| 824 | (Reference Value & Mask) CompareFunction (Stencil Buffer Value & Mask)</PRE>
|
---|
| 825 | The result of this will cause one of 3 actions depending on whether the test fails,
|
---|
| 826 | succeeds but with the depth buffer check still failing, or succeeds with the
|
---|
| 827 | depth buffer check passing too.
|
---|
| 828 | @par
|
---|
| 829 | Unlike other render states, stencilling is left for the application to turn
|
---|
| 830 | on and off when it requires. This is because you are likely to want to change
|
---|
| 831 | parameters between batches of arbitrary objects and control the ordering yourself.
|
---|
| 832 | In order to batch things this way, you'll want to use OGRE's separate render queue
|
---|
| 833 | groups (see RenderQueue) and register a RenderQueueListener to get notifications
|
---|
| 834 | between batches.
|
---|
| 835 | @par
|
---|
| 836 | There are individual state change methods for each of the parameters set using
|
---|
| 837 | this method.
|
---|
| 838 | Note that the default values in this method represent the defaults at system
|
---|
| 839 | start up too.
|
---|
| 840 | @param func The comparison function applied.
|
---|
| 841 | @param refValue The reference value used in the comparison
|
---|
| 842 | @param mask The bitmask applied to both the stencil value and the reference value
|
---|
| 843 | before comparison
|
---|
| 844 | @param stencilFailOp The action to perform when the stencil check fails
|
---|
| 845 | @param depthFailOp The action to perform when the stencil check passes, but the
|
---|
| 846 | depth buffer check still fails
|
---|
| 847 | @param passOp The action to take when both the stencil and depth check pass.
|
---|
| 848 | @param twoSidedOperation If set to true, then if you render both back and front faces
|
---|
| 849 | (you'll have to turn off culling) then these parameters will apply for front faces,
|
---|
| 850 | and the inverse of them will happen for back faces (keep remains the same).
|
---|
| 851 | */
|
---|
| 852 | virtual void setStencilBufferParams(CompareFunction func = CMPF_ALWAYS_PASS,
|
---|
| 853 | uint32 refValue = 0, uint32 mask = 0xFFFFFFFF,
|
---|
| 854 | StencilOperation stencilFailOp = SOP_KEEP,
|
---|
| 855 | StencilOperation depthFailOp = SOP_KEEP,
|
---|
| 856 | StencilOperation passOp = SOP_KEEP,
|
---|
| 857 | bool twoSidedOperation = false) = 0;
|
---|
| 858 |
|
---|
| 859 |
|
---|
| 860 |
|
---|
| 861 | /** Sets the current vertex declaration, ie the source of vertex data. */
|
---|
| 862 | virtual void setVertexDeclaration(VertexDeclaration* decl) = 0;
|
---|
| 863 | /** Sets the current vertex buffer binding state. */
|
---|
| 864 | virtual void setVertexBufferBinding(VertexBufferBinding* binding) = 0;
|
---|
| 865 |
|
---|
| 866 | /** Sets whether or not normals are to be automatically normalised.
|
---|
| 867 | @remarks
|
---|
| 868 | This is useful when, for example, you are scaling SceneNodes such that
|
---|
| 869 | normals may not be unit-length anymore. Note though that this has an
|
---|
| 870 | overhead so should not be turn on unless you really need it.
|
---|
| 871 | @par
|
---|
| 872 | You should not normally call this direct unless you are rendering
|
---|
| 873 | world geometry; set it on the Renderable because otherwise it will be
|
---|
| 874 | overridden by material settings.
|
---|
| 875 | */
|
---|
| 876 | virtual void setNormaliseNormals(bool normalise) = 0;
|
---|
| 877 |
|
---|
| 878 | /**
|
---|
| 879 | Render something to the active viewport.
|
---|
| 880 |
|
---|
| 881 | Low-level rendering interface to perform rendering
|
---|
| 882 | operations. Unlikely to be used directly by client
|
---|
| 883 | applications, since the SceneManager and various support
|
---|
| 884 | classes will be responsible for calling this method.
|
---|
| 885 | Can only be called between _beginScene and _endScene
|
---|
| 886 |
|
---|
| 887 | @param op A rendering operation instance, which contains
|
---|
| 888 | details of the operation to be performed.
|
---|
| 889 | */
|
---|
| 890 | virtual void _render(const RenderOperation& op);
|
---|
| 891 |
|
---|
| 892 | /** Gets the capabilities of the render system. */
|
---|
| 893 | const RenderSystemCapabilities* getCapabilities(void) const { return mCapabilities; }
|
---|
| 894 |
|
---|
| 895 | /** Binds a given GpuProgram (but not the parameters).
|
---|
| 896 | @remarks Only one GpuProgram of each type can be bound at once, binding another
|
---|
| 897 | one will simply replace the exsiting one.
|
---|
| 898 | */
|
---|
| 899 | virtual void bindGpuProgram(GpuProgram* prg);
|
---|
| 900 |
|
---|
| 901 | /** Bind Gpu program parameters.
|
---|
| 902 | */
|
---|
| 903 | virtual void bindGpuProgramParameters(GpuProgramType gptype, GpuProgramParametersSharedPtr params) = 0;
|
---|
| 904 | /** Only binds Gpu program parameters used for passes that have more than one iteration rendering
|
---|
| 905 | */
|
---|
| 906 | virtual void bindGpuProgramPassIterationParameters(GpuProgramType gptype) = 0;
|
---|
| 907 | /** Unbinds GpuPrograms of a given GpuProgramType.
|
---|
| 908 | @remarks
|
---|
| 909 | This returns the pipeline to fixed-function processing for this type.
|
---|
| 910 | */
|
---|
| 911 | virtual void unbindGpuProgram(GpuProgramType gptype);
|
---|
| 912 |
|
---|
| 913 | /** Returns whether or not a Gpu program of the given type is currently bound. */
|
---|
| 914 | virtual bool isGpuProgramBound(GpuProgramType gptype);
|
---|
| 915 |
|
---|
| 916 | /** sets the clipping region.
|
---|
| 917 | */
|
---|
| 918 | virtual void setClipPlanes(const PlaneList& clipPlanes) = 0;
|
---|
| 919 |
|
---|
| 920 | /** Utility method for initialising all render targets attached to this rendering system. */
|
---|
| 921 | virtual void _initRenderTargets(void);
|
---|
| 922 |
|
---|
| 923 | /** Utility method to notify all render targets that a camera has been removed,
|
---|
| 924 | incase they were referring to it as their viewer.
|
---|
| 925 | */
|
---|
| 926 | virtual void _notifyCameraRemoved(const Camera* cam);
|
---|
| 927 |
|
---|
| 928 | /** Internal method for updating all render targets attached to this rendering system. */
|
---|
| 929 | virtual void _updateAllRenderTargets(void);
|
---|
| 930 |
|
---|
| 931 | /** Set a clipping plane. */
|
---|
| 932 | virtual void setClipPlane (ushort index, const Plane &p);
|
---|
| 933 | /** Set a clipping plane. */
|
---|
| 934 | virtual void setClipPlane (ushort index, Real A, Real B, Real C, Real D) = 0;
|
---|
| 935 | /** Enable the clipping plane. */
|
---|
| 936 | virtual void enableClipPlane (ushort index, bool enable) = 0;
|
---|
| 937 |
|
---|
| 938 | /** Sets whether or not vertex windings set should be inverted; this can be important
|
---|
| 939 | for rendering reflections. */
|
---|
| 940 | virtual void setInvertVertexWinding(bool invert);
|
---|
| 941 | /** Sets the 'scissor region' ie the region of the target in which rendering can take place.
|
---|
| 942 | @remarks
|
---|
| 943 | This method allows you to 'mask off' rendering in all but a given rectangular area
|
---|
| 944 | as identified by the parameters to this method.
|
---|
| 945 | @note
|
---|
| 946 | Not all systems support this method. Check the RenderSystemCapabilities for the
|
---|
| 947 | RSC_SCISSOR_TEST capability to see if it is supported.
|
---|
| 948 | @param enabled True to enable the scissor test, false to disable it.
|
---|
| 949 | @param left, top, right, bottom The location of the corners of the rectangle, expressed in
|
---|
| 950 | <i>pixels</i>.
|
---|
| 951 | */
|
---|
| 952 | virtual void setScissorTest(bool enabled, size_t left = 0, size_t top = 0,
|
---|
| 953 | size_t right = 800, size_t bottom = 600) = 0;
|
---|
| 954 |
|
---|
| 955 | /** Clears one or more frame buffers on the active render target.
|
---|
| 956 | @param buffers Combination of one or more elements of FrameBufferType
|
---|
| 957 | denoting which buffers are to be cleared
|
---|
| 958 | @param colour The colour to clear the colour buffer with, if enabled
|
---|
| 959 | @param depth The value to initialise the depth buffer with, if enabled
|
---|
| 960 | @param stencil The value to initialise the stencil buffer with, if enabled.
|
---|
| 961 | */
|
---|
| 962 | virtual void clearFrameBuffer(unsigned int buffers,
|
---|
| 963 | const ColourValue& colour = ColourValue::Black,
|
---|
| 964 | Real depth = 1.0f, unsigned short stencil = 0) = 0;
|
---|
| 965 | /** Returns the horizontal texel offset value required for mapping
|
---|
| 966 | texel origins to pixel origins in this rendersystem.
|
---|
| 967 | @remarks
|
---|
| 968 | Since rendersystems sometimes disagree on the origin of a texel,
|
---|
| 969 | mapping from texels to pixels can sometimes be problematic to
|
---|
| 970 | implement generically. This method allows you to retrieve the offset
|
---|
| 971 | required to map the origin of a texel to the origin of a pixel in
|
---|
| 972 | the horizontal direction.
|
---|
| 973 | */
|
---|
| 974 | virtual Real getHorizontalTexelOffset(void) = 0;
|
---|
| 975 | /** Returns the vertical texel offset value required for mapping
|
---|
| 976 | texel origins to pixel origins in this rendersystem.
|
---|
| 977 | @remarks
|
---|
| 978 | Since rendersystems sometimes disagree on the origin of a texel,
|
---|
| 979 | mapping from texels to pixels can sometimes be problematic to
|
---|
| 980 | implement generically. This method allows you to retrieve the offset
|
---|
| 981 | required to map the origin of a texel to the origin of a pixel in
|
---|
| 982 | the vertical direction.
|
---|
| 983 | */
|
---|
| 984 | virtual Real getVerticalTexelOffset(void) = 0;
|
---|
| 985 |
|
---|
| 986 | /** Gets the minimum (closest) depth value to be used when rendering
|
---|
| 987 | using identity transforms.
|
---|
| 988 | @remarks
|
---|
| 989 | When using identity transforms you can manually set the depth
|
---|
| 990 | of a vertex; however the input values required differ per
|
---|
| 991 | rendersystem. This method lets you retrieve the correct value.
|
---|
| 992 | @see Renderable::useIdentityView, Renderable::useIdentityProjection
|
---|
| 993 | */
|
---|
| 994 | virtual Real getMinimumDepthInputValue(void) = 0;
|
---|
| 995 | /** Gets the maximum (farthest) depth value to be used when rendering
|
---|
| 996 | using identity transforms.
|
---|
| 997 | @remarks
|
---|
| 998 | When using identity transforms you can manually set the depth
|
---|
| 999 | of a vertex; however the input values required differ per
|
---|
| 1000 | rendersystem. This method lets you retrieve the correct value.
|
---|
| 1001 | @see Renderable::useIdentityView, Renderable::useIdentityProjection
|
---|
| 1002 | */
|
---|
| 1003 | virtual Real getMaximumDepthInputValue(void) = 0;
|
---|
| 1004 | /** set the current multi pass count value. This must be set prior to
|
---|
| 1005 | calling _render() if multiple renderings of the same pass state are
|
---|
| 1006 | required.
|
---|
| 1007 | @param count Number of times to render the current state.
|
---|
| 1008 | */
|
---|
| 1009 | void setCurrentPassIterationCount(const size_t count) { mCurrentPassIterationCount = count; }
|
---|
| 1010 |
|
---|
| 1011 | /** Defines a listener on the custom events that this render system
|
---|
| 1012 | can raise.
|
---|
| 1013 | @see RenderSystem::addListener
|
---|
| 1014 | */
|
---|
| 1015 | class _OgreExport Listener
|
---|
| 1016 | {
|
---|
| 1017 | public:
|
---|
| 1018 | Listener() {}
|
---|
| 1019 | virtual ~Listener() {}
|
---|
| 1020 |
|
---|
| 1021 | /** A rendersystem-specific event occurred.
|
---|
| 1022 | @param eventName The name of the event which has occurred
|
---|
| 1023 | @param parameters A list of parameters that may belong to this event,
|
---|
| 1024 | may be null if there are no parameters
|
---|
| 1025 | */
|
---|
| 1026 | virtual void eventOccurred(const String& eventName,
|
---|
| 1027 | const NameValuePairList* parameters = 0) = 0;
|
---|
| 1028 | };
|
---|
| 1029 | /** Adds a listener to the custom events that this render system can raise.
|
---|
| 1030 | @remarks
|
---|
| 1031 | Some render systems have quite specific, internally generated events
|
---|
| 1032 | that the application may wish to be notified of. Many applications
|
---|
| 1033 | don't have to worry about these events, and can just trust OGRE to
|
---|
| 1034 | handle them, but if you want to know, you can add a listener here.
|
---|
| 1035 | @par
|
---|
| 1036 | Events are raised very generically by string name. Perhaps the most
|
---|
| 1037 | common example of a render system specific event is the loss and
|
---|
| 1038 | restoration of a device in DirectX; which OGRE deals with, but you
|
---|
| 1039 | may wish to know when it happens.
|
---|
| 1040 | @see RenderSystem::getRenderSystemEvents
|
---|
| 1041 | */
|
---|
| 1042 | virtual void addListener(Listener* l);
|
---|
| 1043 | /** Remove a listener to the custom events that this render system can raise.
|
---|
| 1044 | */
|
---|
| 1045 | virtual void removeListener(Listener* l);
|
---|
| 1046 |
|
---|
| 1047 | /** Gets a list of the rendersystem specific events that this rendersystem
|
---|
| 1048 | can raise.
|
---|
| 1049 | @see RenderSystem::addListener
|
---|
| 1050 | */
|
---|
| 1051 | virtual const StringVector& getRenderSystemEvents(void) const { return mEventNames; }
|
---|
| 1052 | protected:
|
---|
| 1053 |
|
---|
| 1054 |
|
---|
| 1055 | /** The render targets. */
|
---|
| 1056 | RenderTargetMap mRenderTargets;
|
---|
| 1057 | /** The render targets, ordered by priority. */
|
---|
| 1058 | RenderTargetPriorityMap mPrioritisedRenderTargets;
|
---|
| 1059 | /** The Active render target. */
|
---|
| 1060 | RenderTarget * mActiveRenderTarget;
|
---|
| 1061 | /** The Active GPU programs and gpu program parameters*/
|
---|
| 1062 | GpuProgramParametersSharedPtr mActiveVertexGpuProgramParameters;
|
---|
| 1063 | GpuProgramParametersSharedPtr mActiveFragmentGpuProgramParameters;
|
---|
| 1064 |
|
---|
| 1065 | // Texture manager
|
---|
| 1066 | // A concrete class of this will be created and
|
---|
| 1067 | // made available under the TextureManager singleton,
|
---|
| 1068 | // managed by the RenderSystem
|
---|
| 1069 | TextureManager* mTextureManager;
|
---|
| 1070 |
|
---|
| 1071 | /// Used to store the capabilities of the graphics card
|
---|
| 1072 | RenderSystemCapabilities* mCapabilities;
|
---|
| 1073 |
|
---|
| 1074 | // Active viewport (dest for future rendering operations)
|
---|
| 1075 | Viewport* mActiveViewport;
|
---|
| 1076 |
|
---|
| 1077 | CullingMode mCullingMode;
|
---|
| 1078 |
|
---|
| 1079 | bool mVSync;
|
---|
| 1080 | bool mWBuffer;
|
---|
| 1081 |
|
---|
| 1082 | size_t mFaceCount;
|
---|
| 1083 | size_t mVertexCount;
|
---|
| 1084 |
|
---|
| 1085 | /// Saved set of world matrices
|
---|
| 1086 | Matrix4 mWorldMatrices[256];
|
---|
| 1087 |
|
---|
| 1088 | /// Saved manual colour blends
|
---|
| 1089 | ColourValue mManualBlendColours[OGRE_MAX_TEXTURE_LAYERS][2];
|
---|
| 1090 |
|
---|
| 1091 | bool mInvertVertexWinding;
|
---|
| 1092 |
|
---|
| 1093 | /// number of times to render the current state
|
---|
| 1094 | size_t mCurrentPassIterationCount;
|
---|
| 1095 |
|
---|
| 1096 | /** updates pass iteration rendering state including bound gpu program parameter
|
---|
| 1097 | pass iteration auto constant entry
|
---|
| 1098 | @returns True if more iterations are required
|
---|
| 1099 | */
|
---|
| 1100 | bool updatePassIterationRenderState(void);
|
---|
| 1101 |
|
---|
| 1102 | /// List of names of events this rendersystem may raise
|
---|
| 1103 | StringVector mEventNames;
|
---|
| 1104 |
|
---|
| 1105 | /// Internal method for firing a rendersystem event
|
---|
| 1106 | virtual void fireEvent(const String& name, const NameValuePairList* params = 0);
|
---|
| 1107 |
|
---|
| 1108 | typedef std::list<Listener*> ListenerList;
|
---|
| 1109 | ListenerList mEventListeners;
|
---|
| 1110 |
|
---|
| 1111 | typedef std::list<HardwareOcclusionQuery*> HardwareOcclusionQueryList;
|
---|
| 1112 | HardwareOcclusionQueryList mHwOcclusionQueries;
|
---|
| 1113 |
|
---|
| 1114 | bool mVertexProgramBound;
|
---|
| 1115 | bool mFragmentProgramBound;
|
---|
| 1116 |
|
---|
| 1117 |
|
---|
| 1118 |
|
---|
| 1119 | };
|
---|
| 1120 | }
|
---|
| 1121 |
|
---|
| 1122 | #endif
|
---|