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 |
|
---|
603 | #ifdef GAMETOOLS_ILLUMINATION_MODULE
|
---|
604 | virtual void _setSceneBlending(SceneBlendFactor sourceFactor,
|
---|
605 | SceneBlendFactor destFactor,
|
---|
606 | SceneBlendOperation blendOp = SBOP_ADD,
|
---|
607 | bool separateAlpha = false,
|
---|
608 | SceneBlendFactor sourceFactorAlpha = SBF_ONE,
|
---|
609 | SceneBlendFactor destFactorAlpha = SBF_ZERO,
|
---|
610 | SceneBlendOperation blendOpAlpha = SBOP_ADD) {}
|
---|
611 | #else
|
---|
612 | virtual void _setSceneBlending(SceneBlendFactor sourceFactor, SceneBlendFactor destFactor) = 0;
|
---|
613 | #endif
|
---|
614 |
|
---|
615 | /** Sets the global alpha rejection approach for future renders.
|
---|
616 | By default images are rendered regardless of texture alpha. This method lets you change that.
|
---|
617 | @param func The comparison function which must pass for a pixel to be written.
|
---|
618 | @param val The value to compare each pixels alpha value to (0-255)
|
---|
619 | */
|
---|
620 | virtual void _setAlphaRejectSettings(CompareFunction func, unsigned char value) = 0;
|
---|
621 | /**
|
---|
622 | * Signifies the beginning of a frame, ie the start of rendering on a single viewport. Will occur
|
---|
623 | * several times per complete frame if multiple viewports exist.
|
---|
624 | */
|
---|
625 | virtual void _beginFrame(void) = 0;
|
---|
626 |
|
---|
627 |
|
---|
628 | /**
|
---|
629 | * Ends rendering of a frame to the current viewport.
|
---|
630 | */
|
---|
631 | virtual void _endFrame(void) = 0;
|
---|
632 | /**
|
---|
633 | Sets the provided viewport as the active one for future
|
---|
634 | rendering operations. This viewport is aware of it's own
|
---|
635 | camera and render target. Must be implemented by subclass.
|
---|
636 |
|
---|
637 | @param target Pointer to the appropriate viewport.
|
---|
638 | */
|
---|
639 | virtual void _setViewport(Viewport *vp) = 0;
|
---|
640 | /** Get the current active viewport for rendering. */
|
---|
641 | virtual Viewport* _getViewport(void);
|
---|
642 |
|
---|
643 | /** Sets the culling mode for the render system based on the 'vertex winding'.
|
---|
644 | A typical way for the rendering engine to cull triangles is based on the
|
---|
645 | 'vertex winding' of triangles. Vertex winding refers to the direction in
|
---|
646 | which the vertices are passed or indexed to in the rendering operation as viewed
|
---|
647 | from the camera, and will wither be clockwise or anticlockwise (that's 'counterclockwise' for
|
---|
648 | you Americans out there ;) The default is CULL_CLOCKWISE i.e. that only triangles whose vertices
|
---|
649 | are passed/indexed in anticlockwise order are rendered - this is a common approach and is used in 3D studio models
|
---|
650 | for example. You can alter this culling mode if you wish but it is not advised unless you know what you are doing.
|
---|
651 | You may wish to use the CULL_NONE option for mesh data that you cull yourself where the vertex
|
---|
652 | winding is uncertain.
|
---|
653 | */
|
---|
654 | virtual void _setCullingMode(CullingMode mode) = 0;
|
---|
655 |
|
---|
656 | virtual CullingMode _getCullingMode(void) const;
|
---|
657 |
|
---|
658 | /** Sets the mode of operation for depth buffer tests from this point onwards.
|
---|
659 | Sometimes you may wish to alter the behaviour of the depth buffer to achieve
|
---|
660 | special effects. Because it's unlikely that you'll set these options for an entire frame,
|
---|
661 | but rather use them to tweak settings between rendering objects, this is an internal
|
---|
662 | method (indicated by the '_' prefix) which will be used by a SceneManager implementation
|
---|
663 | rather than directly from the client application.
|
---|
664 | If this method is never called the settings are automatically the same as the default parameters.
|
---|
665 | @param depthTest If true, the depth buffer is tested for each pixel and the frame buffer is only updated
|
---|
666 | if the depth function test succeeds. If false, no test is performed and pixels are always written.
|
---|
667 | @param depthWrite If true, the depth buffer is updated with the depth of the new pixel if the depth test succeeds.
|
---|
668 | If false, the depth buffer is left unchanged even if a new pixel is written.
|
---|
669 | @param depthFunction Sets the function required for the depth test.
|
---|
670 | */
|
---|
671 | virtual void _setDepthBufferParams(bool depthTest = true, bool depthWrite = true, CompareFunction depthFunction = CMPF_LESS_EQUAL) = 0;
|
---|
672 |
|
---|
673 | /** Sets whether or not the depth buffer check is performed before a pixel write.
|
---|
674 | @param enabled If true, the depth buffer is tested for each pixel and the frame buffer is only updated
|
---|
675 | if the depth function test succeeds. If false, no test is performed and pixels are always written.
|
---|
676 | */
|
---|
677 | virtual void _setDepthBufferCheckEnabled(bool enabled = true) = 0;
|
---|
678 | /** Sets whether or not the depth buffer is updated after a pixel write.
|
---|
679 | @param enabled If true, the depth buffer is updated with the depth of the new pixel if the depth test succeeds.
|
---|
680 | If false, the depth buffer is left unchanged even if a new pixel is written.
|
---|
681 | */
|
---|
682 | virtual void _setDepthBufferWriteEnabled(bool enabled = true) = 0;
|
---|
683 | /** Sets the comparison function for the depth buffer check.
|
---|
684 | Advanced use only - allows you to choose the function applied to compare the depth values of
|
---|
685 | new and existing pixels in the depth buffer. Only an issue if the deoth buffer check is enabled
|
---|
686 | (see _setDepthBufferCheckEnabled)
|
---|
687 | @param func The comparison between the new depth and the existing depth which must return true
|
---|
688 | for the new pixel to be written.
|
---|
689 | */
|
---|
690 | virtual void _setDepthBufferFunction(CompareFunction func = CMPF_LESS_EQUAL) = 0;
|
---|
691 | /** Sets whether or not colour buffer writing is enabled, and for which channels.
|
---|
692 | @remarks
|
---|
693 | For some advanced effects, you may wish to turn off the writing of certain colour
|
---|
694 | channels, or even all of the colour channels so that only the depth buffer is updated
|
---|
695 | in a rendering pass. However, the chances are that you really want to use this option
|
---|
696 | through the Material class.
|
---|
697 | @param red, green, blue, alpha Whether writing is enabled for each of the 4 colour channels. */
|
---|
698 | virtual void _setColourBufferWriteEnabled(bool red, bool green, bool blue, bool alpha) = 0;
|
---|
699 | /** Sets the depth bias, NB you should use the Material version of this.
|
---|
700 | @remarks
|
---|
701 | When polygons are coplanar, you can get problems with 'depth fighting' where
|
---|
702 | the pixels from the two polys compete for the same screen pixel. This is particularly
|
---|
703 | a problem for decals (polys attached to another surface to represent details such as
|
---|
704 | bulletholes etc.).
|
---|
705 | @par
|
---|
706 | A way to combat this problem is to use a depth bias to adjust the depth buffer value
|
---|
707 | used for the decal such that it is slightly higher than the true value, ensuring that
|
---|
708 | the decal appears on top.
|
---|
709 | @param bias The bias value, should be between 0 and 16.
|
---|
710 | */
|
---|
711 | virtual void _setDepthBias(ushort bias) = 0;
|
---|
712 | /** Sets the fogging mode for future geometry.
|
---|
713 | @param mode Set up the mode of fog as described in the FogMode enum, or set to FOG_NONE to turn off.
|
---|
714 | @param colour The colour of the fog. Either set this to the same as your viewport background colour,
|
---|
715 | or to blend in with a skydome or skybox.
|
---|
716 | @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
|
---|
717 | that fog never completely obscures the scene.
|
---|
718 | @param linearStart Distance at which linear fog starts to encroach. The distance must be passed
|
---|
719 | 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.
|
---|
720 | @param linearEnd Distance at which linear fog becomes completely opaque.The distance must be passed
|
---|
721 | 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.
|
---|
722 | */
|
---|
723 | 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;
|
---|
724 |
|
---|
725 |
|
---|
726 | /** The RenderSystem will keep a count of tris rendered, this resets the count. */
|
---|
727 | virtual void _beginGeometryCount(void);
|
---|
728 | /** Reports the number of tris rendered since the last _beginGeometryCount call. */
|
---|
729 | virtual unsigned int _getFaceCount(void) const;
|
---|
730 | /** Reports the number of vertices passed to the renderer since the last _beginGeometryCount call. */
|
---|
731 | virtual unsigned int _getVertexCount(void) const;
|
---|
732 |
|
---|
733 | /** Generates a packed data version of the passed in ColourValue suitable for
|
---|
734 | use as with this RenderSystem.
|
---|
735 | @remarks
|
---|
736 | Since different render systems have different colour data formats (eg
|
---|
737 | RGBA for GL, ARGB for D3D) this method allows you to use 1 method for all.
|
---|
738 | @param colour The colour to convert
|
---|
739 | @param pDest Pointer to location to put the result.
|
---|
740 | */
|
---|
741 | virtual void convertColourValue(const ColourValue& colour, uint32* pDest);
|
---|
742 | /** Get the native VertexElementType for a compact 32-bit colour value
|
---|
743 | for this rendersystem.
|
---|
744 | */
|
---|
745 | virtual VertexElementType getColourVertexElementType(void) const = 0;
|
---|
746 |
|
---|
747 | /** Converts a uniform projection matrix to suitable for this render system.
|
---|
748 | @remarks
|
---|
749 | Because different APIs have different requirements (some incompatible) for the
|
---|
750 | projection matrix, this method allows each to implement their own correctly and pass
|
---|
751 | back a generic OGRE matrix for storage in the engine.
|
---|
752 | */
|
---|
753 | virtual void _convertProjectionMatrix(const Matrix4& matrix,
|
---|
754 | Matrix4& dest, bool forGpuProgram = false) = 0;
|
---|
755 |
|
---|
756 | /** Builds a perspective projection matrix suitable for this render system.
|
---|
757 | @remarks
|
---|
758 | Because different APIs have different requirements (some incompatible) for the
|
---|
759 | projection matrix, this method allows each to implement their own correctly and pass
|
---|
760 | back a generic OGRE matrix for storage in the engine.
|
---|
761 | */
|
---|
762 | virtual void _makeProjectionMatrix(const Radian& fovy, Real aspect, Real nearPlane, Real farPlane,
|
---|
763 | Matrix4& dest, bool forGpuProgram = false) = 0;
|
---|
764 |
|
---|
765 | /** Builds a perspective projection matrix for the case when frustum is
|
---|
766 | not centered around camera.
|
---|
767 | @remarks
|
---|
768 | Viewport coordinates are in camera coordinate frame, i.e. camera is
|
---|
769 | at the origin.
|
---|
770 | */
|
---|
771 | virtual void _makeProjectionMatrix(Real left, Real right, Real bottom, Real top,
|
---|
772 | Real nearPlane, Real farPlane, Matrix4& dest, bool forGpuProgram = false) = 0;
|
---|
773 | /** Builds an orthographic projection matrix suitable for this render system.
|
---|
774 | @remarks
|
---|
775 | Because different APIs have different requirements (some incompatible) for the
|
---|
776 | projection matrix, this method allows each to implement their own correctly and pass
|
---|
777 | back a generic OGRE matrix for storage in the engine.
|
---|
778 | */
|
---|
779 | virtual void _makeOrthoMatrix(const Radian& fovy, Real aspect, Real nearPlane, Real farPlane,
|
---|
780 | Matrix4& dest, bool forGpuProgram = false) = 0;
|
---|
781 |
|
---|
782 | /** Update a perspective projection matrix to use 'oblique depth projection'.
|
---|
783 | @remarks
|
---|
784 | This method can be used to change the nature of a perspective
|
---|
785 | transform in order to make the near plane not perpendicular to the
|
---|
786 | camera view direction, but to be at some different orientation.
|
---|
787 | This can be useful for performing arbitrary clipping (e.g. to a
|
---|
788 | reflection plane) which could otherwise only be done using user
|
---|
789 | clip planes, which are more expensive, and not necessarily supported
|
---|
790 | on all cards.
|
---|
791 | @param matrix The existing projection matrix. Note that this must be a
|
---|
792 | perspective transform (not orthographic), and must not have already
|
---|
793 | been altered by this method. The matrix will be altered in-place.
|
---|
794 | @param plane The plane which is to be used as the clipping plane. This
|
---|
795 | plane must be in CAMERA (view) space.
|
---|
796 | @param forGpuProgram Is this for use with a Gpu program or fixed-function
|
---|
797 | */
|
---|
798 | virtual void _applyObliqueDepthProjection(Matrix4& matrix, const Plane& plane,
|
---|
799 | bool forGpuProgram) = 0;
|
---|
800 |
|
---|
801 | /** Sets how to rasterise triangles, as points, wireframe or solid polys. */
|
---|
802 | virtual void _setPolygonMode(PolygonMode level) = 0;
|
---|
803 |
|
---|
804 | /** Turns stencil buffer checking on or off.
|
---|
805 | @remarks
|
---|
806 | Stencilling (masking off areas of the rendering target based on the stencil
|
---|
807 | buffer) canbe turned on or off using this method. By default, stencilling is
|
---|
808 | disabled.
|
---|
809 | */
|
---|
810 | virtual void setStencilCheckEnabled(bool enabled) = 0;
|
---|
811 | /** Determines if this system supports hardware accelerated stencil buffer.
|
---|
812 | @remarks
|
---|
813 | Note that the lack of this function doesn't mean you can't do stencilling, but
|
---|
814 | the stencilling operations will be provided in software, which will NOT be
|
---|
815 | fast.
|
---|
816 | @par
|
---|
817 | Generally hardware stencils are only supported in 32-bit colour modes, because
|
---|
818 | the stencil buffer shares the memory of the z-buffer, and in most cards the
|
---|
819 | z-buffer has to be the same depth as the colour buffer. This means that in 32-bit
|
---|
820 | mode, 24 bits of the z-buffer are depth and 8 bits are stencil. In 16-bit mode there
|
---|
821 | is no room for a stencil (although some cards support a 15:1 depth:stencil option,
|
---|
822 | this isn't useful for very much) so 8 bits of stencil are provided in software.
|
---|
823 | This can mean that if you use stencilling, your applications may be faster in
|
---|
824 | 32-but colour than in 16-bit, which may seem odd to some people.
|
---|
825 | */
|
---|
826 | /*virtual bool hasHardwareStencil(void) = 0;*/
|
---|
827 |
|
---|
828 | /** This method allows you to set all the stencil buffer parameters in one call.
|
---|
829 | @remarks
|
---|
830 | The stencil buffer is used to mask out pixels in the render target, allowing
|
---|
831 | you to do effects like mirrors, cut-outs, stencil shadows and more. Each of
|
---|
832 | your batches of rendering is likely to ignore the stencil buffer,
|
---|
833 | update it with new values, or apply it to mask the output of the render.
|
---|
834 | The stencil test is:<PRE>
|
---|
835 | (Reference Value & Mask) CompareFunction (Stencil Buffer Value & Mask)</PRE>
|
---|
836 | The result of this will cause one of 3 actions depending on whether the test fails,
|
---|
837 | succeeds but with the depth buffer check still failing, or succeeds with the
|
---|
838 | depth buffer check passing too.
|
---|
839 | @par
|
---|
840 | Unlike other render states, stencilling is left for the application to turn
|
---|
841 | on and off when it requires. This is because you are likely to want to change
|
---|
842 | parameters between batches of arbitrary objects and control the ordering yourself.
|
---|
843 | In order to batch things this way, you'll want to use OGRE's separate render queue
|
---|
844 | groups (see RenderQueue) and register a RenderQueueListener to get notifications
|
---|
845 | between batches.
|
---|
846 | @par
|
---|
847 | There are individual state change methods for each of the parameters set using
|
---|
848 | this method.
|
---|
849 | Note that the default values in this method represent the defaults at system
|
---|
850 | start up too.
|
---|
851 | @param func The comparison function applied.
|
---|
852 | @param refValue The reference value used in the comparison
|
---|
853 | @param mask The bitmask applied to both the stencil value and the reference value
|
---|
854 | before comparison
|
---|
855 | @param stencilFailOp The action to perform when the stencil check fails
|
---|
856 | @param depthFailOp The action to perform when the stencil check passes, but the
|
---|
857 | depth buffer check still fails
|
---|
858 | @param passOp The action to take when both the stencil and depth check pass.
|
---|
859 | @param twoSidedOperation If set to true, then if you render both back and front faces
|
---|
860 | (you'll have to turn off culling) then these parameters will apply for front faces,
|
---|
861 | and the inverse of them will happen for back faces (keep remains the same).
|
---|
862 | */
|
---|
863 | virtual void setStencilBufferParams(CompareFunction func = CMPF_ALWAYS_PASS,
|
---|
864 | uint32 refValue = 0, uint32 mask = 0xFFFFFFFF,
|
---|
865 | StencilOperation stencilFailOp = SOP_KEEP,
|
---|
866 | StencilOperation depthFailOp = SOP_KEEP,
|
---|
867 | StencilOperation passOp = SOP_KEEP,
|
---|
868 | bool twoSidedOperation = false) = 0;
|
---|
869 |
|
---|
870 |
|
---|
871 |
|
---|
872 | /** Sets the current vertex declaration, ie the source of vertex data. */
|
---|
873 | virtual void setVertexDeclaration(VertexDeclaration* decl) = 0;
|
---|
874 | /** Sets the current vertex buffer binding state. */
|
---|
875 | virtual void setVertexBufferBinding(VertexBufferBinding* binding) = 0;
|
---|
876 |
|
---|
877 | /** Sets whether or not normals are to be automatically normalised.
|
---|
878 | @remarks
|
---|
879 | This is useful when, for example, you are scaling SceneNodes such that
|
---|
880 | normals may not be unit-length anymore. Note though that this has an
|
---|
881 | overhead so should not be turn on unless you really need it.
|
---|
882 | @par
|
---|
883 | You should not normally call this direct unless you are rendering
|
---|
884 | world geometry; set it on the Renderable because otherwise it will be
|
---|
885 | overridden by material settings.
|
---|
886 | */
|
---|
887 | virtual void setNormaliseNormals(bool normalise) = 0;
|
---|
888 |
|
---|
889 | /**
|
---|
890 | Render something to the active viewport.
|
---|
891 |
|
---|
892 | Low-level rendering interface to perform rendering
|
---|
893 | operations. Unlikely to be used directly by client
|
---|
894 | applications, since the SceneManager and various support
|
---|
895 | classes will be responsible for calling this method.
|
---|
896 | Can only be called between _beginScene and _endScene
|
---|
897 |
|
---|
898 | @param op A rendering operation instance, which contains
|
---|
899 | details of the operation to be performed.
|
---|
900 | */
|
---|
901 | virtual void _render(const RenderOperation& op);
|
---|
902 |
|
---|
903 | /** Gets the capabilities of the render system. */
|
---|
904 | const RenderSystemCapabilities* getCapabilities(void) const { return mCapabilities; }
|
---|
905 |
|
---|
906 | /** Binds a given GpuProgram (but not the parameters).
|
---|
907 | @remarks Only one GpuProgram of each type can be bound at once, binding another
|
---|
908 | one will simply replace the exsiting one.
|
---|
909 | */
|
---|
910 | virtual void bindGpuProgram(GpuProgram* prg);
|
---|
911 |
|
---|
912 | /** Bind Gpu program parameters.
|
---|
913 | */
|
---|
914 | virtual void bindGpuProgramParameters(GpuProgramType gptype, GpuProgramParametersSharedPtr params) = 0;
|
---|
915 | /** Only binds Gpu program parameters used for passes that have more than one iteration rendering
|
---|
916 | */
|
---|
917 | virtual void bindGpuProgramPassIterationParameters(GpuProgramType gptype) = 0;
|
---|
918 | /** Unbinds GpuPrograms of a given GpuProgramType.
|
---|
919 | @remarks
|
---|
920 | This returns the pipeline to fixed-function processing for this type.
|
---|
921 | */
|
---|
922 | virtual void unbindGpuProgram(GpuProgramType gptype);
|
---|
923 |
|
---|
924 | /** Returns whether or not a Gpu program of the given type is currently bound. */
|
---|
925 | virtual bool isGpuProgramBound(GpuProgramType gptype);
|
---|
926 |
|
---|
927 | /** sets the clipping region.
|
---|
928 | */
|
---|
929 | virtual void setClipPlanes(const PlaneList& clipPlanes) = 0;
|
---|
930 |
|
---|
931 | /** Utility method for initialising all render targets attached to this rendering system. */
|
---|
932 | virtual void _initRenderTargets(void);
|
---|
933 |
|
---|
934 | /** Utility method to notify all render targets that a camera has been removed,
|
---|
935 | incase they were referring to it as their viewer.
|
---|
936 | */
|
---|
937 | virtual void _notifyCameraRemoved(const Camera* cam);
|
---|
938 |
|
---|
939 | /** Internal method for updating all render targets attached to this rendering system. */
|
---|
940 | virtual void _updateAllRenderTargets(void);
|
---|
941 |
|
---|
942 | /** Set a clipping plane. */
|
---|
943 | virtual void setClipPlane (ushort index, const Plane &p);
|
---|
944 | /** Set a clipping plane. */
|
---|
945 | virtual void setClipPlane (ushort index, Real A, Real B, Real C, Real D) = 0;
|
---|
946 | /** Enable the clipping plane. */
|
---|
947 | virtual void enableClipPlane (ushort index, bool enable) = 0;
|
---|
948 |
|
---|
949 | /** Sets whether or not vertex windings set should be inverted; this can be important
|
---|
950 | for rendering reflections. */
|
---|
951 | virtual void setInvertVertexWinding(bool invert);
|
---|
952 | /** Sets the 'scissor region' ie the region of the target in which rendering can take place.
|
---|
953 | @remarks
|
---|
954 | This method allows you to 'mask off' rendering in all but a given rectangular area
|
---|
955 | as identified by the parameters to this method.
|
---|
956 | @note
|
---|
957 | Not all systems support this method. Check the RenderSystemCapabilities for the
|
---|
958 | RSC_SCISSOR_TEST capability to see if it is supported.
|
---|
959 | @param enabled True to enable the scissor test, false to disable it.
|
---|
960 | @param left, top, right, bottom The location of the corners of the rectangle, expressed in
|
---|
961 | <i>pixels</i>.
|
---|
962 | */
|
---|
963 | virtual void setScissorTest(bool enabled, size_t left = 0, size_t top = 0,
|
---|
964 | size_t right = 800, size_t bottom = 600) = 0;
|
---|
965 |
|
---|
966 | /** Clears one or more frame buffers on the active render target.
|
---|
967 | @param buffers Combination of one or more elements of FrameBufferType
|
---|
968 | denoting which buffers are to be cleared
|
---|
969 | @param colour The colour to clear the colour buffer with, if enabled
|
---|
970 | @param depth The value to initialise the depth buffer with, if enabled
|
---|
971 | @param stencil The value to initialise the stencil buffer with, if enabled.
|
---|
972 | */
|
---|
973 | virtual void clearFrameBuffer(unsigned int buffers,
|
---|
974 | const ColourValue& colour = ColourValue::Black,
|
---|
975 | Real depth = 1.0f, unsigned short stencil = 0) = 0;
|
---|
976 | /** Returns the horizontal texel offset value required for mapping
|
---|
977 | texel origins to pixel origins in this rendersystem.
|
---|
978 | @remarks
|
---|
979 | Since rendersystems sometimes disagree on the origin of a texel,
|
---|
980 | mapping from texels to pixels can sometimes be problematic to
|
---|
981 | implement generically. This method allows you to retrieve the offset
|
---|
982 | required to map the origin of a texel to the origin of a pixel in
|
---|
983 | the horizontal direction.
|
---|
984 | */
|
---|
985 | virtual Real getHorizontalTexelOffset(void) = 0;
|
---|
986 | /** Returns the vertical texel offset value required for mapping
|
---|
987 | texel origins to pixel origins in this rendersystem.
|
---|
988 | @remarks
|
---|
989 | Since rendersystems sometimes disagree on the origin of a texel,
|
---|
990 | mapping from texels to pixels can sometimes be problematic to
|
---|
991 | implement generically. This method allows you to retrieve the offset
|
---|
992 | required to map the origin of a texel to the origin of a pixel in
|
---|
993 | the vertical direction.
|
---|
994 | */
|
---|
995 | virtual Real getVerticalTexelOffset(void) = 0;
|
---|
996 |
|
---|
997 | /** Gets the minimum (closest) depth value to be used when rendering
|
---|
998 | using identity transforms.
|
---|
999 | @remarks
|
---|
1000 | When using identity transforms you can manually set the depth
|
---|
1001 | of a vertex; however the input values required differ per
|
---|
1002 | rendersystem. This method lets you retrieve the correct value.
|
---|
1003 | @see Renderable::useIdentityView, Renderable::useIdentityProjection
|
---|
1004 | */
|
---|
1005 | virtual Real getMinimumDepthInputValue(void) = 0;
|
---|
1006 | /** Gets the maximum (farthest) depth value to be used when rendering
|
---|
1007 | using identity transforms.
|
---|
1008 | @remarks
|
---|
1009 | When using identity transforms you can manually set the depth
|
---|
1010 | of a vertex; however the input values required differ per
|
---|
1011 | rendersystem. This method lets you retrieve the correct value.
|
---|
1012 | @see Renderable::useIdentityView, Renderable::useIdentityProjection
|
---|
1013 | */
|
---|
1014 | virtual Real getMaximumDepthInputValue(void) = 0;
|
---|
1015 | /** set the current multi pass count value. This must be set prior to
|
---|
1016 | calling _render() if multiple renderings of the same pass state are
|
---|
1017 | required.
|
---|
1018 | @param count Number of times to render the current state.
|
---|
1019 | */
|
---|
1020 | void setCurrentPassIterationCount(const size_t count) { mCurrentPassIterationCount = count; }
|
---|
1021 |
|
---|
1022 | /** Defines a listener on the custom events that this render system
|
---|
1023 | can raise.
|
---|
1024 | @see RenderSystem::addListener
|
---|
1025 | */
|
---|
1026 | class _OgreExport Listener
|
---|
1027 | {
|
---|
1028 | public:
|
---|
1029 | Listener() {}
|
---|
1030 | virtual ~Listener() {}
|
---|
1031 |
|
---|
1032 | /** A rendersystem-specific event occurred.
|
---|
1033 | @param eventName The name of the event which has occurred
|
---|
1034 | @param parameters A list of parameters that may belong to this event,
|
---|
1035 | may be null if there are no parameters
|
---|
1036 | */
|
---|
1037 | virtual void eventOccurred(const String& eventName,
|
---|
1038 | const NameValuePairList* parameters = 0) = 0;
|
---|
1039 | };
|
---|
1040 | /** Adds a listener to the custom events that this render system can raise.
|
---|
1041 | @remarks
|
---|
1042 | Some render systems have quite specific, internally generated events
|
---|
1043 | that the application may wish to be notified of. Many applications
|
---|
1044 | don't have to worry about these events, and can just trust OGRE to
|
---|
1045 | handle them, but if you want to know, you can add a listener here.
|
---|
1046 | @par
|
---|
1047 | Events are raised very generically by string name. Perhaps the most
|
---|
1048 | common example of a render system specific event is the loss and
|
---|
1049 | restoration of a device in DirectX; which OGRE deals with, but you
|
---|
1050 | may wish to know when it happens.
|
---|
1051 | @see RenderSystem::getRenderSystemEvents
|
---|
1052 | */
|
---|
1053 | virtual void addListener(Listener* l);
|
---|
1054 | /** Remove a listener to the custom events that this render system can raise.
|
---|
1055 | */
|
---|
1056 | virtual void removeListener(Listener* l);
|
---|
1057 |
|
---|
1058 | /** Gets a list of the rendersystem specific events that this rendersystem
|
---|
1059 | can raise.
|
---|
1060 | @see RenderSystem::addListener
|
---|
1061 | */
|
---|
1062 | virtual const StringVector& getRenderSystemEvents(void) const { return mEventNames; }
|
---|
1063 | protected:
|
---|
1064 |
|
---|
1065 |
|
---|
1066 | /** The render targets. */
|
---|
1067 | RenderTargetMap mRenderTargets;
|
---|
1068 | /** The render targets, ordered by priority. */
|
---|
1069 | RenderTargetPriorityMap mPrioritisedRenderTargets;
|
---|
1070 | /** The Active render target. */
|
---|
1071 | RenderTarget * mActiveRenderTarget;
|
---|
1072 | /** The Active GPU programs and gpu program parameters*/
|
---|
1073 | GpuProgramParametersSharedPtr mActiveVertexGpuProgramParameters;
|
---|
1074 | GpuProgramParametersSharedPtr mActiveFragmentGpuProgramParameters;
|
---|
1075 |
|
---|
1076 | // Texture manager
|
---|
1077 | // A concrete class of this will be created and
|
---|
1078 | // made available under the TextureManager singleton,
|
---|
1079 | // managed by the RenderSystem
|
---|
1080 | TextureManager* mTextureManager;
|
---|
1081 |
|
---|
1082 | /// Used to store the capabilities of the graphics card
|
---|
1083 | RenderSystemCapabilities* mCapabilities;
|
---|
1084 |
|
---|
1085 | // Active viewport (dest for future rendering operations)
|
---|
1086 | Viewport* mActiveViewport;
|
---|
1087 |
|
---|
1088 | CullingMode mCullingMode;
|
---|
1089 |
|
---|
1090 | bool mVSync;
|
---|
1091 | bool mWBuffer;
|
---|
1092 |
|
---|
1093 | size_t mFaceCount;
|
---|
1094 | size_t mVertexCount;
|
---|
1095 |
|
---|
1096 | /// Saved set of world matrices
|
---|
1097 | Matrix4 mWorldMatrices[256];
|
---|
1098 |
|
---|
1099 | /// Saved manual colour blends
|
---|
1100 | ColourValue mManualBlendColours[OGRE_MAX_TEXTURE_LAYERS][2];
|
---|
1101 |
|
---|
1102 | bool mInvertVertexWinding;
|
---|
1103 |
|
---|
1104 | /// number of times to render the current state
|
---|
1105 | size_t mCurrentPassIterationCount;
|
---|
1106 |
|
---|
1107 | /** updates pass iteration rendering state including bound gpu program parameter
|
---|
1108 | pass iteration auto constant entry
|
---|
1109 | @returns True if more iterations are required
|
---|
1110 | */
|
---|
1111 | bool updatePassIterationRenderState(void);
|
---|
1112 |
|
---|
1113 | /// List of names of events this rendersystem may raise
|
---|
1114 | StringVector mEventNames;
|
---|
1115 |
|
---|
1116 | /// Internal method for firing a rendersystem event
|
---|
1117 | virtual void fireEvent(const String& name, const NameValuePairList* params = 0);
|
---|
1118 |
|
---|
1119 | typedef std::list<Listener*> ListenerList;
|
---|
1120 | ListenerList mEventListeners;
|
---|
1121 |
|
---|
1122 | typedef std::list<HardwareOcclusionQuery*> HardwareOcclusionQueryList;
|
---|
1123 | HardwareOcclusionQueryList mHwOcclusionQueries;
|
---|
1124 |
|
---|
1125 | bool mVertexProgramBound;
|
---|
1126 | bool mFragmentProgramBound;
|
---|
1127 |
|
---|
1128 |
|
---|
1129 |
|
---|
1130 | };
|
---|
1131 | }
|
---|
1132 |
|
---|
1133 | #endif
|
---|