PixelLightAPI  .
Renderer.h
Go to the documentation of this file.
00001 /*********************************************************\
00002  *  File: Renderer.h                                     *
00003  *
00004  *  Copyright (C) 2002-2012 The PixelLight Team (http://www.pixellight.org/)
00005  *
00006  *  This file is part of PixelLight.
00007  *
00008  *  PixelLight is free software: you can redistribute it and/or modify
00009  *  it under the terms of the GNU Lesser General Public License as published by
00010  *  the Free Software Foundation, either version 3 of the License, or
00011  *  (at your option) any later version.
00012  *
00013  *  PixelLight is distributed in the hope that it will be useful,
00014  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00016  *  GNU Lesser General Public License for more details.
00017  *
00018  *  You should have received a copy of the GNU Lesser General Public License
00019  *  along with PixelLight. If not, see <http://www.gnu.org/licenses/>.
00020 \*********************************************************/
00021 
00022 
00023 #ifndef __PLRENDERER_RENDERER_H__
00024 #define __PLRENDERER_RENDERER_H__
00025 #pragma once
00026 
00027 
00028 //[-------------------------------------------------------]
00029 //[ Includes                                              ]
00030 //[-------------------------------------------------------]
00031 #include <PLCore/Base/Object.h>
00032 #include <PLGraphics/Color/Color4.h>
00033 #include "PLRenderer/Renderer/Types.h"
00034 #include "PLRenderer/Renderer/SurfaceTextureBuffer.h"
00035 
00036 
00037 //[-------------------------------------------------------]
00038 //[ Forward declarations                                  ]
00039 //[-------------------------------------------------------]
00040 namespace PLMath {
00041     class Vector2;
00042     class Vector4;
00043     class Rectangle;
00044 }
00045 namespace PLGraphics {
00046     class Image;
00047 }
00048 namespace PLRenderer {
00049     class RendererContext;
00050     class SurfaceWindow;
00051     class SurfaceWindowHandler;
00052     class TextureBuffer;
00053     class TextureBuffer1D;
00054     class TextureBuffer2D;
00055     class TextureBuffer2DArray;
00056     class TextureBuffer3D;
00057     class TextureBufferCube;
00058     class IndexBuffer;
00059     class VertexBuffer;
00060     class OcclusionQuery;
00061     class FixedFunctions;
00062     class DrawHelpers;
00063     class Program;
00064     class FontManager;
00065     class ShaderLanguage;
00066 }
00067 
00068 
00069 //[-------------------------------------------------------]
00070 //[ Namespace                                             ]
00071 //[-------------------------------------------------------]
00072 namespace PLRenderer {
00073 
00074 
00075 //[-------------------------------------------------------]
00076 //[ Classes                                               ]
00077 //[-------------------------------------------------------]
00078 /**
00079 *  @brief
00080 *    Abstract renderer main class
00081 */
00082 class Renderer : public PLCore::Object {
00083 
00084 
00085     //[-------------------------------------------------------]
00086     //[ Friends                                               ]
00087     //[-------------------------------------------------------]
00088     friend class RendererContext;
00089 
00090 
00091     //[-------------------------------------------------------]
00092     //[ Public definitions                                    ]
00093     //[-------------------------------------------------------]
00094     public:
00095         /**
00096         *  @brief
00097         *    Renderer mode
00098         */
00099         enum EMode {
00100             ModeFixedFunctions = 0, /**< The renderer can only use fixed functions */
00101             ModeShaders        = 1, /**< The renderer can only use shaders */
00102             ModeBoth           = 2  /**< The renderer is allowed to use fixed functions as well as shaders */
00103         };
00104         pl_enum(EMode)
00105             pl_enum_value(ModeFixedFunctions,   "The renderer can only use fixed functions")
00106             pl_enum_value(ModeShaders,          "The renderer can only use shaders")
00107             pl_enum_value(ModeBoth,             "The renderer is allowed to use fixed functions as well as shaders")
00108         pl_enum_end
00109 
00110 
00111     //[-------------------------------------------------------]
00112     //[ RTTI interface                                        ]
00113     //[-------------------------------------------------------]
00114     pl_class(PLRENDERER_RTTI_EXPORT, Renderer, "PLRenderer", PLCore::Object, "Abstract renderer main class")
00115     pl_class_end
00116 
00117 
00118     //[-------------------------------------------------------]
00119     //[ Public virtual Renderer functions                     ]
00120     //[-------------------------------------------------------]
00121     public:
00122         /**
00123         *  @brief
00124         *    Returns whether or not the renderer instance was initialized successfully within it's constructor
00125         *
00126         *  @return
00127         *    'true' if the renderer instance was initialized successfully within it's constructor, else 'false'
00128         */
00129         virtual bool IsInitialized() const = 0;
00130 
00131         /**
00132         *  @brief
00133         *    Returns the owner renderer context
00134         *
00135         *  @return
00136         *    Reference to the owner renderer context
00137         */
00138         virtual RendererContext &GetRendererContext() const = 0;
00139 
00140         /**
00141         *  @brief
00142         *    Returns the renderer API (for example 'OpenGL' or 'Direct3D')
00143         *
00144         *  @param[out] pnVersion
00145         *    Version information, can be a null pointer
00146         *
00147         *  @return
00148         *    Renderer API
00149         *
00150         *  @remarks
00151         *    The content of 'nVersion' depends on the used API.
00152         *    For 'OpenGL', 'nVersion' can for example be '21' for 'OpenGL 2.1'.
00153         *    For 'Direct3D', 'nVersion' can for example be '900' for 'Direct3D 9'.
00154         */
00155         virtual PLCore::String GetAPI(PLCore::uint32 *pnVersion = nullptr) const = 0;
00156 
00157         /**
00158         *  @brief
00159         *    Returns the renderer vendor (for example 'ATI Technologies Inc.')
00160         *
00161         *  @return
00162         *    Renderer vendor
00163         */
00164         virtual PLCore::String GetVendor() const = 0;
00165 
00166         /**
00167         *  @brief
00168         *    Returns the mode the renderer is running in
00169         *
00170         *  @return
00171         *    The mode the renderer is running in
00172         */
00173         virtual EMode GetMode() const = 0;
00174 
00175         /**
00176         *  @brief
00177         *    Returns the name of the default shader language of the renderer
00178         *
00179         *  @return
00180         *    The name of the default shader language of the renderer (for example "GLSL" or "Cg"), the string can be empty, too
00181         */
00182         virtual PLCore::String GetDefaultShaderLanguage() const = 0;
00183 
00184         /**
00185         *  @brief
00186         *    Returns a shader language instance
00187         *
00188         *  @param[in] sShaderLanguage
00189         *    The name of the shader language (for example "GLSL" or "Cg"), if empty string,
00190         *    the default renderer shader language is used (see GetDefaultShaderLanguage())
00191         *
00192         *  @return
00193         *    The shader language instance (do NOT delete it!), a null pointer on error
00194         */
00195         virtual ShaderLanguage *GetShaderLanguage(const PLCore::String &sShaderLanguage = "") = 0;
00196 
00197         /**
00198         *  @brief
00199         *    Returns the fixed functions renderer interface
00200         *
00201         *  @return
00202         *    The fixed functions renderer interface, can be a null pointer
00203         *
00204         *  @note
00205         *    - A legacy renderer interface for previously build in features in old graphics APIs and GPUs
00206         *    - A renderer backend is not enforced to implement this interface, so, you have to take it into
00207         *      account that this function just returns a null pointer
00208         *    - Do NOT delete the instance of the interface!
00209         */
00210         virtual FixedFunctions *GetFixedFunctions() const = 0;
00211 
00212         /**
00213         *  @brief
00214         *    Returns the font manager interface
00215         *
00216         *  @return
00217         *    The font manager interface
00218         */
00219         virtual FontManager &GetFontManager() const = 0;
00220 
00221         /**
00222         *  @brief
00223         *    Returns the draw helpers interface
00224         *
00225         *  @return
00226         *    The draw helpers interface
00227         */
00228         virtual DrawHelpers &GetDrawHelpers() const = 0;
00229 
00230         /**
00231         *  @brief
00232         *    Backups the device objects
00233         *
00234         *  @note
00235         *    - Used for instance if the display mode is changed to backup/restore
00236         *      all device objects (like texture buffers, renderer buffers etc.)
00237         *    - Normally only used inside the renderer backend!
00238         */
00239         virtual void BackupDeviceObjects() = 0;
00240 
00241         /**
00242         *  @brief
00243         *    Restores the device objects
00244         *
00245         *  @see
00246         *    - BackupDeviceObjects()
00247         */
00248         virtual void RestoreDeviceObjects() = 0;
00249 
00250         /**
00251         *  @brief
00252         *    Returns the number of all available display modes
00253         *
00254         *  @return
00255         *    Number of all available display modes
00256         *
00257         *  @remarks
00258         *    Be careful when using one of the 'all available display modes' directly... because it can
00259         *    happen that even if a display mode received by the system is listed, it may not work properly
00260         *    within fullscreen mode and you get for example just a black window.
00261         */
00262         virtual PLCore::uint32 GetNumOfDisplayModes() const = 0;
00263 
00264         /**
00265         *  @brief
00266         *    Returns a display mode
00267         *
00268         *  @param[in] nIndex
00269         *    Index of the display mode to return (0..'GetNumOfDisplayModes()')
00270         *
00271         *  @return
00272         *    The requested display mode, (do NOT delete the display mode!) a null pointer on error
00273         *
00274         *  @see
00275         *    - GetNumOfDisplayModes()
00276         */
00277         virtual const DisplayMode *GetDisplayMode(PLCore::uint32 nIndex) const = 0;
00278 
00279         /**
00280         *  @brief
00281         *    Returns the renderer capabilities
00282         *
00283         *  @return
00284         *    The renderer capabilities
00285         */
00286         virtual const Capabilities &GetCapabilities() const = 0;
00287 
00288         /**
00289         *  @brief
00290         *    Returns whether or not the given size is valid for a 1D texture buffer
00291         *
00292         *  @param[in] nSize
00293         *    Size to check
00294         *
00295         *  @return
00296         *    'true' if the given size is valid, else 'false'
00297         *
00298         *  @note
00299         *    - A size is valid if nSize<=GetCapabilities().nMaxTextureBufferSize and nSize>0 and
00300         *      the size is a power of two (or GetCapabilities().bTextureBufferNonPowerOfTwo is "true")
00301         */
00302         virtual bool IsValidTextureBuffer1DSize(int nSize) const = 0;
00303 
00304         /**
00305         *  @brief
00306         *    Returns whether or not the given size is valid for a 2D texture buffer
00307         *
00308         *  @param[in] nSize
00309         *    Size to check
00310         *
00311         *  @return
00312         *    'true' if the given size is valid, else 'false'
00313         *
00314         *  @note
00315         *    - A size is valid if nSize<=GetCapabilities().nMaxTextureBufferSize and nSize>0 and
00316         *      the size is a power of two (or GetCapabilities().bTextureBufferNonPowerOfTwo is "true")
00317         */
00318         virtual bool IsValidTextureBuffer2DSize(int nSize) const = 0;
00319 
00320         /**
00321         *  @brief
00322         *    Returns whether or not the given size is valid for a rectangle texture buffer
00323         *
00324         *  @param[in] nSize
00325         *    Size to check
00326         *
00327         *  @return
00328         *    'true' if the given size is valid, else 'false'
00329         *
00330         *  @note
00331         *    - A size is valid if nSize<=GetCapabilities().nMaxRectangleTextureBufferSize and nSize>0
00332         */
00333         virtual bool IsValidTextureBufferRectangleSize(int nSize) const = 0;
00334 
00335         /**
00336         *  @brief
00337         *    Returns whether or not the given size is valid for a 3D texture buffer
00338         *
00339         *  @param[in] nSize
00340         *    Size to check
00341         *
00342         *  @return
00343         *    'true' if the given size is valid, else 'false'
00344         *
00345         *  @note
00346         *    - A size is valid if nSize<=GetCapabilities().nMax3DTextureBufferSize and nSize>0 and
00347         *      the size is a power of two (or GetCapabilities().bTextureBufferNonPowerOfTwo is "true")
00348         */
00349         virtual bool IsValidTextureBuffer3DSize(int nSize) const = 0;
00350 
00351         /**
00352         *  @brief
00353         *    Returns whether or not the given size is valid for a cube texture buffer
00354         *
00355         *  @param[in] nSize
00356         *    Size to check
00357         *
00358         *  @return
00359         *    'true' if the given size is valid, else 'false'
00360         *
00361         *  @note
00362         *    - A size is valid if nSize<=GetCapabilities().nMaxCubeTextureBufferSize and nSize>0 and
00363         *      the size is a power of two (or GetCapabilities().bTextureBufferNonPowerOfTwo is "true")
00364         */
00365         virtual bool IsValidTextureBufferCubeSize(int nSize) const = 0;
00366 
00367         /**
00368         *  @brief
00369         *    Returns the renderer statistics
00370         *
00371         *  @return
00372         *    The renderer statistics
00373         */
00374         virtual const Statistics &GetStatistics() const = 0;
00375 
00376         /**
00377         *  @brief
00378         *    Returns the offset required to line up texel origins with pixels origins
00379         *
00380         *  @return
00381         *    The pixel origin to texel origin offset, usually (0.0, 0.0) or (-0.5, -0.5)
00382         *
00383         *  @note
00384         *    - OpenGL/D3D10/D3D11 have no offset while D3D9 has an offset of -0.5 (see http://msdn.microsoft.com/en-us/library/bb219690%28VS.85%29.aspx)
00385         */
00386         virtual const PLMath::Vector2 &GetTexelToPixelOffset() const = 0;
00387 
00388         /**
00389         *  @brief
00390         *    Updates the renderer
00391         *
00392         *  @note
00393         *    - All renderer surfaces of this renderer will be updated
00394         */
00395         virtual void Update() = 0;
00396 
00397         /**
00398         *  @brief
00399         *    Resets all render states, texture units etc. to default
00400         *
00401         *  @note
00402         *    - Avoid calling this function frequently because this can be a performance hit
00403         *    - Internally this functions are called:
00404         *      SetColor(), ResetRenderStates(), ResetTransformStates(), ResetSamplerStates(), SetTextureBuffer(),
00405         *      SetIndexBuffer(), SetViewport(), SetScissorRect(), SetColorMask(), SetProgram(),
00406         *      FixedFunctions::Reset(), DrawHelpers::End2DMode(), DrawHelpers::Set2DZValue()
00407         */
00408         virtual void Reset() = 0;
00409 
00410         //[-------------------------------------------------------]
00411         //[ Surfaces                                              ]
00412         //[-------------------------------------------------------]
00413         /**
00414         *  @brief
00415         *    Returns the number of surfaces
00416         *
00417         *  @return
00418         *    Number of surfaces
00419         */
00420         virtual PLCore::uint32 GetNumOfSurfaces() const = 0;
00421 
00422         /**
00423         *  @brief
00424         *    Returns a renderer surface
00425         *
00426         *  @param[in] nIndex
00427         *    Index of the surface to return
00428         *
00429         *  @return
00430         *    The surface at the given index, a null pointer on error
00431         */
00432         virtual Surface *GetSurface(PLCore::uint32 nIndex = 0) const = 0;
00433 
00434         /**
00435         *  @brief
00436         *    Adds a renderer surface to the renderer
00437         *
00438         *  @param[in] cSurface
00439         *    Renderer surface to add
00440         *
00441         *  @return
00442         *    'true' if all went fine and the renderer surface was added to the renderer,
00443         *    else 'false'
00444         *
00445         *  @note
00446         *    - The renderer surface itself is only added to the renderers list of surfaces!
00447         */
00448         virtual bool AddSurface(Surface &cSurface) = 0;
00449 
00450         /**
00451         *  @brief
00452         *    Removes a renderer surface from the renderer
00453         *
00454         *  @param[in] cSurface
00455         *    Renderer surface to remove
00456         *
00457         *  @return
00458         *    'true' if all went fine and the renderer surface was removed from the
00459         *    renderer, else 'false' (maybe the surface isn't in the renderer)
00460         *
00461         *  @note
00462         *    - The renderer surface itself isn't destroyed, it is just removed
00463         *      from the renderers list of surfaces!
00464         */
00465         virtual bool RemoveSurface(Surface &cSurface) = 0;
00466 
00467         /**
00468         *  @brief
00469         *    Creates a surface painter
00470         *
00471         *  @param[in] sClass
00472         *    Class name of the surface painter to create
00473         *
00474         *  @return
00475         *    The created surface painter, a null pointer on error (YOU have to destroy the object!)
00476         */
00477         virtual SurfacePainter *CreateSurfacePainter(const PLCore::String &sClass) = 0;
00478 
00479         //[-------------------------------------------------------]
00480         //[ Resources                                             ]
00481         //[-------------------------------------------------------]
00482         /**
00483         *  @brief
00484         *    Returns the number of resources
00485         *
00486         *  @return
00487         *    Number of resources
00488         */
00489         virtual PLCore::uint32 GetNumOfResources() const = 0;
00490 
00491         /**
00492         *  @brief
00493         *    Returns a renderer resource
00494         *
00495         *  @param[in] nIndex
00496         *    Index of the renderer resource to return
00497         *
00498         *  @return
00499         *    The resource at the given index, a null pointer on error
00500         */
00501         virtual Resource *GetResource(PLCore::uint32 nIndex = 0) const = 0;
00502 
00503         /**
00504         *  @brief
00505         *    Adds a renderer resource to the renderer
00506         *
00507         *  @param[in] cResource
00508         *    Renderer resource to add
00509         *
00510         *  @return
00511         *    'true' if all went fine and the renderer resource was added to the renderer,
00512         *    else 'false'
00513         *
00514         *  @note
00515         *    - The renderer resource itself is only added to the renderers list of resources!
00516         */
00517         virtual bool AddResource(Resource &cResource) = 0;
00518 
00519         /**
00520         *  @brief
00521         *    Removes a renderer resource from the renderer
00522         *
00523         *  @param[in] cResource
00524         *    Renderer resource to remove
00525         *
00526         *  @return
00527         *    'true' if all went fine and the renderer resource was removed from the
00528         *    renderer, else 'false' (maybe the resource isn't in the renderer)
00529         *
00530         *  @note
00531         *    - The renderer resource itself isn't destroyed, it is just removed
00532         *      from the renderers list of resources!
00533         */
00534         virtual bool RemoveResource(Resource &cResource) = 0;
00535 
00536         //[-------------------------------------------------------]
00537         //[ Create surface/resource                               ]
00538         //[-------------------------------------------------------]
00539         /**
00540         *  @brief
00541         *    Creates renderer surface window
00542         *
00543         *  @param[in] cHandler
00544         *    Renderer surface handler the new renderer surface is assigned with
00545         *  @param[in] nNativeWindowHandle
00546         *    Handle to the native window the renderer surface is assigned with
00547         *  @param[in] sDisplayMode
00548         *    Display mode information
00549         *  @param[in] bFullscreen
00550         *    Fullscreen mode?
00551         *
00552         *  @return
00553         *    The created renderer surface, a null pointer on error
00554         *
00555         *  @note
00556         *    - The new created renderer surface is added to this renderer automatically
00557         *    - The renderer surface handler is required because this kind of surface is assigned
00558         *      with a window and if the surface or window is lost they have to be informed
00559         */
00560         virtual SurfaceWindow *CreateSurfaceWindow(SurfaceWindowHandler &cHandler, PLCore::handle nNativeWindowHandle, const DisplayMode &sDisplayMode, bool bFullscreen = false) = 0;
00561 
00562         /**
00563         *  @brief
00564         *    Creates renderer 2D texture buffer surface
00565         *
00566         *  @param[in] vSize
00567         *    Size of renderer texture buffer surface
00568         *  @param[in] nFormat
00569         *    Texture buffer pixel format
00570         *  @param[in] nFlags
00571         *    Texture buffer surface flags (see SurfaceTextureBuffer::EFlags)
00572         *  @param[in] nMaxColorTargets
00573         *    Maximum number of color render targets. This must be at least 1 - main renderer
00574         *    target color. Have a look at SetColorRenderTarget()
00575         *
00576         *  @return
00577         *    The created renderer surface, a null pointer on error
00578         *
00579         *  @note
00580         *    - The new created renderer surface is added to this renderer automatically
00581         */
00582         virtual SurfaceTextureBuffer *CreateSurfaceTextureBuffer2D(const PLMath::Vector2i &vSize, TextureBuffer::EPixelFormat nFormat,
00583                                                                    PLCore::uint32 nFlags = SurfaceTextureBuffer::Depth | SurfaceTextureBuffer::Stencil,
00584                                                                    PLCore::uint8 nMaxColorTargets = 1) = 0;
00585 
00586         /**
00587         *  @brief
00588         *    Creates renderer rectangle texture buffer surface
00589         *
00590         *  @param[in] vSize
00591         *    Size of renderer texture buffer surface
00592         *  @param[in] nFormat
00593         *    Texture buffer pixel format
00594         *  @param[in] nFlags
00595         *    Texture buffer surface flags (see SurfaceTextureBuffer::EFlags)
00596         *  @param[in] nMaxColorTargets
00597         *    Maximum number of color render targets. This must be at least 1 - main renderer
00598         *    target color. Have a look at SetColorRenderTarget()
00599         *
00600         *  @return
00601         *    The created renderer surface, a null pointer on error
00602         *
00603         *  @note
00604         *    - The new created renderer surface is added to this renderer automatically
00605         *    - Additional color target texture buffers must be created with TextureBuffer::RenderTarget in order to
00606         *      work as render targets
00607         */
00608         virtual SurfaceTextureBuffer *CreateSurfaceTextureBufferRectangle(const PLMath::Vector2i &vSize, TextureBuffer::EPixelFormat nFormat,
00609                                                                           PLCore::uint32 nFlags = SurfaceTextureBuffer::Depth | SurfaceTextureBuffer::Stencil,
00610                                                                           PLCore::uint8 nMaxColorTargets = 1) = 0;
00611 
00612         /**
00613         *  @brief
00614         *    Creates renderer cube texture buffer surface
00615         *
00616         *  @param[in] nSize
00617         *    Size of renderer texture buffer surface
00618         *  @param[in] nFormat
00619         *    Texture buffer pixel format
00620         *  @param[in] nFlags
00621         *    Texture buffer surface flags (see SurfaceTextureBuffer::EFlags)
00622         *
00623         *  @return
00624         *    The created renderer surface, a null pointer on error
00625         *
00626         *  @note
00627         *    - The new created renderer surface is added to this renderer automatically
00628         */
00629         virtual SurfaceTextureBuffer *CreateSurfaceTextureBufferCube(PLCore::uint16 nSize, TextureBuffer::EPixelFormat nFormat,
00630                                                                      PLCore::uint32 nFlags = SurfaceTextureBuffer::Depth | SurfaceTextureBuffer::Stencil) = 0;
00631 
00632         /**
00633         *  @brief
00634         *    Creates a 1D texture buffer
00635         *
00636         *  @param[in] cImage
00637         *    Texture buffer image
00638         *  @param[in] nInternalFormat
00639         *    Desired internal texture buffer pixel format, if TextureBuffer::Unknown use the format of the given image
00640         *  @param[in] nFlags
00641         *    Texture buffer flags, TextureBuffer::RenderTarget has no effect (see TextureBuffer::EFlags)
00642         *
00643         *  @return
00644         *    The created 1D renderer texture buffer, a null pointer on error
00645         *    (maybe the image size is no power of two?)
00646         *
00647         *  @note
00648         *    - If the usage of 'nInternalFormat' failed - for instance texture buffer compression is not
00649         *      supported for this texture buffer type, the renderer will try to find a valid format by your self.
00650         *      Use the function TextureBuffer::GetFormat() to get the 'resulting' used format.
00651         *    - If the given image is pre compressed, but the compressed format is NOT supported by the renderer
00652         *      the uncompressed image is used instead.
00653         *    - If an desired internal format is given, the 'Compression' flag (see TextureBuffer::EFlags) is ignored.
00654         *    - If the 'Mipmaps' flag (see TextureBuffer::EFlags) is set and the given image doesn't provide any mipmaps,
00655         *      the mipmaps are created automatically. If the image comes with any mipmaps, this mipmaps MUST
00656         *      define all mipmap levels down to 1x1 otherwise the texture buffer is invalid when you try to use any min
00657         *      filter that uses mipmaps. (the OpenGL renderer normally uses white color when invalid/incomplete texture buffer is enabled)
00658         */
00659         virtual TextureBuffer1D *CreateTextureBuffer1D(PLGraphics::Image &cImage,
00660                                                        TextureBuffer::EPixelFormat nInternalFormat = TextureBuffer::Unknown,
00661                                                        PLCore::uint32 nFlags = TextureBuffer::Mipmaps | TextureBuffer::Compression) = 0;
00662 
00663         /**
00664         *  @brief
00665         *    Creates a 2D texture buffer
00666         *
00667         *  @param[in] cImage
00668         *    Texture buffer image
00669         *  @param[in] nInternalFormat
00670         *    Desired internal texture buffer pixel format, if TextureBuffer::Unknown use the format of the given image
00671         *  @param[in] nFlags
00672         *    Texture buffer flags (see TextureBuffer::EFlags)
00673         *
00674         *  @return
00675         *    The created 2D renderer texture buffer, a null pointer on error
00676         *    (maybe the image size is no power of two?)
00677         *
00678         *  @see
00679         *    - CreateTextureBuffer1D()
00680         */
00681         virtual TextureBuffer2D *CreateTextureBuffer2D(PLGraphics::Image &cImage,
00682                                                        TextureBuffer::EPixelFormat nInternalFormat = TextureBuffer::Unknown,
00683                                                        PLCore::uint32 nFlags = TextureBuffer::Mipmaps | TextureBuffer::Compression) = 0;
00684 
00685         /**
00686         *  @brief
00687         *    Creates a 2D array texture buffer
00688         *
00689         *  @param[in] cImage
00690         *    Texture buffer image
00691         *  @param[in] nInternalFormat
00692         *    Desired internal texture buffer pixel format, if TextureBuffer::Unknown use the format of the given image
00693         *  @param[in] nFlags
00694         *    Texture buffer flags (see TextureBuffer::EFlags)
00695         *
00696         *  @return
00697         *    The created 2D array renderer texture buffer, a null pointer on error
00698         *    (maybe the image size is no power of two?)
00699         *
00700         *  @see
00701         *    - CreateTextureBuffer1D()
00702         */
00703         virtual TextureBuffer2DArray *CreateTextureBuffer2DArray(PLGraphics::Image &cImage,
00704                                                                  TextureBuffer::EPixelFormat nInternalFormat = TextureBuffer::Unknown,
00705                                                                  PLCore::uint32 nFlags = TextureBuffer::Mipmaps | TextureBuffer::Compression) = 0;
00706 
00707         /**
00708         *  @brief
00709         *    Creates a rectangle texture buffer
00710         *
00711         *  @param[in] cImage
00712         *    Texture buffer image
00713         *  @param[in] nInternalFormat
00714         *    Desired internal texture buffer pixel format, if TextureBuffer::Unknown use the format of the given image
00715         *  @param[in] nFlags
00716         *    Texture buffer flags, TextureBuffer::Mipmaps has no effect (see TextureBuffer::EFlags)
00717         *
00718         *  @return
00719         *    The created rectangle renderer texture buffer, a null pointer on error
00720         *
00721         *  @remarks
00722         *    Please note that it's up to the implementation to decide whether there's a special TextureBufferRectangle implementation
00723         *    which can deal with non-power-of-two texture data, or if TextureBuffer2D etc. can deal with non-power-of-two texture as well.
00724         *    (Capabilities::bTextureBufferNonPowerOfTwo = true)
00725         *    For instance, OpenGL ES 2.0 has no special "rectangle"/"non-power-of-two" textures. GL_TEXTURE_2D can also be used with
00726         *    non-power-of-two texture data, but non-power-of-two textures have restrictions on the allowed texture wrap modes and filters
00727         *    (the texture wrap mode must be GL_CLAMP_TO_EDGE and the minification filter must be GL_NEAREST or GL_LINEAR). As a result, usually
00728         *    when using GLSL, rectangle textures are accessed by using sampler2DRect/texture2DRect instead of sampler2D/texture2D, and the
00729         *    texture coordinates are not normalized. But OpenGL ES 2.0 makes no difference between this two texture types - as a result,
00730         *    a lot of special case handling would be required. To avoid this, we decided that if the implementation doesn't make a difference,
00731         *    "CreateTextureBufferRectangle()" should be able to return TextureBuffer2D or TextureBufferRectangle - this way, no special
00732         *    case handling is required, just use the textures.
00733 
00734         *  @note
00735         *    - If rectangle texture buffers are not supported (Capabilities::bTextureBufferRectangle = false)
00736         *      this function will fail and a null pointer is returned
00737         *
00738         *  @see
00739         *    - CreateTextureBuffer1D()
00740         */
00741         virtual TextureBuffer *CreateTextureBufferRectangle(PLGraphics::Image &cImage,
00742                                                             TextureBuffer::EPixelFormat nInternalFormat = TextureBuffer::Unknown,
00743                                                             PLCore::uint32 nFlags = TextureBuffer::Compression) = 0;
00744 
00745         /**
00746         *  @brief
00747         *    Creates a 3D texture buffer
00748         *
00749         *  @param[in] cImage
00750         *    Texture buffer image
00751         *  @param[in] nInternalFormat
00752         *    Desired internal texture buffer pixel format, if TextureBuffer::Unknown use the format of the given image
00753         *  @param[in] nFlags
00754         *    Texture buffer flags, TextureBuffer::RenderTarget has no effect (see TextureBuffer::EFlags)
00755         *
00756         *  @return
00757         *    The created 3D renderer texture buffer, a null pointer on error
00758         *    (maybe the image size is no power of two?)
00759         *
00760         *  @note
00761         *    - If 3D texture buffers are not supported (Capabilities::bTextureBuffer3D = false)
00762         *      this function will fail and a null pointer is returned
00763         *
00764         *  @see
00765         *    - CreateTextureBuffer1D()
00766         */
00767         virtual TextureBuffer3D *CreateTextureBuffer3D(PLGraphics::Image &cImage,
00768                                                        TextureBuffer::EPixelFormat nInternalFormat = TextureBuffer::Unknown,
00769                                                        PLCore::uint32 nFlags = TextureBuffer::Mipmaps | TextureBuffer::Compression) = 0;
00770 
00771         /**
00772         *  @brief
00773         *    Creates a cube texture buffer
00774         *
00775         *  @param[in] cImage
00776         *    Cube map image (image with 6 image parts)
00777         *  @param[in] nInternalFormat
00778         *    Desired internal texture buffer pixel format, if TextureBuffer::Unknown use the format of the given image
00779         *  @param[in] nFlags
00780         *    Texture buffer flags (see TextureBuffer::EFlags)
00781         *
00782         *  @return
00783         *    The created cube renderer texture buffer, a null pointer on error
00784         *    (maybe the image size is no power of two?)
00785         *
00786         *  @note
00787         *    - If cube texture buffers are not supported (Capabilities::bTextureBufferCube = false)
00788         *      this function will fail and a null pointer is returned
00789         *
00790         *  @see
00791         *    - CreateTextureBuffer1D()
00792         */
00793         virtual TextureBufferCube *CreateTextureBufferCube(PLGraphics::Image &cImage,
00794                                                            TextureBuffer::EPixelFormat nInternalFormat = TextureBuffer::Unknown,
00795                                                            PLCore::uint32 nFlags = TextureBuffer::Mipmaps | TextureBuffer::Compression) = 0;
00796 
00797         /**
00798         *  @brief
00799         *    Creates an index buffer
00800         *
00801         *  @return
00802         *    The created index buffer, a null pointer on error
00803         *
00804         *  @remarks
00805         *    To use index buffers, create an index buffer, lock it, fill it with indices, unlock it, pass it to
00806         *    SetIndexBuffer(), set up the vertices, set up the vertex shader program, and call DrawIndexedPrimitive() for rendering.
00807         */
00808         virtual IndexBuffer *CreateIndexBuffer() = 0;
00809 
00810         /**
00811         *  @brief
00812         *    Creates a vertex buffer
00813         *
00814         *  @return
00815         *     The created vertex buffer, a null pointer on error
00816         *
00817         *  @remarks
00818         *    To use vertex buffers, create an vertex buffer, setup the vertex elements,
00819         *    allocate the vertex buffer, lock it, fill it with data, unlock it.
00820         *    For shader based rendering, use the ProgramAttribute interface to assign an vertex buffer attribute to an vertex shader attribute.
00821         *    For fixed functions rendering, pass the vertex buffer it to FixedFunctions::SetVertexBuffer().
00822         */
00823         virtual VertexBuffer *CreateVertexBuffer() = 0;
00824 
00825         /**
00826         *  @brief
00827         *    Creates an occlusion query
00828         *
00829         *  @return
00830         *    The created occlusion query, a null pointer on error
00831         *
00832         *  @note
00833         *    - If occlusion query is not supported by the hardware, an occlusion query object
00834         *      is returned, too. But the test will always succeed. (see Capabilities::bOcclusionQuery)
00835         */
00836         virtual OcclusionQuery *CreateOcclusionQuery() = 0;
00837 
00838         //[-------------------------------------------------------]
00839         //[ States                                                ]
00840         //[-------------------------------------------------------]
00841         /**
00842         *  @brief
00843         *    Returns a default render state
00844         *
00845         *  @param[in] nState
00846         *    Render state to return the default value from
00847         *
00848         *  @return
00849         *    The default state
00850         */
00851         virtual PLCore::uint32 GetDefaultRenderState(RenderState::Enum nState) const = 0;
00852 
00853         /**
00854         *  @brief
00855         *    Resets all render states to default
00856         *
00857         *  @see
00858         *    - GetDefaultRenderState()
00859         */
00860         virtual void ResetRenderStates() = 0;
00861 
00862         /**
00863         *  @brief
00864         *    Retrieves a render-state value
00865         *
00866         *  @param[in] nState
00867         *    State variable that is being queried. This parameter can
00868         *    be any member of the render state enumerated type.
00869         *
00870         *  @return
00871         *    The value of the queried render state variable, < 0 on error
00872         *
00873         *  @see
00874         *    - GetDefaultRenderState()
00875         */
00876         virtual int GetRenderState(RenderState::Enum nState) const = 0;
00877 
00878         /**
00879         *  @brief
00880         *    Sets a single render-state parameter
00881         *
00882         *  @param[in] nState
00883         *    State variable that is being modified. This parameter
00884         *    can be any member of the render state enumerated type.
00885         *  @param[in] nValue
00886         *    New value for the render state to be set. The meaning of
00887         *    this parameter is dependent on the value specified for nState.
00888         *    For example, if nState is Shade, the second parameter
00889         *    must be one member of the Shade enumerated type. (e.g. Shade::Flat)
00890         *
00891         *  @return
00892         *    'true' if all went fine, else 'false'
00893         *
00894         *  @see
00895         *    - GetDefaultRenderState()
00896         */
00897         virtual bool SetRenderState(RenderState::Enum nState, PLCore::uint32 nValue) = 0;
00898 
00899         /**
00900         *  @brief
00901         *    Returns a default sampler state
00902         *
00903         *  @param[in] nState
00904         *    Sampler state to return the default value from
00905         *
00906         *  @return
00907         *    The default state
00908         */
00909         virtual PLCore::uint32 GetDefaultSamplerState(Sampler::Enum nState) const = 0;
00910 
00911         /**
00912         *  @brief
00913         *    Resets all sampler states to default
00914         *
00915         *  @see
00916         *    - GetDefaultSamplerState()
00917         */
00918         virtual void ResetSamplerStates() = 0;
00919 
00920         /**
00921         *  @brief
00922         *    Retrieves a sampler-state value
00923         *
00924         *  @param[in] nStage
00925         *    Texture stage to get the value from
00926         *  @param[in] nState
00927         *    State variable that is being queried. This parameter can
00928         *    be any member of the sampler enumerated type.
00929         *
00930         *  @return
00931         *    The value of the queried sampler state variable, < 0 on error
00932         *
00933         *  @see
00934         *    - GetDefaultSamplerState()
00935         */
00936         virtual int GetSamplerState(PLCore::uint32 nStage, Sampler::Enum nState) const = 0;
00937 
00938         /**
00939         *  @brief
00940         *    Sets a single sampler-state parameter
00941         *
00942         *  @param[in] nStage
00943         *    Texture stage to set the value
00944         *  @param[in] nState
00945         *    State variable that is being modified. This parameter
00946         *    can be any member of the sampler enumerated type.
00947         *  @param[in] nValue
00948         *    New value for the sampler state to be set. The meaning of
00949         *    this parameter is dependent on the value specified for nState.
00950         *    For example, if nState is Sampler::AddressU, the second parameter
00951         *    must be one member of the Sampler::AddressU enumerated type. (e.g. TextureAddressing::Wrap)
00952         *
00953         *  @return
00954         *    'true' if all went fine, else 'false'
00955         *
00956         *  @note
00957         *    - If the state to set is 'Sampler::MipFilter' and the texture buffer at the given texture state
00958         *      has no mipmaps, the value is internally set to 'TextureFiltering::None' automatically for proper
00959         *      rendering of the texture buffer.
00960         *
00961         *  @see
00962         *    - GetDefaultSamplerState()
00963         */
00964         virtual bool SetSamplerState(PLCore::uint32 nStage, Sampler::Enum nState, PLCore::uint32 nValue) = 0;
00965 
00966         //[-------------------------------------------------------]
00967         //[ Misc                                                  ]
00968         //[-------------------------------------------------------]
00969         /**
00970         *  @brief
00971         *    Returns the swap interval (vertical synchronization)
00972         *
00973         *  @return
00974         *    The swap interval
00975         *
00976         *  @note
00977         *    - Please note that the swap interval is only a hint and can be overwritten by the driver settings!
00978         */
00979         virtual PLCore::uint32 GetSwapInterval() const = 0;
00980 
00981         /**
00982         *  @brief
00983         *    Sets the swap interval (vertical synchronization)
00984         *
00985         *  @param[in] nSwapInterval
00986         *    The swap interval, default value is 1
00987         *
00988         *  @see
00989         *    - GetSwapInterval()
00990         */
00991         virtual void SetSwapInterval(PLCore::uint32 nSwapInterval = 1) = 0;
00992 
00993         /**
00994         *  @brief
00995         *    Begins a scene
00996         *
00997         *  @return
00998         *    'true' if all went fine, else 'false'
00999         *     (e.g. if BeginScene is called while already in a BeginScene/EndScene pair.
01000         *     This happens only when BeginScene is called twice without first calling EndScene.
01001         *
01002         *  @see
01003         *    - EndScene()
01004         */
01005         virtual bool BeginScene() = 0;
01006 
01007         /**
01008         *  @brief
01009         *    Ends a scene that was begun by calling the BeginScene method
01010         *
01011         *  @return
01012         *    'true' if all went fine, else 'false'
01013         *
01014         *  @note
01015         *    - When this method succeeds, the scene has been queued up for rendering by the
01016         *      driver. This is not a synchronous method, so the scene is not guaranteed to
01017         *      have completed rendering when this method returns.
01018         *    - When scene rendering begins successfully, you must call this method before
01019         *      you can call the BeginScene method to start rendering another scene. If a
01020         *      prior call to BeginScene method fails, the scene did not begin and this method
01021         *      should not be called.
01022         */
01023         virtual bool EndScene() = 0;
01024 
01025         /**
01026         *  @brief
01027         *    Gets the window dimensions of a render target surface onto
01028         *    which a 3-D volume projects
01029         *
01030         *  @param[out] pfMinZ
01031         *    If not a null pointer, receives minimum z value describing the range of depth values into
01032         *    which a scene is to be rendered
01033         *  @param[out] pfMaxZ
01034         *    If not a null pointer, receives maximum z value describing the range of depth values into
01035         *    which a scene is to be rendered
01036         *
01037         *  @return
01038         *    The current viewport rectangle
01039         *
01040         *  @note
01041         *    - Rectangle.vMin is the pixel coordinate of the upper-left corner of the
01042         *      viewport on the render target surface. Unless you want to render to
01043         *      a subset of the surface, this member can be set to 0.
01044         *    - Rectangle.vMax define the other corner of the clip volume, in pixels. Unless
01045         *      you are rendering only to a subset of the surface, this member should be set
01046         *      to the dimension of the render target surface. If < 0 the dimension of the
01047         *      current renderer surface is set.
01048         *    - Usually, applications render to the entire target surface; when rendering on a
01049         *      640×480 surface, these cRectangle members from above should be 0, 0, 640, and 480, respectively.
01050         *    - pfMinZ and pfMaxZ indicate the depth-ranges into which the scene will be rendered and
01051         *      are not used for clipping. Most applications set these members to 0.0 and 1.0 to enable
01052         *      the system to render to the entire range of depth values in the depth buffer. In some
01053         *      cases, you can achieve special effects by using other depth ranges. For instance, to
01054         *      render a heads-up display in a game, you can set both values to 0.0 to force the system
01055         *      to render objects in a scene in the foreground, or you might set them both to 1.0 to
01056         *      render an object that should always be in the background.
01057         */
01058         virtual const PLMath::Rectangle &GetViewport(float *pfMinZ = nullptr, float *pfMaxZ = nullptr) const = 0;
01059 
01060         /**
01061         *  @brief
01062         *    Defines the window dimensions of a render target surface onto
01063         *    which a 3-D volume projects
01064         *
01065         *  @param[in] pRectangle
01066         *    Viewport rectangle, if a null pointer, use the whole render target surface
01067         *  @param[in] fMinZ
01068         *    Minimum z value
01069         *  @param[in] fMaxZ
01070         *    Maximum z value
01071         *
01072         *  @return
01073         *    'true' if all went fine, else 'false'
01074         *
01075         *  @see
01076         *    - GetViewport()
01077         */
01078         virtual bool SetViewport(const PLMath::Rectangle *pRectangle = nullptr, float fMinZ = 0.0f, float fMaxZ = 1.0f) = 0;
01079 
01080         /**
01081         *  @brief
01082         *    Gets the scissor rectangle
01083         *
01084         *  @return
01085         *    The current scissor rectangle
01086         *
01087         *  @note
01088         *    - cRectangle.vMin is the pixel coordinate of the upper-left corner of the
01089         *      scissor rectangle on the render target surface. Unless you want to render to
01090         *      a subset of the surface, this member can be set to 0.
01091         *    - cRectangle.vMax define the other corner of the clip volume, in pixels. Unless
01092         *      you are rendering only to a subset of the surface, this member should be set
01093         *      to the dimension of the render target surface. If < 0 the dimension of the
01094         *      current renderer viewport is set.
01095         *    - The scissor rectangle is used as a rectangular clipping region
01096         *    - The default scissor rectangle is the full viewport
01097         *    - The scissor test is enabled and disabled using SetRenderState() with argument
01098         */
01099         virtual const PLMath::Rectangle &GetScissorRect() const = 0;
01100 
01101         /**
01102         *  @brief
01103         *    Sets the scissor rectangle
01104         *
01105         *  @param[in] pRectangle
01106         *    Viewport rectangle, if a null pointer, use the whole set viewport
01107         *
01108         *  @return
01109         *    'true' if all went fine, else 'false'
01110         *
01111         *  @see
01112         *    - GetScissorRect()
01113         */
01114         virtual bool SetScissorRect(const PLMath::Rectangle *pRectangle = nullptr) = 0;
01115 
01116         /**
01117         *  @brief
01118         *    Gets the depth bounds
01119         *
01120         *  @param[out] fZMin
01121         *    Will receive the Z minimum value
01122         *  @param[out] fZMax
01123         *    Will receive the Z maximum value
01124         *
01125         *  @return
01126         *    'true' if all went fine, else 'false' (maybe not supported by the hardware)
01127         *
01128         *  @note
01129         *    - The depth bounds test is a kind of scissor rect technique to reject
01130         *      untouched fragments
01131         *    - Has only an effect if Capabilities::bDepthBoundsTest is true
01132         *    - If fZMin is 0.0 and fZMax is 1.0 no depth bounds test will be performed (default)
01133         */
01134         virtual bool GetDepthBounds(float &fZMin, float &fZMax) const = 0;
01135 
01136         /**
01137         *  @brief
01138         *    Sets the depth bounds
01139         *
01140         *  @param[in] fZMin
01141         *    Z minimum value (range: 0.0-1.0, must be less than or equal to fZMax)
01142         *  @param[in] fZMax
01143         *    Z maximum value (range: 0.0-1.0, must be greater than or equal to fZMin)
01144         *
01145         *  @return
01146         *    'true' if all went fine, else 'false' (maybe not supported by the hardware)
01147         *
01148         *  @see
01149         *    - GetDepthBounds()
01150         */
01151         virtual bool SetDepthBounds(float fZMin = 0.0f, float fZMax = 1.0f) = 0;
01152 
01153         /**
01154         *  @brief
01155         *    Returns the color mask
01156         *
01157         *  @param[out] bRed
01158         *    Will receive whether the red component is written
01159         *  @param[out] bGreen
01160         *    Will receive whether the green component is written
01161         *  @param[out] bBlue
01162         *    Will receive whether the blue component is written
01163         *  @param[out] bAlpha
01164         *    Will receive whether the alpha component is written
01165         *
01166         *  @note
01167         *    - With the color mask you can decide which color components are drawn,
01168         *      if you e.g. only want to fill the depth buffer you can set all components
01169         *      to false
01170         *    - If no color components are written, some GPU's are optimized to use for instance the
01171         *      z buffer much more performant
01172         *    - By default all color components are written
01173         */
01174         virtual void GetColorMask(bool &bRed, bool &bGreen, bool &bBlue, bool &bAlpha) const = 0;
01175 
01176         /**
01177         *  @brief
01178         *    Sets the color mask
01179         *
01180         *  @param[in] bRed
01181         *    Write red component?
01182         *  @param[in] bGreen
01183         *    Write green component?
01184         *  @param[in] bBlue
01185         *    Write blue component?
01186         *  @param[in] bAlpha
01187         *    Write alpha component?
01188         *
01189         *  @return
01190         *    'true' if all went fine, else 'false'
01191         *
01192         *  @see
01193         *    - GetColorMask()
01194         */
01195         virtual bool SetColorMask(bool bRed = true, bool bGreen = true, bool bBlue = true, bool bAlpha = true) = 0;
01196 
01197         /**
01198         *  @brief
01199         *    Clears the viewport to a specified RGBA color, clears the depth buffer,
01200         *    and erases the stencil buffer
01201         *
01202         *  @param[in] nFlags
01203         *    Flags that indicate what should be cleared. This parameter can be any
01204         *    combination of the following flags, but at least one flag must be used:
01205         *    Clear::Color, Clear::ZBuffer and Clear::Stencil, see Clear flags
01206         *  @param[in] cColor
01207         *    RGBA clear color (used if Clear::Color is set)
01208         *  @param[in] fZ
01209         *    Z clear value. (if Clear::ZBuffer is set)
01210         *    This parameter can be in the range from 0.0 through 1.0. A value of 0.0
01211         *    represents the nearest distance to the viewer, and 1.0 the farthest distance.
01212         *  @param[in] nStencil
01213         *    Value to clear the stencil-buffer with. This parameter can be in the range from
01214         *    0 through 2^n–1, where n is the bit depth of the stencil buffer.
01215         *
01216         *  @return
01217         *    'true' if all went fine, else 'false'
01218         *
01219         *  @note
01220         *    - If scissor is disabled or set to the full viewport size some GPU's may be able to clear more efficient
01221         *    - The color mask has no effect on the clear operation
01222         */
01223         virtual bool Clear(PLCore::uint32 nFlags = Clear::Color | Clear::ZBuffer,
01224                            const PLGraphics::Color4 &cColor = PLGraphics::Color4::Black, float fZ = 1.0f,
01225                            PLCore::uint32 nStencil = 0) = 0;
01226 
01227         //[-------------------------------------------------------]
01228         //[ Get/set current resources                             ]
01229         //[-------------------------------------------------------]
01230         /**
01231         *  @brief
01232         *    Returns the current render target
01233         *
01234         *  @param[out] pnFace
01235         *    If not a null pointer, this will receive the current cube map face
01236         *
01237         *  @return
01238         *    Current renderer target, a null pointer if there's no one
01239         */
01240         virtual Surface *GetRenderTarget(PLCore::uint8 *pnFace = nullptr) const = 0;
01241 
01242         /**
01243         *  @brief
01244         *    Returns the current color render target
01245         *
01246         *  @param[in] nColorIndex
01247         *    Color index of the color render target to return
01248         *
01249         *  @return
01250         *    Current color renderer target, a null pointer if there's no one
01251         */
01252         virtual TextureBuffer *GetColorRenderTarget(PLCore::uint8 nColorIndex = 0) const = 0;
01253 
01254         /**
01255         *  @brief
01256         *    Sets the current render target
01257         *
01258         *  @param[in] pSurface
01259         *    Current renderer target, can be a null pointer
01260         *  @param[in] nFace
01261         *    Cube map face to render in (0-5) - only used if 'pSurface' is a cube texture buffer render target
01262         *
01263         *  @return
01264         *    'true' if all went fine, else 'false'
01265         *
01266         *  @note
01267         *    - SetViewport() and SetScissorRect() are called automatically
01268         */
01269         virtual bool SetRenderTarget(Surface *pSurface, PLCore::uint8 nFace = 0) = 0;
01270 
01271         /**
01272         *  @brief
01273         *    Sets the current color render target (for multi render targets)
01274         *
01275         *  @param[in] pTextureBuffer
01276         *    Current color renderer target, can be a null pointer
01277         *  @param[in] nColorIndex
01278         *    Color index of this render target, if 0 this will set the main color render target of the
01279         *    current set render target. (see SetRenderTarget())
01280         *  @param[in] nFace
01281         *    Cube map face to render in ([TODO])
01282         *
01283         *  @return
01284         *    'true' if all went fine, else 'false' (maybe invalid color index of the current render target?)
01285         *
01286         *  @note
01287         *    - This color render targets MUST have the dimension and format of the render target
01288         */
01289         virtual bool SetColorRenderTarget(TextureBuffer *pTextureBuffer, PLCore::uint8 nColorIndex = 0, PLCore::uint8 nFace = 0) = 0;
01290 
01291         /**
01292         *  @brief
01293         *    Sets the current depth render target
01294         *
01295         *  @param[in] pTextureBuffer
01296         *    Current depth renderer target, can be a null pointer
01297         *  @param[in] nFace
01298         *    Cube map face to render in ([TODO])
01299         *
01300         *  @return
01301         *    'true' if all went fine, else 'false'
01302         *
01303         *  @note
01304         *    - This depth render targets MUST have the dimension and format of the render target
01305         */
01306         virtual bool SetDepthRenderTarget(TextureBuffer *pTextureBuffer, PLCore::uint8 nFace = 0) = 0;
01307 
01308         /**
01309         *  @brief
01310         *    Makes a screenshot of the current render target (see GetRenderTarget())
01311         *
01312         *  @param[out] cImage
01313         *    Image which will receive the screenshot data (usually RGBA unsigned byte)
01314         *
01315         *  @return
01316         *    'true' if all went fine, else 'false'
01317         */
01318         virtual bool MakeScreenshot(PLGraphics::Image &cImage) = 0;
01319 
01320         /**
01321         *  @brief
01322         *    Gets the current texture buffer at the given stage
01323         *
01324         *  @param[in] nStage
01325         *    Texture stage
01326         *
01327         *  @return
01328         *    The current texture buffer at the given stage, a null pointer if there's no one
01329         */
01330         virtual TextureBuffer *GetTextureBuffer(PLCore::uint32 nStage) const = 0;
01331 
01332         /**
01333         *  @brief
01334         *    Sets the current texture buffer at the given stage
01335         *
01336         *  @param[in] nStage
01337         *    Texture stage. (0 - max texture stages -> see Capabilities::nMaxTextureUnits)
01338         *    < 0 = set all available texture stages to this setting.
01339         *  @param[in] pTextureBuffer
01340         *    The texture buffer which should be set, a null pointer if no texture buffer should be set
01341         *
01342         *  @return
01343         *    'true' if all went fine, else 'false' (maybe this is already the current
01344         *    texture buffer at the given stage)
01345         *
01346         *  @see
01347         *    - GetTransformState(), bOriginal parameter description
01348         */
01349         virtual bool SetTextureBuffer(int nStage = -1, TextureBuffer *pTextureBuffer = nullptr) = 0;
01350 
01351         /**
01352         *  @brief
01353         *    Gets the current index buffer
01354         *
01355         *  @return
01356         *    The current index buffer, a null pointer if there's no one
01357         */
01358         virtual IndexBuffer *GetIndexBuffer() const = 0;
01359 
01360         /**
01361         *  @brief
01362         *    Sets the current index buffer
01363         *
01364         *  @param[in] pIndexBuffer
01365         *    The index buffer which should be set, a null pointer if no index buffer should be set
01366         *
01367         *  @return
01368         *    'true' if all went fine, else 'false' (maybe this is already the current index buffer)
01369         */
01370         virtual bool SetIndexBuffer(IndexBuffer *pIndexBuffer = nullptr) = 0;
01371 
01372         /**
01373         *  @brief
01374         *    Returns the currently used program
01375         *
01376         *  @return
01377         *    The currently used program, can be a null pointer
01378         */
01379         virtual Program *GetProgram() const = 0;
01380 
01381         /**
01382         *  @brief
01383         *    Sets the currently used program
01384         *
01385         *  @param[in] pProgram
01386         *    Program to use, can be a null pointer
01387         *
01388         *  @return
01389         *    'true' if all went fine, else 'false' (invalid program?)
01390         */
01391         virtual bool SetProgram(Program *pProgram = nullptr) = 0;
01392 
01393         //[-------------------------------------------------------]
01394         //[ Draw                                                  ]
01395         //[-------------------------------------------------------]
01396         /**
01397         *  @brief
01398         *    Renders the specified geometric primitive, based on an array of vertices
01399         *
01400         *  @param[in] nType
01401         *    Member of the primitive enumerated type, describing the type of primitive to render
01402         *  @param[in] nStartIndex
01403         *    Start vertex index for vertices used during this call
01404         *  @param[in] nNumVertices
01405         *    Number of vertices used during this call
01406         *
01407         *  @return
01408         *    'true' if all went fine, else 'false'
01409         *
01410         *  @note
01411         *    - DrawPrimitives() fails if no vertex array is set
01412         */
01413         virtual bool DrawPrimitives(Primitive::Enum nType, PLCore::uint32 nStartIndex, PLCore::uint32 nNumVertices) = 0;
01414 
01415         /**
01416         *  @brief
01417         *    Renders the specified geometric primitive, based on indexing into an array of vertices
01418         *
01419         *  @param[in] nType
01420         *    Member of the primitive enumerated type, describing the type of primitive to render, e.g. "Primitive::TriangleList"
01421         *  @param[in] nMinIndex
01422         *    Minimum vertex index for vertices used during this call, usually "0"
01423         *  @param[in] nMaxIndex
01424         *    Maximum vertex index for vertices used during this call, usually "pVertexBuffer->GetNumOfElements() - 1" when "pVertexBuffer" is your currently used vertex buffer
01425         *  @param[in] nStartIndex
01426         *    Start vertex index for vertices used during this call, usually "0"
01427         *  @param[in] nNumVertices
01428         *    Number of vertices used during this call, usually "pIndexBuffer->GetNumOfElements()" when "pIndexBuffer" is your currently used index buffer
01429         *
01430         *  @return
01431         *    'true' if all went fine, else 'false'
01432         *
01433         *  @note
01434         *    - This method draws indexed primitives from the current set of data input streams
01435         *    - The nMinIndex and nMaxIndex parameters specify the range of vertex indices used for each DrawIndexedPrimitive()
01436         *      call. These are used to optimize vertex processing of indexed primitives by processing a sequential range of
01437         *      vertices prior to indexing into these vertices. It is invalid for any indices used during this call to reference
01438         *      any vertices outside of this range.
01439         *    - DrawIndexedPrimitive() fails if no index and/or vertex array is set
01440         *    - The Primitive::PointList member of the primitive enumerated type is not supported and is not a valid type for this method
01441         */
01442         virtual bool DrawIndexedPrimitives(Primitive::Enum nType, PLCore::uint32 nMinIndex, PLCore::uint32 nMaxIndex,
01443                                            PLCore::uint32 nStartIndex, PLCore::uint32 nNumVertices) = 0;
01444 
01445 
01446     //[-------------------------------------------------------]
01447     //[ Protected functions                                   ]
01448     //[-------------------------------------------------------]
01449     protected:
01450         /**
01451         *  @brief
01452         *    Constructor
01453         */
01454         PLRENDERER_API Renderer();
01455 
01456         /**
01457         *  @brief
01458         *    Destructor
01459         */
01460         PLRENDERER_API virtual ~Renderer();
01461 
01462 
01463     //[-------------------------------------------------------]
01464     //[ Private functions                                     ]
01465     //[-------------------------------------------------------]
01466     private:
01467         /**
01468         *  @brief
01469         *    Copy constructor
01470         *
01471         *  @param[in] cSource
01472         *    Source to copy from
01473         */
01474         Renderer(const Renderer &cSource);
01475 
01476         /**
01477         *  @brief
01478         *    Copy operator
01479         *
01480         *  @param[in] cSource
01481         *    Source to copy from
01482         *
01483         *  @return
01484         *    Reference to this instance
01485         */
01486         Renderer &operator =(const Renderer &cSource);
01487 
01488 
01489 };
01490 
01491 
01492 //[-------------------------------------------------------]
01493 //[ Namespace                                             ]
01494 //[-------------------------------------------------------]
01495 } // PLRenderer
01496 
01497 
01498 #endif // __PLRENDERER_RENDERER_H__


PixelLight PixelLight 0.9.11-R1
Copyright (C) 2002-2012 by The PixelLight Team
Last modified Thu Feb 23 2012 14:08:59
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported