Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/ogre_src_v1-9-0/OgreMain/include/OgreRenderSystem.h @ 148

Last change on this file since 148 was 148, checked in by patricwi, 6 years ago

Added new dependencies for ogre1.9 and cegui0.8

File size: 69.1 KB
Line 
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4(Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org
6
7Copyright (c) 2000-2013 Torus Knot Software Ltd
8
9Permission is hereby granted, free of charge, to any person obtaining a copy
10of this software and associated documentation files (the "Software"), to deal
11in the Software without restriction, including without limitation the rights
12to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13copies of the Software, and to permit persons to whom the Software is
14furnished to do so, subject to the following conditions:
15
16The above copyright notice and this permission notice shall be included in
17all copies or substantial portions of the Software.
18
19THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25THE SOFTWARE.
26-----------------------------------------------------------------------------
27*/
28#ifndef __RenderSystem_H_
29#define __RenderSystem_H_
30
31// Precompiler options
32#include "OgrePrerequisites.h"
33
34#include "OgreString.h"
35
36#include "OgreTextureUnitState.h"
37#include "OgreCommon.h"
38
39#include "OgreMaterialManager.h"
40#include "OgreRenderOperation.h"
41#include "OgreRenderSystemCapabilities.h"
42#include "OgreRenderTarget.h"
43#include "OgreRenderTexture.h"
44#include "OgreFrameListener.h"
45#include "OgreConfigOptionMap.h"
46#include "OgreGpuProgram.h"
47#include "OgrePlane.h"
48#include "OgreIteratorWrappers.h"
49#include "OgreHeaderPrefix.h"
50
51namespace Ogre
52{
53        /** \addtogroup Core
54        *  @{
55        */
56        /** \addtogroup RenderSystem
57        *  @{
58        */
59
60        typedef vector<DepthBuffer*>::type DepthBufferVec;
61        typedef map< uint16, DepthBufferVec >::type DepthBufferMap;
62        typedef map< String, RenderTarget * >::type RenderTargetMap;
63        typedef multimap<uchar, RenderTarget * >::type RenderTargetPriorityMap;
64
65        class TextureManager;
66        /// Enum describing the ways to generate texture coordinates
67        enum TexCoordCalcMethod
68        {
69                /// No calculated texture coordinates
70                TEXCALC_NONE,
71                /// Environment map based on vertex normals
72                TEXCALC_ENVIRONMENT_MAP,
73                /// Environment map based on vertex positions
74                TEXCALC_ENVIRONMENT_MAP_PLANAR,
75                TEXCALC_ENVIRONMENT_MAP_REFLECTION,
76                TEXCALC_ENVIRONMENT_MAP_NORMAL,
77                /// Projective texture
78                TEXCALC_PROJECTIVE_TEXTURE
79        };
80        /// Enum describing the various actions which can be taken on the stencil buffer
81        enum StencilOperation
82        {
83                /// Leave the stencil buffer unchanged
84                SOP_KEEP,
85                /// Set the stencil value to zero
86                SOP_ZERO,
87                /// Set the stencil value to the reference value
88                SOP_REPLACE,
89                /// Increase the stencil value by 1, clamping at the maximum value
90                SOP_INCREMENT,
91                /// Decrease the stencil value by 1, clamping at 0
92                SOP_DECREMENT,
93                /// Increase the stencil value by 1, wrapping back to 0 when incrementing the maximum value
94                SOP_INCREMENT_WRAP,
95                /// Decrease the stencil value by 1, wrapping when decrementing 0
96                SOP_DECREMENT_WRAP,
97                /// Invert the bits of the stencil buffer
98                SOP_INVERT
99        };
100
101
102        /** Defines the functionality of a 3D API
103        @remarks
104        The RenderSystem class provides a base interface
105        which abstracts the general functionality of the 3D API
106        e.g. Direct3D or OpenGL. Whilst a few of the general
107        methods have implementations, most of this class is
108        abstract, requiring a subclass based on a specific API
109        to be constructed to provide the full functionality.
110        Note there are 2 levels to the interface - one which
111        will be used often by the caller of the Ogre library,
112        and one which is at a lower level and will be used by the
113        other classes provided by Ogre. These lower level
114        methods are prefixed with '_' to differentiate them.
115        The advanced user of the library may use these lower
116        level methods to access the 3D API at a more fundamental
117        level (dealing direct with render states and rendering
118        primitives), but still benefiting from Ogre's abstraction
119        of exactly which 3D API is in use.
120        @author
121        Steven Streeting
122        @version
123        1.0
124        */
125        class _OgreExport RenderSystem : public RenderSysAlloc
126        {
127        public:
128                /** Default Constructor.
129                */
130                RenderSystem();
131
132                /** Destructor.
133                */
134                virtual ~RenderSystem();
135
136                /** Returns the name of the rendering system.
137                */
138                virtual const String& getName(void) const = 0;
139
140                /** Returns the details of this API's configuration options
141                @remarks
142                Each render system must be able to inform the world
143                of what options must/can be specified for it's
144                operation.
145                @par
146                These are passed as strings for portability, but
147                grouped into a structure (_ConfigOption) which includes
148                both options and current value.
149                @par
150                Note that the settings returned from this call are
151                affected by the options that have been set so far,
152                since some options are interdependent.
153                @par
154                This routine is called automatically by the default
155                configuration dialogue produced by Root::showConfigDialog
156                or may be used by the caller for custom settings dialogs
157                @return
158                A 'map' of options, i.e. a list of options which is also
159                indexed by option name.
160                */
161                virtual ConfigOptionMap& getConfigOptions(void) = 0;
162
163                /** Sets an option for this API
164                @remarks
165                Used to confirm the settings (normally chosen by the user) in
166                order to make the renderer able to initialise with the settings as required.
167                This may be video mode, D3D driver, full screen / windowed etc.
168                Called automatically by the default configuration
169                dialog, and by the restoration of saved settings.
170                These settings are stored and only activated when
171                RenderSystem::initialise or RenderSystem::reinitialise
172                are called.
173                @par
174                If using a custom configuration dialog, it is advised that the
175                caller calls RenderSystem::getConfigOptions
176                again, since some options can alter resulting from a selection.
177                @param
178                name The name of the option to alter.
179                @param
180                value The value to set the option to.
181                */
182                virtual void setConfigOption(const String &name, const String &value) = 0;
183
184                /** Create an object for performing hardware occlusion queries.
185                */
186                virtual HardwareOcclusionQuery* createHardwareOcclusionQuery(void) = 0;
187
188                /** Destroy a hardware occlusion query object.
189                */
190                virtual void destroyHardwareOcclusionQuery(HardwareOcclusionQuery *hq);
191
192                /** Validates the options set for the rendering system, returning a message if there are problems.
193                @note
194                If the returned string is empty, there are no problems.
195                */
196                virtual String validateConfigOptions(void) = 0;
197
198                /** Start up the renderer using the settings selected (Or the defaults if none have been selected).
199                @remarks
200                Called by Root::setRenderSystem. Shouldn't really be called
201                directly, although  this can be done if the app wants to.
202                @param
203                autoCreateWindow If true, creates a render window
204                automatically, based on settings chosen so far. This saves
205                an extra call to _createRenderWindow
206                for the main render window.
207                @param
208                windowTitle Sets the app window title
209                @return
210                A pointer to the automatically created window, if requested, otherwise null.
211                */
212                virtual RenderWindow* _initialise(bool autoCreateWindow, const String& windowTitle = "OGRE Render Window");
213
214                /*
215                Returns whether under the current render system buffers marked as TU_STATIC can be locked for update
216                @remarks
217                Needed in the implementation of DirectX9 with DirectX9Ex driver
218                */
219                virtual bool isStaticBufferLockable() const { return true; }
220
221                /** Query the real capabilities of the GPU and driver in the RenderSystem*/
222                virtual RenderSystemCapabilities* createRenderSystemCapabilities() const = 0;
223 
224                /** Get a pointer to the current capabilities being used by the RenderSystem.
225                @remarks
226                The capabilities may be modified using this pointer, this will only have an effect
227                before the RenderSystem has been initialised. It's intended use is to allow a
228                listener of the RenderSystemCapabilitiesCreated event to customise the capabilities
229                on the fly before the RenderSystem is initialised.
230                */
231                RenderSystemCapabilities* getMutableCapabilities(){ return mCurrentCapabilities; }
232
233                /** Force the render system to use the special capabilities. Can only be called
234                *    before the render system has been fully initializer (before createWindow is called)
235                *       @param
236                *                capabilities has to be a subset of the real capabilities and the caller is
237                *                responsible for deallocating capabilities.
238                */
239                virtual void useCustomRenderSystemCapabilities(RenderSystemCapabilities* capabilities);
240
241                /** Restart the renderer (normally following a change in settings).
242                */
243                virtual void reinitialise(void) = 0;
244
245                /** Shutdown the renderer and cleanup resources.
246                */
247                virtual void shutdown(void);
248
249
250                /** Sets the colour & strength of the ambient (global directionless) light in the world.
251                */
252                virtual void setAmbientLight(float r, float g, float b) = 0;
253
254                /** Sets the type of light shading required (default = Gouraud).
255                */
256                virtual void setShadingType(ShadeOptions so) = 0;
257
258                /** Sets whether or not dynamic lighting is enabled.
259                @param
260                enabled If true, dynamic lighting is performed on geometry with normals supplied, geometry without
261                normals will not be displayed. If false, no lighting is applied and all geometry will be full brightness.
262                */
263                virtual void setLightingEnabled(bool enabled) = 0;
264
265                /** Sets whether or not W-buffers are enabled if they are available for this renderer.
266                @param
267                enabled If true and the renderer supports them W-buffers will be used.  If false
268                W-buffers will not be used even if available.  W-buffers are enabled by default
269                for 16bit depth buffers and disabled for all other depths.
270                */
271                void setWBufferEnabled(bool enabled);
272
273                /** Returns true if the renderer will try to use W-buffers when available.
274                */
275                bool getWBufferEnabled(void) const;
276
277                /** Creates a new rendering window.
278                @remarks
279                This method creates a new rendering window as specified
280                by the paramteters. The rendering system could be
281                responible for only a single window (e.g. in the case
282                of a game), or could be in charge of multiple ones (in the
283                case of a level editor). The option to create the window
284                as a child of another is therefore given.
285                This method will create an appropriate subclass of
286                RenderWindow depending on the API and platform implementation.
287                @par
288                After creation, this window can be retrieved using getRenderTarget().
289                @param
290                name The name of the window. Used in other methods
291                later like setRenderTarget and getRenderTarget.
292                @param
293                width The width of the new window.
294                @param
295                height The height of the new window.
296                @param
297                fullScreen Specify true to make the window full screen
298                without borders, title bar or menu bar.
299                @param
300                miscParams A NameValuePairList describing the other parameters for the new rendering window.
301                Options are case sensitive. Unrecognised parameters will be ignored silently.
302                These values might be platform dependent, but these are present for all platforms unless
303                indicated otherwise:
304                <table>
305                <tr>
306                        <td><b>Key</b></td>
307                        <td><b>Type/Values</b></td>
308                        <td><b>Default</b></td>
309                        <td><b>Description</b></td>
310                        <td><b>Notes</b></td>
311                </tr>
312                <tr>
313                        <td>title</td>
314                        <td>Any string</td>
315                        <td>RenderTarget name</td>
316                        <td>The title of the window that will appear in the title bar</td>
317                        <td>&nbsp;</td>
318                </tr>
319                <tr>
320                        <td>colourDepth</td>
321                        <td>16, 32</td>
322                        <td>Desktop depth</td>
323                        <td>Colour depth of the resulting rendering window; only applies if fullScreen</td>
324                        <td>Win32 Specific</td>
325                </tr>
326                <tr>
327                        <td>left</td>
328                        <td>Positive integers</td>
329                        <td>Centred</td>
330                        <td>Screen x coordinate from left</td>
331                        <td>&nbsp;</td>
332                </tr>
333                <tr>
334                        <td>top</td>
335                        <td>Positive integers</td>
336                        <td>Centred</td>
337                        <td>Screen y coordinate from left</td>
338                        <td>&nbsp;</td>
339                </tr>
340                <tr>
341                        <td>depthBuffer</td>
342                        <td>true, false</td>
343                        <td>true</td>
344                        <td>Use depth buffer</td>
345                        <td>DirectX9 specific</td>
346                </tr>
347                <tr>
348                        <td>externalWindowHandle</td>
349                        <td>Win32: HWND as integer<br/>
350                            GLX: poslong:posint:poslong (display*:screen:windowHandle) or poslong:posint:poslong:poslong (display*:screen:windowHandle:XVisualInfo*)<br/>
351                OS X: WindowRef for Carbon or NSWindow for Cocoa address as an integer
352                iOS: UIWindow address as an integer
353            </td>
354                        <td>0 (none)</td>
355                        <td>External window handle, for embedding the OGRE render in an existing window</td>
356                        <td>&nbsp;</td>
357                </tr>
358                <tr>
359                        <td>externalGLControl</td>
360                        <td>true, false</td>
361                        <td>false</td>
362                        <td>Let the external window control OpenGL i.e. don't select a pixel format for the window,
363                        do not change v-sync and do not swap buffer. When set to true, the calling application
364                        is responsible of OpenGL initialization and buffer swapping. It should also create an
365                        OpenGL context for its own rendering, Ogre will create one for its use. Then the calling
366                        application must also enable Ogre OpenGL context before calling any Ogre function and
367                        restore its OpenGL context after these calls.</td>
368                        <td>OpenGL specific</td>
369                </tr>
370                <tr>
371                        <td>externalGLContext</td>
372                        <td>Context as Unsigned Long</td>
373                        <td>0 (create own context)</td>
374                        <td>Use an externally created GL context</td>
375                        <td>OpenGL Specific</td>
376                </tr>
377                <tr>
378                        <td>parentWindowHandle</td>
379                        <td>Win32: HWND as integer<br/>
380                            GLX: poslong:posint:poslong (display*:screen:windowHandle) or poslong:posint:poslong:poslong (display*:screen:windowHandle:XVisualInfo*)</td>
381                        <td>0 (none)</td>
382                        <td>Parent window handle, for embedding the OGRE in a child of an external window</td>
383                        <td>&nbsp;</td>
384                </tr>
385                <tr>
386                        <td>macAPI</td>
387                        <td>String: "cocoa" or "carbon"</td>
388                        <td>"carbon"</td>
389                        <td>Specifies the type of rendering window on the Mac Platform.</td>
390            <td>Mac OS X Specific</td>
391                        <td>&nbsp;</td>
392                 </tr>
393                 <tr>
394                        <td>macAPICocoaUseNSView</td>
395                        <td>bool "true" or "false"</td>
396                        <td>"false"</td>
397                        <td>On the Mac platform the most diffused method to embed OGRE in a custom application is to use Interface Builder
398                                and add to the interface an instance of OgreView.
399                                The pointer to this instance is then used as "externalWindowHandle".
400                                However, there are cases where you are NOT using Interface Builder and you get the Cocoa NSView* of an existing interface.
401                                For example, this is happens when you want to render into a Java/AWT interface.
402                                In short, by setting this flag to "true" the Ogre::Root::createRenderWindow interprets the "externalWindowHandle" as a NSView*
403                                instead of an OgreView*. See OgreOSXCocoaView.h/mm.
404                        </td>
405            <td>Mac OS X Specific</td>
406                        <td>&nbsp;</td>
407                 </tr>
408         <tr>
409             <td>contentScalingFactor</td>
410             <td>Positive Float greater than 1.0</td>
411             <td>The default content scaling factor of the screen</td>
412             <td>Specifies the CAEAGLLayer content scaling factor.  Only supported on iOS 4 or greater.
413                 This can be useful to limit the resolution of the OpenGL ES backing store.  For example, the iPhone 4's
414                 native resolution is 960 x 640.  Windows are always 320 x 480, if you would like to limit the display
415                 to 720 x 480, specify 1.5 as the scaling factor.
416             </td>
417             <td>iOS Specific</td>
418             <td>&nbsp;</td>
419                 </tr>
420         <tr>
421             <td>externalViewHandle</td>
422             <td>UIView pointer as an integer</td>
423             <td>0</td>
424             <td>External view handle, for rendering OGRE render in an existing view</td>
425             <td>iOS Specific</td>
426             <td>&nbsp;</td>
427         </tr>
428         <tr>
429             <td>externalViewControllerHandle</td>
430             <td>UIViewController pointer as an integer</td>
431             <td>0</td>
432             <td>External view controller handle, for embedding OGRE in an existing view controller</td>
433             <td>iOS Specific</td>
434             <td>&nbsp;</td>
435         </tr>
436         <tr>
437             <td>externalSharegroup</td>
438             <td>EAGLSharegroup pointer as an integer</td>
439             <td>0</td>
440             <td>External sharegroup, used to shared GL resources between contexts</td>
441             <td>iOS Specific</td>
442             <td>&nbsp;</td>
443         </tr>
444         <tr>
445             <td>Full Screen</td>
446             <td>true, false</td>
447             <td>false</td>
448             <td>Specify whether to create the window in full screen mode</td>
449             <td>OS X Specific</td>
450             <td>&nbsp;</td>
451         </tr>
452         <tr>
453                        <td>FSAA</td>
454                        <td>Positive integer (usually 0, 2, 4, 8, 16)</td>
455                        <td>0</td>
456                        <td>Full screen antialiasing factor</td>
457                        <td>&nbsp;</td>
458                </tr>
459                <tr>
460                        <td>FSAAHint</td>
461                        <td>Depends on RenderSystem and hardware. Currently supports:<br/>
462                        "Quality": on systems that have an option to prefer higher AA quality over speed, use it</td>
463                        <td>Blank</td>
464                        <td>Full screen antialiasing hint</td>
465                        <td>&nbsp;</td>
466                </tr>
467                <tr>
468                        <td>displayFrequency</td>
469                        <td>Refresh rate in Hertz (e.g. 60, 75, 100)</td>
470                        <td>Desktop vsync rate</td>
471                        <td>Display frequency rate, for fullscreen mode</td>
472                        <td>&nbsp;</td>
473                </tr>
474                <tr>
475                        <td>vsync</td>
476                        <td>true, false</td>
477                        <td>false</td>
478                        <td>Synchronize buffer swaps to monitor vsync, eliminating tearing at the expense of a fixed frame rate</td>
479                        <td>&nbsp;</td>
480                </tr>
481                <tr>
482                        <td>vsyncInterval</td>
483                        <td>1, 2, 3, 4</td>
484                        <td>1</td>
485                        <td>If vsync is enabled, the minimum number of vertical blanks that should occur between renders.
486                        For example if vsync is enabled, the refresh rate is 60 and this is set to 2, then the
487                        frame rate will be locked at 30.</td>
488                        <td>&nbsp;</td>
489                </tr>
490                <tr>
491                        <td>border</td>
492                        <td>none, fixed, resize</td>
493                        <td>resize</td>
494                        <td>The type of window border (in windowed mode)</td>
495                        <td>&nbsp;</td>
496                </tr>
497                <tr>
498                        <td>outerDimensions</td>
499                        <td>true, false</td>
500                        <td>false</td>
501                        <td>Whether the width/height is expressed as the size of the
502                        outer window, rather than the content area</td>
503                        <td>&nbsp;</td>
504                </tr>
505                <tr>
506                        <td>useNVPerfHUD</td>
507                        <td>true, false</td>
508                        <td>false</td>
509                        <td>Enable the use of nVidia NVPerfHUD</td>
510                        <td>&nbsp;</td>
511                </tr>
512                <tr>
513                        <td>gamma</td>
514                        <td>true, false</td>
515                        <td>false</td>
516                        <td>Enable hardware conversion from linear colour space to gamma
517                        colour space on rendering to the window.</td>
518                        <td>&nbsp;</td>
519                </tr>
520                <tr>
521                        <td>enableDoubleClick</td>
522                        <td>true, false</td>
523                        <td>false</td>
524                        <td>Enable the window to keep track and transmit double click messages.</td>
525                        <td>Win32 Specific</td>
526                </tr>
527               
528                */
529                virtual RenderWindow* _createRenderWindow(const String &name, unsigned int width, unsigned int height, 
530                        bool fullScreen, const NameValuePairList *miscParams = 0) = 0;
531
532                /** Creates multiple rendering windows.         
533                @param
534                renderWindowDescriptions Array of structures containing the descriptions of each render window.
535                The structure's members are the same as the parameters of _createRenderWindow:
536                * name
537                * width
538                * height
539                * fullScreen
540                * miscParams
541                See _createRenderWindow for details about each member.         
542                @param
543                createdWindows This array will hold the created render windows.
544                @return
545                true on success.               
546                */
547                virtual bool _createRenderWindows(const RenderWindowDescriptionList& renderWindowDescriptions, 
548                        RenderWindowList& createdWindows);
549
550               
551                /**     Create a MultiRenderTarget, which is a render target that renders to multiple RenderTextures
552                at once. Surfaces can be bound and unbound at will.
553                This fails if mCapabilities->getNumMultiRenderTargets() is smaller than 2.
554                */
555                virtual MultiRenderTarget * createMultiRenderTarget(const String & name) = 0; 
556
557                /** Destroys a render window */
558                virtual void destroyRenderWindow(const String& name);
559                /** Destroys a render texture */
560                virtual void destroyRenderTexture(const String& name);
561                /** Destroys a render target of any sort */
562                virtual void destroyRenderTarget(const String& name);
563
564                /** Attaches the passed render target to the render system.
565                */
566                virtual void attachRenderTarget( RenderTarget &target );
567                /** Returns a pointer to the render target with the passed name, or NULL if that
568                render target cannot be found.
569                */
570                virtual RenderTarget * getRenderTarget( const String &name );
571                /** Detaches the render target with the passed name from the render system and
572                returns a pointer to it.
573                @note
574                If the render target cannot be found, NULL is returned.
575                */
576                virtual RenderTarget * detachRenderTarget( const String &name );
577
578                /// Iterator over RenderTargets
579                typedef MapIterator<Ogre::RenderTargetMap> RenderTargetIterator;
580
581                /** Returns a specialised MapIterator over all render targets attached to the RenderSystem. */
582                virtual RenderTargetIterator getRenderTargetIterator(void) {
583                        return RenderTargetIterator( mRenderTargets.begin(), mRenderTargets.end() );
584                }
585                /** Returns a description of an error code.
586                */
587                virtual String getErrorDescription(long errorNumber) const = 0;
588
589                /** Returns the global instance vertex buffer.
590                */
591        HardwareVertexBufferSharedPtr getGlobalInstanceVertexBuffer() const;
592                /** Sets the global instance vertex buffer.
593                */
594        void setGlobalInstanceVertexBuffer(const HardwareVertexBufferSharedPtr &val);
595                /** Gets vertex declaration for the global vertex buffer for the global instancing
596                */
597        VertexDeclaration* getGlobalInstanceVertexBufferVertexDeclaration() const;
598                /** Sets vertex declaration for the global vertex buffer for the global instancing
599                */
600        void setGlobalInstanceVertexBufferVertexDeclaration( VertexDeclaration* val);
601                /** Gets the global number of instances.
602                */
603        size_t getGlobalNumberOfInstances() const;
604                /** Sets the global number of instances.
605                */
606        void setGlobalNumberOfInstances(const size_t val);
607
608                /** Sets if fixed pipeline rendering is enabled on the system.
609                */
610                void setFixedPipelineEnabled(bool enabled);
611
612                /** Returns true if fixed pipeline rendering is enabled on the system.
613                */
614                bool getFixedPipelineEnabled(void) const;
615
616                /** Retrieves an existing DepthBuffer or creates a new one suited for the given RenderTarget
617                        and sets it.
618                        @remarks
619                                RenderTarget's pool ID is respected. @see RenderTarget::setDepthBufferPool()
620                */
621                virtual void setDepthBufferFor( RenderTarget *renderTarget );
622
623                // ------------------------------------------------------------------------
624                //                     Internal Rendering Access
625                // All methods below here are normally only called by other OGRE classes
626                // They can be called by library user if required
627                // ------------------------------------------------------------------------
628
629
630                /** Tells the rendersystem to use the attached set of lights (and no others)
631                up to the number specified (this allows the same list to be used with different
632                count limits) */
633                virtual void _useLights(const LightList& lights, unsigned short limit) = 0;
634                /** Are fixed-function lights provided in view space? Affects optimisation.
635                */
636                virtual bool areFixedFunctionLightsInViewSpace() const { return false; }
637                /** Sets the world transform matrix. */
638                virtual void _setWorldMatrix(const Matrix4 &m) = 0;
639                /** Sets multiple world matrices (vertex blending). */
640                virtual void _setWorldMatrices(const Matrix4* m, unsigned short count);
641                /** Sets the view transform matrix */
642                virtual void _setViewMatrix(const Matrix4 &m) = 0;
643                /** Sets the projection transform matrix */
644                virtual void _setProjectionMatrix(const Matrix4 &m) = 0;
645                /** Utility function for setting all the properties of a texture unit at once.
646                This method is also worth using over the individual texture unit settings because it
647                only sets those settings which are different from the current settings for this
648                unit, thus minimising render state changes.
649                */
650                virtual void _setTextureUnitSettings(size_t texUnit, TextureUnitState& tl);
651                /** Turns off a texture unit. */
652                virtual void _disableTextureUnit(size_t texUnit);
653                /** Disables all texture units from the given unit upwards */
654                virtual void _disableTextureUnitsFrom(size_t texUnit);
655                /** Sets the surface properties to be used for future rendering.
656
657                This method sets the the properties of the surfaces of objects
658                to be rendered after it. In this context these surface properties
659                are the amount of each type of light the object reflects (determining
660                it's colour under different types of light), whether it emits light
661                itself, and how shiny it is. Textures are not dealt with here,
662                see the _setTetxure method for details.
663                This method is used by _setMaterial so does not need to be called
664                direct if that method is being used.
665
666                @param ambient The amount of ambient (sourceless and directionless)
667                light an object reflects. Affected by the colour/amount of ambient light in the scene.
668                @param diffuse The amount of light from directed sources that is
669                reflected (affected by colour/amount of point, directed and spot light sources)
670                @param specular The amount of specular light reflected. This is also
671                affected by directed light sources but represents the colour at the
672                highlights of the object.
673                @param emissive The colour of light emitted from the object. Note that
674                this will make an object seem brighter and not dependent on lights in
675                the scene, but it will not act as a light, so will not illuminate other
676                objects. Use a light attached to the same SceneNode as the object for this purpose.
677                @param shininess A value which only has an effect on specular highlights (so
678                specular must be non-black). The higher this value, the smaller and crisper the
679                specular highlights will be, imitating a more highly polished surface.
680                This value is not constrained to 0.0-1.0, in fact it is likely to
681                be more (10.0 gives a modest sheen to an object).
682                @param tracking A bit field that describes which of the ambient, diffuse, specular
683                and emissive colours follow the vertex colour of the primitive. When a bit in this field is set
684                its ColourValue is ignored. This is a combination of TVC_AMBIENT, TVC_DIFFUSE, TVC_SPECULAR(note that the shininess value is still
685                taken from shininess) and TVC_EMISSIVE. TVC_NONE means that there will be no material property
686                tracking the vertex colours.
687                */
688                virtual void _setSurfaceParams(const ColourValue &ambient,
689                        const ColourValue &diffuse, const ColourValue &specular,
690                        const ColourValue &emissive, Real shininess,
691                        TrackVertexColourType tracking = TVC_NONE) = 0;
692
693                /** Sets whether or not rendering points using OT_POINT_LIST will
694                render point sprites (textured quads) or plain points.
695                @param enabled True enables point sprites, false returns to normal
696                point rendering.
697                */     
698                virtual void _setPointSpritesEnabled(bool enabled) = 0;
699
700                /** Sets the size of points and how they are attenuated with distance.
701                @remarks
702                When performing point rendering or point sprite rendering,
703                point size can be attenuated with distance. The equation for
704                doing this is attenuation = 1 / (constant + linear * dist + quadratic * d^2) .
705                @par
706                For example, to disable distance attenuation (constant screensize)
707                you would set constant to 1, and linear and quadratic to 0. A
708                standard perspective attenuation would be 0, 1, 0 respectively.
709                */
710                virtual void _setPointParameters(Real size, bool attenuationEnabled, 
711                        Real constant, Real linear, Real quadratic, Real minSize, Real maxSize) = 0;
712
713
714                /**
715                Sets the texture to bind to a given texture unit.
716
717                User processes would not normally call this direct unless rendering
718                primitives themselves.
719
720                @param unit The index of the texture unit to modify. Multitexturing
721                hardware can support multiple units (see
722                RenderSystemCapabilites::getNumTextureUnits)
723                @param enabled Boolean to turn the unit on/off
724                @param texPtr Pointer to the texture to use.
725                */
726                virtual void _setTexture(size_t unit, bool enabled, 
727                        const TexturePtr &texPtr) = 0;
728                /**
729                Sets the texture to bind to a given texture unit.
730
731                User processes would not normally call this direct unless rendering
732                primitives themselves.
733
734                @param unit The index of the texture unit to modify. Multitexturing
735                hardware can support multiple units (see
736                RenderSystemCapabilites::getNumTextureUnits)
737                @param enabled Boolean to turn the unit on/off
738                @param texname The name of the texture to use - this should have
739                already been loaded with TextureManager::load.
740                */
741                virtual void _setTexture(size_t unit, bool enabled, const String &texname);
742
743                /** Binds a texture to a vertex sampler.
744                @remarks
745                Not all rendersystems support separate vertex samplers. For those that
746                do, you can set a texture for them, separate to the regular texture
747                samplers, using this method. For those that don't, you should use the
748                regular texture samplers which are shared between the vertex and
749                fragment units; calling this method will throw an exception.
750                @see RenderSystemCapabilites::getVertexTextureUnitsShared
751                */
752                virtual void _setVertexTexture(size_t unit, const TexturePtr& tex);
753
754                /**
755                Sets the texture coordinate set to use for a texture unit.
756
757                Meant for use internally - not generally used directly by apps - the Material and TextureUnitState
758                classes let you manage textures far more easily.
759
760                @param unit Texture unit as above
761                @param index The index of the texture coordinate set to use.
762                */
763                virtual void _setTextureCoordSet(size_t unit, size_t index) = 0;
764
765                /**
766                Sets a method for automatically calculating texture coordinates for a stage.
767                Should not be used by apps - for use by Ogre only.
768                @param unit Texture unit as above
769                @param m Calculation method to use
770                @param frustum Optional Frustum param, only used for projective effects
771                */
772                virtual void _setTextureCoordCalculation(size_t unit, TexCoordCalcMethod m, 
773                        const Frustum* frustum = 0) = 0;
774
775                /** Sets the texture blend modes from a TextureUnitState record.
776                Meant for use internally only - apps should use the Material
777                and TextureUnitState classes.
778                @param unit Texture unit as above
779                @param bm Details of the blending mode
780                */
781                virtual void _setTextureBlendMode(size_t unit, const LayerBlendModeEx& bm) = 0;
782
783                /** Sets the filtering options for a given texture unit.
784                @param unit The texture unit to set the filtering options for
785                @param minFilter The filter used when a texture is reduced in size
786                @param magFilter The filter used when a texture is magnified
787                @param mipFilter The filter used between mipmap levels, FO_NONE disables mipmapping
788                */
789                virtual void _setTextureUnitFiltering(size_t unit, FilterOptions minFilter,
790                        FilterOptions magFilter, FilterOptions mipFilter);
791
792                /** Sets a single filter for a given texture unit.
793                @param unit The texture unit to set the filtering options for
794                @param ftype The filter type
795                @param filter The filter to be used
796                */
797                virtual void _setTextureUnitFiltering(size_t unit, FilterType ftype, FilterOptions filter) = 0;
798
799                /** Sets whether the compare func is enabled or not for this texture unit
800                @param unit The texture unit to set the filtering options for
801                @param compare The state (enabled/disabled)
802                */
803                virtual void _setTextureUnitCompareEnabled(size_t unit, bool compare) = 0;
804
805
806                /** Sets the compare function to use for a given texture unit
807                @param unit The texture unit to set the filtering options for
808                @param function The comparison function
809                */
810                virtual void _setTextureUnitCompareFunction(size_t unit, CompareFunction function) = 0;
811
812
813                /** Sets the maximal anisotropy for the specified texture unit.*/
814                virtual void _setTextureLayerAnisotropy(size_t unit, unsigned int maxAnisotropy) = 0;
815
816                /** Sets the texture addressing mode for a texture unit.*/
817                virtual void _setTextureAddressingMode(size_t unit, const TextureUnitState::UVWAddressingMode& uvw) = 0;
818
819                /** Sets the texture border colour for a texture unit.*/
820                virtual void _setTextureBorderColour(size_t unit, const ColourValue& colour) = 0;
821
822                /** Sets the mipmap bias value for a given texture unit.
823                @remarks
824                This allows you to adjust the mipmap calculation up or down for a
825                given texture unit. Negative values force a larger mipmap to be used,
826                positive values force a smaller mipmap to be used. Units are in numbers
827                of levels, so +1 forces the mipmaps to one smaller level.
828                @note Only does something if render system has capability RSC_MIPMAP_LOD_BIAS.
829                */
830                virtual void _setTextureMipmapBias(size_t unit, float bias) = 0;
831
832                /** Sets the texture coordinate transformation matrix for a texture unit.
833                @param unit Texture unit to affect
834                @param xform The 4x4 matrix
835                */
836                virtual void _setTextureMatrix(size_t unit, const Matrix4& xform) = 0;
837
838                /** Sets the global blending factors for combining subsequent renders with the existing frame contents.
839                The result of the blending operation is:
840                <p align="center">final = (texture * sourceFactor) + (pixel * destFactor)</p>
841                Each of the factors is specified as one of a number of options, as specified in the SceneBlendFactor
842                enumerated type.
843                By changing the operation you can change addition between the source and destination pixels to a different operator.
844                @param sourceFactor The source factor in the above calculation, i.e. multiplied by the texture colour components.
845                @param destFactor The destination factor in the above calculation, i.e. multiplied by the pixel colour components.
846                @param op The blend operation mode for combining pixels
847                */
848                virtual void _setSceneBlending(SceneBlendFactor sourceFactor, SceneBlendFactor destFactor, SceneBlendOperation op = SBO_ADD) = 0;
849
850                /** Sets the global blending factors for combining subsequent renders with the existing frame contents.
851                The result of the blending operation is:
852                <p align="center">final = (texture * sourceFactor) + (pixel * destFactor)</p>
853                Each of the factors is specified as one of a number of options, as specified in the SceneBlendFactor
854                enumerated type.
855                @param sourceFactor The source factor in the above calculation, i.e. multiplied by the texture colour components.
856                @param destFactor The destination factor in the above calculation, i.e. multiplied by the pixel colour components.
857                @param sourceFactorAlpha The source factor in the above calculation for the alpha channel, i.e. multiplied by the texture alpha components.
858                @param destFactorAlpha The destination factor in the above calculation for the alpha channel, i.e. multiplied by the pixel alpha components.
859                @param op The blend operation mode for combining pixels
860                @param alphaOp The blend operation mode for combining pixel alpha values
861                */
862                virtual void _setSeparateSceneBlending(SceneBlendFactor sourceFactor, SceneBlendFactor destFactor, SceneBlendFactor sourceFactorAlpha, 
863                        SceneBlendFactor destFactorAlpha, SceneBlendOperation op = SBO_ADD, SceneBlendOperation alphaOp = SBO_ADD) = 0;
864
865                /** Sets the global alpha rejection approach for future renders.
866                By default images are rendered regardless of texture alpha. This method lets you change that.
867                @param func The comparison function which must pass for a pixel to be written.
868                @param value The value to compare each pixels alpha value to (0-255)
869                @param alphaToCoverage Whether to enable alpha to coverage, if supported
870                */
871                virtual void _setAlphaRejectSettings(CompareFunction func, unsigned char value, bool alphaToCoverage) = 0;
872
873                /** Notify the rendersystem that it should adjust texture projection to be
874                        relative to a different origin.
875                */
876                virtual void _setTextureProjectionRelativeTo(bool enabled, const Vector3& pos);
877
878                /** Creates a DepthBuffer that can be attached to the specified RenderTarget
879                        @remarks
880                                It doesn't attach anything, it just returns a pointer to a new DepthBuffer
881                                Caller is responsible for putting this buffer into the right pool, for
882                                attaching, and deleting it. Here's where API-specific magic happens.
883                                Don't call this directly unless you know what you're doing.
884                */
885                virtual DepthBuffer* _createDepthBufferFor( RenderTarget *renderTarget ) = 0;
886
887                /** Removes all depth buffers. Should be called on device lost and shutdown
888                        @remarks
889                                Advanced users can call this directly with bCleanManualBuffers=false to
890                                remove all depth buffers created for RTTs; when they think the pool has
891                                grown too big or they've used lots of depth buffers they don't need anymore,
892                                freeing GPU RAM.
893                */
894                void _cleanupDepthBuffers( bool bCleanManualBuffers=true );
895
896                /**
897                * Signifies the beginning of a frame, i.e. the start of rendering on a single viewport. Will occur
898                * several times per complete frame if multiple viewports exist.
899                */
900                virtual void _beginFrame(void) = 0;
901               
902                //Dummy structure for render system contexts - implementing RenderSystems can extend
903                //as needed
904                struct RenderSystemContext { };
905                /**
906                * Pause rendering for a frame. This has to be called after _beginFrame and before _endFrame.
907                * Will usually be called by the SceneManager, don't use this manually unless you know what
908                * you are doing.
909                */
910                virtual RenderSystemContext* _pauseFrame(void);
911                /**
912                * Resume rendering for a frame. This has to be called after a _pauseFrame call
913                * Will usually be called by the SceneManager, don't use this manually unless you know what
914                * you are doing.
915                * @param context the render system context, as returned by _pauseFrame
916                */
917                virtual void _resumeFrame(RenderSystemContext* context);
918
919                /**
920                * Ends rendering of a frame to the current viewport.
921                */
922                virtual void _endFrame(void) = 0;
923                /**
924                Sets the provided viewport as the active one for future
925                rendering operations. This viewport is aware of it's own
926                camera and render target. Must be implemented by subclass.
927
928                @param vp Pointer to the appropriate viewport.
929                */
930                virtual void _setViewport(Viewport *vp) = 0;
931                /** Get the current active viewport for rendering. */
932                virtual Viewport* _getViewport(void);
933
934                /** Sets the culling mode for the render system based on the 'vertex winding'.
935                A typical way for the rendering engine to cull triangles is based on the
936                'vertex winding' of triangles. Vertex winding refers to the direction in
937                which the vertices are passed or indexed to in the rendering operation as viewed
938                from the camera, and will wither be clockwise or anticlockwise (that's 'counterclockwise' for
939                you Americans out there ;) The default is CULL_CLOCKWISE i.e. that only triangles whose vertices
940                are passed/indexed in anticlockwise order are rendered - this is a common approach and is used in 3D studio models
941                for example. You can alter this culling mode if you wish but it is not advised unless you know what you are doing.
942                You may wish to use the CULL_NONE option for mesh data that you cull yourself where the vertex
943                winding is uncertain.
944                */
945                virtual void _setCullingMode(CullingMode mode) = 0;
946
947                virtual CullingMode _getCullingMode(void) const;
948
949                /** Sets the mode of operation for depth buffer tests from this point onwards.
950                Sometimes you may wish to alter the behaviour of the depth buffer to achieve
951                special effects. Because it's unlikely that you'll set these options for an entire frame,
952                but rather use them to tweak settings between rendering objects, this is an internal
953                method (indicated by the '_' prefix) which will be used by a SceneManager implementation
954                rather than directly from the client application.
955                If this method is never called the settings are automatically the same as the default parameters.
956                @param depthTest If true, the depth buffer is tested for each pixel and the frame buffer is only updated
957                if the depth function test succeeds. If false, no test is performed and pixels are always written.
958                @param depthWrite If true, the depth buffer is updated with the depth of the new pixel if the depth test succeeds.
959                If false, the depth buffer is left unchanged even if a new pixel is written.
960                @param depthFunction Sets the function required for the depth test.
961                */
962                virtual void _setDepthBufferParams(bool depthTest = true, bool depthWrite = true, CompareFunction depthFunction = CMPF_LESS_EQUAL) = 0;
963
964                /** Sets whether or not the depth buffer check is performed before a pixel write.
965                @param enabled If true, the depth buffer is tested for each pixel and the frame buffer is only updated
966                if the depth function test succeeds. If false, no test is performed and pixels are always written.
967                */
968                virtual void _setDepthBufferCheckEnabled(bool enabled = true) = 0;
969                /** Sets whether or not the depth buffer is updated after a pixel write.
970                @param enabled If true, the depth buffer is updated with the depth of the new pixel if the depth test succeeds.
971                If false, the depth buffer is left unchanged even if a new pixel is written.
972                */
973                virtual void _setDepthBufferWriteEnabled(bool enabled = true) = 0;
974                /** Sets the comparison function for the depth buffer check.
975                Advanced use only - allows you to choose the function applied to compare the depth values of
976                new and existing pixels in the depth buffer. Only an issue if the deoth buffer check is enabled
977                (see _setDepthBufferCheckEnabled)
978                @param  func The comparison between the new depth and the existing depth which must return true
979                for the new pixel to be written.
980                */
981                virtual void _setDepthBufferFunction(CompareFunction func = CMPF_LESS_EQUAL) = 0;
982                /** Sets whether or not colour buffer writing is enabled, and for which channels.
983                @remarks
984                For some advanced effects, you may wish to turn off the writing of certain colour
985                channels, or even all of the colour channels so that only the depth buffer is updated
986                in a rendering pass. However, the chances are that you really want to use this option
987                through the Material class.
988                @param red, green, blue, alpha Whether writing is enabled for each of the 4 colour channels. */
989                virtual void _setColourBufferWriteEnabled(bool red, bool green, bool blue, bool alpha) = 0;
990                /** Sets the depth bias, NB you should use the Material version of this.
991                @remarks
992                When polygons are coplanar, you can get problems with 'depth fighting' where
993                the pixels from the two polys compete for the same screen pixel. This is particularly
994                a problem for decals (polys attached to another surface to represent details such as
995                bulletholes etc.).
996                @par
997                A way to combat this problem is to use a depth bias to adjust the depth buffer value
998                used for the decal such that it is slightly higher than the true value, ensuring that
999                the decal appears on top.
1000                @note
1001                The final bias value is a combination of a constant bias and a bias proportional
1002                to the maximum depth slope of the polygon being rendered. The final bias
1003                is constantBias + slopeScaleBias * maxslope. Slope scale biasing is
1004                generally preferable but is not available on older hardware.
1005                @param constantBias The constant bias value, expressed as a value in
1006                homogeneous depth coordinates.
1007                @param slopeScaleBias The bias value which is factored by the maximum slope
1008                of the polygon, see the description above. This is not supported by all
1009                cards.
1010
1011                */
1012                virtual void _setDepthBias(float constantBias, float slopeScaleBias = 0.0f) = 0;
1013                /** Sets the fogging mode for future geometry.
1014                @param mode Set up the mode of fog as described in the FogMode enum, or set to FOG_NONE to turn off.
1015                @param colour The colour of the fog. Either set this to the same as your viewport background colour,
1016                or to blend in with a skydome or skybox.
1017                @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
1018                that fog never completely obscures the scene.
1019                @param linearStart Distance at which linear fog starts to encroach. The distance must be passed
1020                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.
1021                @param linearEnd Distance at which linear fog becomes completely opaque.The distance must be passed
1022                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.
1023                */
1024                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;
1025
1026
1027                /** The RenderSystem will keep a count of tris rendered, this resets the count. */
1028                virtual void _beginGeometryCount(void);
1029                /** Reports the number of tris rendered since the last _beginGeometryCount call. */
1030                virtual unsigned int _getFaceCount(void) const;
1031                /** Reports the number of batches rendered since the last _beginGeometryCount call. */
1032                virtual unsigned int _getBatchCount(void) const;
1033                /** Reports the number of vertices passed to the renderer since the last _beginGeometryCount call. */
1034                virtual unsigned int _getVertexCount(void) const;
1035
1036                /** Generates a packed data version of the passed in ColourValue suitable for
1037                use as with this RenderSystem.
1038                @remarks
1039                Since different render systems have different colour data formats (eg
1040                RGBA for GL, ARGB for D3D) this method allows you to use 1 method for all.
1041                @param colour The colour to convert
1042                @param pDest Pointer to location to put the result.
1043                */
1044                virtual void convertColourValue(const ColourValue& colour, uint32* pDest);
1045                /** Get the native VertexElementType for a compact 32-bit colour value
1046                for this rendersystem.
1047                */
1048                virtual VertexElementType getColourVertexElementType(void) const = 0;
1049
1050                /** Converts a uniform projection matrix to suitable for this render system.
1051                @remarks
1052                Because different APIs have different requirements (some incompatible) for the
1053                projection matrix, this method allows each to implement their own correctly and pass
1054                back a generic OGRE matrix for storage in the engine.
1055                */
1056                virtual void _convertProjectionMatrix(const Matrix4& matrix,
1057                        Matrix4& dest, bool forGpuProgram = false) = 0;
1058
1059                /** Builds a perspective projection matrix suitable for this render system.
1060                @remarks
1061                Because different APIs have different requirements (some incompatible) for the
1062                projection matrix, this method allows each to implement their own correctly and pass
1063                back a generic OGRE matrix for storage in the engine.
1064                */
1065                virtual void _makeProjectionMatrix(const Radian& fovy, Real aspect, Real nearPlane, Real farPlane, 
1066                        Matrix4& dest, bool forGpuProgram = false) = 0;
1067
1068                /** Builds a perspective projection matrix for the case when frustum is
1069                not centered around camera.
1070                @remarks
1071                Viewport coordinates are in camera coordinate frame, i.e. camera is
1072                at the origin.
1073                */
1074                virtual void _makeProjectionMatrix(Real left, Real right, Real bottom, Real top, 
1075                        Real nearPlane, Real farPlane, Matrix4& dest, bool forGpuProgram = false) = 0;
1076                /** Builds an orthographic projection matrix suitable for this render system.
1077                @remarks
1078                Because different APIs have different requirements (some incompatible) for the
1079                projection matrix, this method allows each to implement their own correctly and pass
1080                back a generic OGRE matrix for storage in the engine.
1081                */
1082                virtual void _makeOrthoMatrix(const Radian& fovy, Real aspect, Real nearPlane, Real farPlane, 
1083                        Matrix4& dest, bool forGpuProgram = false) = 0;
1084
1085                /** Update a perspective projection matrix to use 'oblique depth projection'.
1086                @remarks
1087                This method can be used to change the nature of a perspective
1088                transform in order to make the near plane not perpendicular to the
1089                camera view direction, but to be at some different orientation.
1090                This can be useful for performing arbitrary clipping (e.g. to a
1091                reflection plane) which could otherwise only be done using user
1092                clip planes, which are more expensive, and not necessarily supported
1093                on all cards.
1094                @param matrix The existing projection matrix. Note that this must be a
1095                perspective transform (not orthographic), and must not have already
1096                been altered by this method. The matrix will be altered in-place.
1097                @param plane The plane which is to be used as the clipping plane. This
1098                plane must be in CAMERA (view) space.
1099                @param forGpuProgram Is this for use with a Gpu program or fixed-function
1100                */
1101                virtual void _applyObliqueDepthProjection(Matrix4& matrix, const Plane& plane, 
1102                        bool forGpuProgram) = 0;
1103
1104                /** Sets how to rasterise triangles, as points, wireframe or solid polys. */
1105                virtual void _setPolygonMode(PolygonMode level) = 0;
1106
1107                /** Turns stencil buffer checking on or off.
1108                @remarks
1109                Stencilling (masking off areas of the rendering target based on the stencil
1110                buffer) can be turned on or off using this method. By default, stencilling is
1111                disabled.
1112                */
1113                virtual void setStencilCheckEnabled(bool enabled) = 0;
1114                /** Determines if this system supports hardware accelerated stencil buffer.
1115                @remarks
1116                Note that the lack of this function doesn't mean you can't do stencilling, but
1117                the stencilling operations will be provided in software, which will NOT be
1118                fast.
1119                @par
1120                Generally hardware stencils are only supported in 32-bit colour modes, because
1121                the stencil buffer shares the memory of the z-buffer, and in most cards the
1122                z-buffer has to be the same depth as the colour buffer. This means that in 32-bit
1123                mode, 24 bits of the z-buffer are depth and 8 bits are stencil. In 16-bit mode there
1124                is no room for a stencil (although some cards support a 15:1 depth:stencil option,
1125                this isn't useful for very much) so 8 bits of stencil are provided in software.
1126                This can mean that if you use stencilling, your applications may be faster in
1127                32-but colour than in 16-bit, which may seem odd to some people.
1128                */
1129                /*virtual bool hasHardwareStencil(void) = 0;*/
1130
1131                /** This method allows you to set all the stencil buffer parameters in one call.
1132                @remarks
1133                The stencil buffer is used to mask out pixels in the render target, allowing
1134                you to do effects like mirrors, cut-outs, stencil shadows and more. Each of
1135                your batches of rendering is likely to ignore the stencil buffer,
1136                update it with new values, or apply it to mask the output of the render.
1137                The stencil test is:<PRE>
1138                (Reference Value & Mask) CompareFunction (Stencil Buffer Value & Mask)</PRE>
1139                The result of this will cause one of 3 actions depending on whether the test fails,
1140                succeeds but with the depth buffer check still failing, or succeeds with the
1141                depth buffer check passing too.
1142                @par
1143                Unlike other render states, stencilling is left for the application to turn
1144                on and off when it requires. This is because you are likely to want to change
1145                parameters between batches of arbitrary objects and control the ordering yourself.
1146                In order to batch things this way, you'll want to use OGRE's separate render queue
1147                groups (see RenderQueue) and register a RenderQueueListener to get notifications
1148                between batches.
1149                @par
1150                There are individual state change methods for each of the parameters set using
1151                this method.
1152                Note that the default values in this method represent the defaults at system
1153                start up too.
1154                @param func The comparison function applied.
1155                @param refValue The reference value used in the comparison
1156                @param compareMask The bitmask applied to both the stencil value and the reference value
1157                before comparison
1158                @param writeMask The bitmask the controls which bits from refValue will be written to
1159                stencil buffer (valid for operations such as SOP_REPLACE).
1160                the stencil
1161                @param stencilFailOp The action to perform when the stencil check fails
1162                @param depthFailOp The action to perform when the stencil check passes, but the
1163                depth buffer check still fails
1164                @param passOp The action to take when both the stencil and depth check pass.
1165                @param twoSidedOperation If set to true, then if you render both back and front faces
1166                (you'll have to turn off culling) then these parameters will apply for front faces,
1167                and the inverse of them will happen for back faces (keep remains the same).
1168                */
1169                virtual void setStencilBufferParams(CompareFunction func = CMPF_ALWAYS_PASS, 
1170                        uint32 refValue = 0, uint32 compareMask = 0xFFFFFFFF, uint32 writeMask = 0xFFFFFFFF, 
1171                        StencilOperation stencilFailOp = SOP_KEEP, 
1172                        StencilOperation depthFailOp = SOP_KEEP,
1173                        StencilOperation passOp = SOP_KEEP, 
1174                        bool twoSidedOperation = false) = 0;
1175
1176
1177
1178                /** Sets the current vertex declaration, ie the source of vertex data. */
1179                virtual void setVertexDeclaration(VertexDeclaration* decl) = 0;
1180                /** Sets the current vertex buffer binding state. */
1181                virtual void setVertexBufferBinding(VertexBufferBinding* binding) = 0;
1182
1183                /** Sets whether or not normals are to be automatically normalised.
1184                @remarks
1185                This is useful when, for example, you are scaling SceneNodes such that
1186                normals may not be unit-length anymore. Note though that this has an
1187                overhead so should not be turn on unless you really need it.
1188                @par
1189                You should not normally call this direct unless you are rendering
1190                world geometry; set it on the Renderable because otherwise it will be
1191                overridden by material settings.
1192                */
1193                virtual void setNormaliseNormals(bool normalise) = 0;
1194
1195                /**
1196                Render something to the active viewport.
1197
1198                Low-level rendering interface to perform rendering
1199                operations. Unlikely to be used directly by client
1200                applications, since the SceneManager and various support
1201                classes will be responsible for calling this method.
1202                Can only be called between _beginScene and _endScene
1203
1204                @param op A rendering operation instance, which contains
1205                details of the operation to be performed.
1206                */
1207                virtual void _render(const RenderOperation& op);
1208
1209                /** Gets the capabilities of the render system. */
1210                const RenderSystemCapabilities* getCapabilities(void) const { return mCurrentCapabilities; }
1211
1212
1213                /** Returns the driver version.
1214                */
1215                virtual const DriverVersion& getDriverVersion(void) const { return mDriverVersion; }
1216
1217        /** Returns the default material scheme used by the render system.
1218            Systems that use the RTSS to emulate a fixed function pipeline
1219            (e.g. OpenGL ES 2, GL3+, DX11) need to override this function to return
1220            the default material scheme of the RTSS ShaderGenerator.
1221         
1222            This is currently only used to set the default material scheme for
1223            viewports.  It is a necessary step on these render systems for
1224            render textures to be rendered into properly.
1225                */
1226                virtual const String& _getDefaultViewportMaterialScheme(void) const;
1227
1228                /** Binds a given GpuProgram (but not the parameters).
1229                @remarks Only one GpuProgram of each type can be bound at once, binding another
1230                one will simply replace the existing one.
1231                */
1232                virtual void bindGpuProgram(GpuProgram* prg);
1233
1234                /** Bind Gpu program parameters.
1235                @param gptype The type of program to bind the parameters to
1236                @param params The parameters to bind
1237                @param variabilityMask A mask of GpuParamVariability identifying which params need binding
1238                */
1239                virtual void bindGpuProgramParameters(GpuProgramType gptype, 
1240                        GpuProgramParametersSharedPtr params, uint16 variabilityMask) = 0;
1241
1242                /** Only binds Gpu program parameters used for passes that have more than one iteration rendering
1243                */
1244                virtual void bindGpuProgramPassIterationParameters(GpuProgramType gptype) = 0;
1245                /** Unbinds GpuPrograms of a given GpuProgramType.
1246                @remarks
1247                This returns the pipeline to fixed-function processing for this type.
1248                */
1249                virtual void unbindGpuProgram(GpuProgramType gptype);
1250
1251                /** Returns whether or not a Gpu program of the given type is currently bound. */
1252                virtual bool isGpuProgramBound(GpuProgramType gptype);
1253
1254        /**
1255         * Gets the native shading language version for this render system.
1256         * Formatted so that it can be used within a shading program.
1257         * For example, OpenGL 3.2 would return 150, while 3.3 would return 330
1258         */
1259        uint16 getNativeShadingLanguageVersion() const { return mNativeShadingLanguageVersion; }
1260
1261                /** Sets the user clipping region.
1262                */
1263                virtual void setClipPlanes(const PlaneList& clipPlanes);
1264
1265                /** Add a user clipping plane. */
1266                virtual void addClipPlane (const Plane &p);
1267                /** Add a user clipping plane. */
1268                virtual void addClipPlane (Real A, Real B, Real C, Real D);
1269
1270                /** Clears the user clipping region.
1271                */
1272                virtual void resetClipPlanes();
1273
1274                /** Utility method for initialising all render targets attached to this rendering system. */
1275                virtual void _initRenderTargets(void);
1276
1277                /** Utility method to notify all render targets that a camera has been removed,
1278                in case they were referring to it as their viewer.
1279                */
1280                virtual void _notifyCameraRemoved(const Camera* cam);
1281
1282                /** Internal method for updating all render targets attached to this rendering system. */
1283                virtual void _updateAllRenderTargets(bool swapBuffers = true);
1284                /** Internal method for swapping all the buffers on all render targets,
1285                if _updateAllRenderTargets was called with a 'false' parameter. */
1286                virtual void _swapAllRenderTargetBuffers();
1287
1288                /** Sets whether or not vertex windings set should be inverted; this can be important
1289                for rendering reflections. */
1290                virtual void setInvertVertexWinding(bool invert);
1291
1292                /** Indicates whether or not the vertex windings set will be inverted for the current render (e.g. reflections)
1293                @see RenderSystem::setInvertVertexWinding
1294                */
1295                virtual bool getInvertVertexWinding(void) const;
1296
1297                /** Sets the 'scissor region' i.e. the region of the target in which rendering can take place.
1298                @remarks
1299                This method allows you to 'mask off' rendering in all but a given rectangular area
1300                as identified by the parameters to this method.
1301                @note
1302                Not all systems support this method. Check the RenderSystemCapabilities for the
1303                RSC_SCISSOR_TEST capability to see if it is supported.
1304                @param enabled True to enable the scissor test, false to disable it.
1305                @param left, top, right, bottom The location of the corners of the rectangle, expressed in
1306                <i>pixels</i>.
1307                */
1308                virtual void setScissorTest(bool enabled, size_t left = 0, size_t top = 0, 
1309                        size_t right = 800, size_t bottom = 600) = 0;
1310
1311                /** Clears one or more frame buffers on the active render target.
1312                @param buffers Combination of one or more elements of FrameBufferType
1313                denoting which buffers are to be cleared
1314                @param colour The colour to clear the colour buffer with, if enabled
1315                @param depth The value to initialise the depth buffer with, if enabled
1316                @param stencil The value to initialise the stencil buffer with, if enabled.
1317                */
1318                virtual void clearFrameBuffer(unsigned int buffers, 
1319                        const ColourValue& colour = ColourValue::Black, 
1320                        Real depth = 1.0f, unsigned short stencil = 0) = 0;
1321                /** Returns the horizontal texel offset value required for mapping
1322                texel origins to pixel origins in this rendersystem.
1323                @remarks
1324                Since rendersystems sometimes disagree on the origin of a texel,
1325                mapping from texels to pixels can sometimes be problematic to
1326                implement generically. This method allows you to retrieve the offset
1327                required to map the origin of a texel to the origin of a pixel in
1328                the horizontal direction.
1329                */
1330                virtual Real getHorizontalTexelOffset(void) = 0;
1331                /** Returns the vertical texel offset value required for mapping
1332                texel origins to pixel origins in this rendersystem.
1333                @remarks
1334                Since rendersystems sometimes disagree on the origin of a texel,
1335                mapping from texels to pixels can sometimes be problematic to
1336                implement generically. This method allows you to retrieve the offset
1337                required to map the origin of a texel to the origin of a pixel in
1338                the vertical direction.
1339                */
1340                virtual Real getVerticalTexelOffset(void) = 0;
1341
1342                /** Gets the minimum (closest) depth value to be used when rendering
1343                using identity transforms.
1344                @remarks
1345                When using identity transforms you can manually set the depth
1346                of a vertex; however the input values required differ per
1347                rendersystem. This method lets you retrieve the correct value.
1348                @see Renderable::getUseIdentityView, Renderable::getUseIdentityProjection
1349                */
1350                virtual Real getMinimumDepthInputValue(void) = 0;
1351                /** Gets the maximum (farthest) depth value to be used when rendering
1352                using identity transforms.
1353                @remarks
1354                When using identity transforms you can manually set the depth
1355                of a vertex; however the input values required differ per
1356                rendersystem. This method lets you retrieve the correct value.
1357                @see Renderable::getUseIdentityView, Renderable::getUseIdentityProjection
1358                */
1359                virtual Real getMaximumDepthInputValue(void) = 0;
1360                /** set the current multi pass count value.  This must be set prior to
1361                calling _render() if multiple renderings of the same pass state are
1362                required.
1363                @param count Number of times to render the current state.
1364                */
1365                virtual void setCurrentPassIterationCount(const size_t count) { mCurrentPassIterationCount = count; }
1366
1367                /** Tell the render system whether to derive a depth bias on its own based on
1368                the values passed to it in setCurrentPassIterationCount.
1369                The depth bias set will be baseValue + iteration * multiplier
1370                @param derive True to tell the RS to derive this automatically
1371                @param baseValue The base value to which the multiplier should be
1372                added
1373                @param multiplier The amount of depth bias to apply per iteration
1374                @param slopeScale The constant slope scale bias for completeness
1375                */
1376                virtual void setDeriveDepthBias(bool derive, float baseValue = 0.0f,
1377                        float multiplier = 0.0f, float slopeScale = 0.0f)
1378                {
1379                        mDerivedDepthBias = derive;
1380                        mDerivedDepthBiasBase = baseValue;
1381                        mDerivedDepthBiasMultiplier = multiplier;
1382                        mDerivedDepthBiasSlopeScale = slopeScale;
1383                }
1384
1385                /**
1386         * Set current render target to target, enabling its device context if needed
1387         */
1388        virtual void _setRenderTarget(RenderTarget *target) = 0;
1389
1390                /** Defines a listener on the custom events that this render system
1391                can raise.
1392                @see RenderSystem::addListener
1393                */
1394                class _OgreExport Listener
1395                {
1396                public:
1397                        Listener() {}
1398                        virtual ~Listener() {}
1399
1400                        /** A rendersystem-specific event occurred.
1401                        @param eventName The name of the event which has occurred
1402                        @param parameters A list of parameters that may belong to this event,
1403                        may be null if there are no parameters
1404                        */
1405                        virtual void eventOccurred(const String& eventName, 
1406                                const NameValuePairList* parameters = 0) = 0;
1407                };
1408                /** Adds a listener to the custom events that this render system can raise.
1409                @remarks
1410                Some render systems have quite specific, internally generated events
1411                that the application may wish to be notified of. Many applications
1412                don't have to worry about these events, and can just trust OGRE to
1413                handle them, but if you want to know, you can add a listener here.
1414                @par
1415                Events are raised very generically by string name. Perhaps the most
1416                common example of a render system specific event is the loss and
1417                restoration of a device in DirectX; which OGRE deals with, but you
1418                may wish to know when it happens.
1419                @see RenderSystem::getRenderSystemEvents
1420                */
1421                virtual void addListener(Listener* l);
1422                /** Remove a listener to the custom events that this render system can raise.
1423                */
1424                virtual void removeListener(Listener* l);
1425
1426                /** Gets a list of the rendersystem specific events that this rendersystem
1427                can raise.
1428                @see RenderSystem::addListener
1429                */
1430                virtual const StringVector& getRenderSystemEvents(void) const { return mEventNames; }
1431
1432                /** Tell the rendersystem to perform any prep tasks it needs to directly
1433                before other threads which might access the rendering API are registered.
1434                @remarks
1435                Call this from your main thread before starting your other threads
1436                (which themselves should call registerThread()). Note that if you
1437                start your own threads, there is a specific startup sequence which
1438                must be respected and requires synchronisation between the threads:
1439                <ol>
1440                <li>[Main thread]Call preExtraThreadsStarted</li>
1441                <li>[Main thread]Start other thread, wait</li>
1442                <li>[Other thread]Call registerThread, notify main thread & continue</li>
1443                <li>[Main thread]Wake up & call postExtraThreadsStarted</li>
1444                </ol>
1445                Once this init sequence is completed the threads are independent but
1446                this startup sequence must be respected.
1447                */
1448                virtual void preExtraThreadsStarted() = 0;
1449
1450                /* Tell the rendersystem to perform any tasks it needs to directly
1451                after other threads which might access the rendering API are registered.
1452                @see RenderSystem::preExtraThreadsStarted
1453                */
1454                virtual void postExtraThreadsStarted() = 0;
1455
1456                /** Register the an additional thread which may make calls to rendersystem-related
1457                objects.
1458                @remarks
1459                This method should only be called by additional threads during their
1460                initialisation. If they intend to use hardware rendering system resources
1461                they should call this method before doing anything related to the render system.
1462                Some rendering APIs require a per-thread setup and this method will sort that
1463                out. It is also necessary to call unregisterThread before the thread shuts down.
1464                @note
1465                This method takes no parameters - it must be called from the thread being
1466                registered and that context is enough.
1467                */
1468                virtual void registerThread() = 0;
1469
1470                /** Unregister an additional thread which may make calls to rendersystem-related objects.
1471                @see RenderSystem::registerThread
1472                */
1473                virtual void unregisterThread() = 0;
1474
1475                /**
1476                * Gets the number of display monitors.
1477                @see Root::getDisplayMonitorCount
1478                */
1479                virtual unsigned int getDisplayMonitorCount() const = 0;
1480
1481        /**
1482        * This marks the beginning of an event for GPU profiling.
1483        */
1484        virtual void beginProfileEvent( const String &eventName ) = 0;
1485
1486        /**
1487        * Ends the currently active GPU profiling event.
1488        */
1489        virtual void endProfileEvent( void ) = 0;
1490
1491        /**
1492        * Marks an instantaneous event for graphics profilers. 
1493        * This is equivalent to calling @see beginProfileEvent and @see endProfileEvent back to back.
1494        */
1495        virtual void markProfileEvent( const String &event ) = 0;
1496
1497                /** Determines if the system has anisotropic mip map filter support
1498                */
1499                virtual bool hasAnisotropicMipMapFilter() const = 0;
1500
1501                /** Gets a custom (maybe platform-specific) attribute.
1502        @remarks This is a nasty way of satisfying any API's need to see platform-specific details.
1503        @param name The name of the attribute.
1504        @param pData Pointer to memory of the right kind of structure to receive the info.
1505        */
1506                virtual void getCustomAttribute(const String& name, void* pData);
1507
1508        protected:
1509
1510                /** DepthBuffers to be attached to render targets */
1511                DepthBufferMap  mDepthBufferPool;
1512
1513                /** The render targets. */
1514                RenderTargetMap mRenderTargets;
1515                /** The render targets, ordered by priority. */
1516                RenderTargetPriorityMap mPrioritisedRenderTargets;
1517                /** The Active render target. */
1518                RenderTarget * mActiveRenderTarget;
1519
1520                /** The Active GPU programs and gpu program parameters*/
1521                GpuProgramParametersSharedPtr mActiveVertexGpuProgramParameters;
1522                GpuProgramParametersSharedPtr mActiveGeometryGpuProgramParameters;
1523                GpuProgramParametersSharedPtr mActiveFragmentGpuProgramParameters;
1524                GpuProgramParametersSharedPtr mActiveTesselationHullGpuProgramParameters;
1525                GpuProgramParametersSharedPtr mActiveTesselationDomainGpuProgramParameters;
1526                GpuProgramParametersSharedPtr mActiveComputeGpuProgramParameters;
1527
1528                // Texture manager
1529                // A concrete class of this will be created and
1530                // made available under the TextureManager singleton,
1531                // managed by the RenderSystem
1532                TextureManager* mTextureManager;
1533
1534                // Active viewport (dest for future rendering operations)
1535                Viewport* mActiveViewport;
1536
1537                CullingMode mCullingMode;
1538
1539                bool mWBuffer;
1540
1541                size_t mBatchCount;
1542                size_t mFaceCount;
1543                size_t mVertexCount;
1544
1545                /// Saved manual colour blends
1546                ColourValue mManualBlendColours[OGRE_MAX_TEXTURE_LAYERS][2];
1547
1548                bool mInvertVertexWinding;
1549
1550                /// Texture units from this upwards are disabled
1551                size_t mDisabledTexUnitsFrom;
1552
1553                /// number of times to render the current state
1554                size_t mCurrentPassIterationCount;
1555                size_t mCurrentPassIterationNum;
1556                /// Whether to update the depth bias per render call
1557                bool mDerivedDepthBias;
1558                float mDerivedDepthBiasBase;
1559                float mDerivedDepthBiasMultiplier;
1560                float mDerivedDepthBiasSlopeScale;
1561
1562        /// a global vertex buffer for global instancing
1563        HardwareVertexBufferSharedPtr mGlobalInstanceVertexBuffer;
1564        /// a vertex declaration for the global vertex buffer for the global instancing
1565        VertexDeclaration* mGlobalInstanceVertexBufferVertexDeclaration;
1566        /// the number of global instances (this number will be multiply by the render op instance number)
1567        size_t mGlobalNumberOfInstances;
1568
1569                /// is fixed pipeline enabled
1570                bool mEnableFixedPipeline;
1571
1572                /** updates pass iteration rendering state including bound gpu program parameter
1573                pass iteration auto constant entry
1574                @return True if more iterations are required
1575                */
1576                bool updatePassIterationRenderState(void);
1577
1578                /// List of names of events this rendersystem may raise
1579                StringVector mEventNames;
1580
1581                /// Internal method for firing a rendersystem event
1582                virtual void fireEvent(const String& name, const NameValuePairList* params = 0);
1583
1584                typedef list<Listener*>::type ListenerList;
1585                ListenerList mEventListeners;
1586
1587                typedef list<HardwareOcclusionQuery*>::type HardwareOcclusionQueryList;
1588                HardwareOcclusionQueryList mHwOcclusionQueries;
1589
1590                bool mVertexProgramBound;
1591                bool mGeometryProgramBound;
1592                bool mFragmentProgramBound;
1593                bool mTesselationHullProgramBound;
1594                bool mTesselationDomainProgramBound;
1595                bool mComputeProgramBound;
1596
1597                // Recording user clip planes
1598                PlaneList mClipPlanes;
1599                // Indicator that we need to re-set the clip planes on next render call
1600                bool mClipPlanesDirty;
1601
1602                /// Used to store the capabilities of the graphics card
1603                RenderSystemCapabilities* mRealCapabilities;
1604                RenderSystemCapabilities* mCurrentCapabilities;
1605                bool mUseCustomCapabilities;
1606
1607                /// Internal method used to set the underlying clip planes when needed
1608                virtual void setClipPlanesImpl(const PlaneList& clipPlanes) = 0;
1609
1610                /** Initialize the render system from the capabilities*/
1611                virtual void initialiseFromRenderSystemCapabilities(RenderSystemCapabilities* caps, RenderTarget* primary) = 0;
1612
1613
1614                DriverVersion mDriverVersion;
1615        uint16 mNativeShadingLanguageVersion;
1616
1617                bool mTexProjRelative;
1618                Vector3 mTexProjRelativeOrigin;
1619
1620
1621
1622        };
1623        /** @} */
1624        /** @} */
1625}
1626
1627#include "OgreHeaderSuffix.h"
1628
1629#endif
Note: See TracBrowser for help on using the repository browser.