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

render.h

Go to the documentation of this file.
00001 /***************************************************************************
00002                           render.h  -  Render device
00003                              -------------------
00004     begin                : Wed Oct 31 2001
00005     copyright            : (C) 2001 by Reality Rift Studios
00006     email                : mattias@realityrift.com
00007  ***************************************************************************
00008 
00009  The contents of this file are subject to the Mozilla Public License Version
00010  1.1 (the "License"); you may not use this file except in compliance with
00011  the License. You may obtain a copy of the License at 
00012  http://www.mozilla.org/MPL/
00013 
00014  Software distributed under the License is distributed on an "AS IS" basis,
00015  WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00016  for the specific language governing rights and limitations under the
00017  License.
00018 
00019  The Original Code is the NeoEngine, render.h
00020 
00021  The Initial Developer of the Original Code is Mattias Jansson.
00022  Portions created by Mattias Jansson are Copyright (C) 2001
00023  Reality Rift Studios. All Rights Reserved.
00024 
00025  ***************************************************************************/
00026 
00027 #ifndef __NERENDERDEVICE_H
00028 #define __NERENDERDEVICE_H
00029 
00030 
00037 #include "base.h"
00038 #include "buffer.h"
00039 #include "pointer.h"
00040 #include "texture.h"
00041 #include "input.h"
00042 #include "callback.h"
00043 #include "pointer.h"
00044 #include "projection.h"
00045 #include "rendercaps.h"
00046 #include "renderwindow.h"
00047 #include "renderprimitive.h"
00048 #include "viewport.h"
00049 #include "program.h"
00050 
00051 
00052 namespace NeoEngine
00053 {
00054 
00055 
00056 // External classes
00057 class Light;
00058 class PixelBuffer;
00059 class Program;
00060 class ShadowGenerator;
00061 class Color;
00062 class RenderAdapter;
00063 
00064 
00076 class NEOENGINE_API RenderDevice : public InputDevice, public TextureLoader, public ConfigCallback
00077 {
00078     friend class Core;
00079 
00080     public:
00081 
00085         enum RENDERTARGET
00086         {
00088           INVALIDBUFFER                               = 0xFFFFFFFF,
00089 
00091           FRAMEBUFFER                                 = 0x00000000,
00092 
00094           PIXELBUFFER                                 = 0x01000000
00095         };
00096 
00100         enum RENDERFRAMEFLAGS
00101         {
00103           NOFLAGS                                     = 0x00000000,
00104 
00106           NOSORT                                      = 0x00000001
00107         };
00108 
00112         enum CULLMODE
00113         {
00115           CULLNONE                                    = 0,
00116 
00118           CULLBACK                                    = 1,
00119 
00121           CULLFRONT                                   = 2,
00122 
00124           CULLBOTH                                    = 3
00125         };
00126 
00130         enum STENCILOP
00131         {
00133           STENCILOP_KEEP                              = 0,
00134 
00136           STENCILOP_ZERO                              = 1,
00137 
00139           STENCILOP_REPLACE                           = 2,
00140 
00141           /* Increment value, clamp to max */
00142           STENCILOP_INCR                              = 3,
00143 
00145           STENCILOP_DECR                              = 4,
00146 
00148           STENCILOP_INVERT                            = 5
00149         };
00150 
00154         enum STENCILFUNC
00155         {
00157           STENCILFUNC_NEVER                           = 0,
00158 
00160           STENCILFUNC_LESS                            = 1,
00161 
00163           STENCILFUNC_LEQUAL                          = 2,
00164 
00166           STENCILFUNC_GREATER                         = 3,
00167 
00169           STENCILFUNC_GEQUAL                          = 4,
00170 
00172           STENCILFUNC_EQUAL                           = 5,
00173 
00175           STENCILFUNC_NOTEQUAL                        = 6,
00176 
00178           STENCILFUNC_ALWAYS                          = 7
00179         };
00180 
00184         enum BUFFER
00185         {
00187           COLORBUFFER                                 = 1,
00188 
00190           ZBUFFER                                     = 2,
00191 
00193           STENCILBUFFER                               = 4
00194         };
00195 
00196 
00197     protected:
00198 
00200         ModulePtr                                     m_pkModule;
00201 
00203         TexturePool                                  *m_pkTexturePool;
00204 
00206         Projection                                   *m_pkProjection;
00207 
00209         PerspectiveProjection                         m_kPerspectiveProjection;
00210 
00212         OrthographicProjection                        m_kOrthographicProjection;
00213 
00215         Projection                                    m_kCustomProjection;
00216 
00218         Matrix                                        m_kViewMatrix;
00219 
00221         RenderWindow                                  m_kWindow;
00222 
00224         Viewport                                      m_kViewport;
00225 
00227         CULLMODE                                      m_eCullMode;
00228 
00230         unsigned int                                  m_uiDefaultTextureFilter;
00231 
00233         unsigned int                                  m_uiDefaultMaxAnisotropy;
00234 
00236         FileManager                                  *m_pkFileManager;
00237 
00238 
00244                                                       RenderDevice( FileManager *pkFileManager, InputManager *pkInputManager );
00245 
00249         virtual                                      ~RenderDevice();
00250 
00255         virtual void                                  SetProjection( const Matrix &rkMatrix ) = 0;
00256 
00257 
00258 
00259     public:
00260 
00261 
00263         ShadowGenerator                              *m_pkShadowGenerator;
00264 
00265 
00273         virtual bool                                  Open( const RenderWindow &rkWndData ) = 0;
00274 
00278         virtual void                                  Close() = 0;
00279 
00285         virtual void                                  Begin( const Matrix &rkViewMatrix, unsigned int uiFlags = NOFLAGS ) = 0;
00286 
00290         virtual void                                  End() = 0;
00291 
00297         virtual void                                  Render( const RenderPrimitive &rkPrimitive, unsigned int uiFlags = RenderPrimitive::NOFLAGS ) = 0;
00298 
00304         virtual unsigned int                          SetRenderTarget( unsigned int uiTarget ) = 0;
00305 
00311         virtual CULLMODE                              SetCullMode( CULLMODE eCullMode = CULLBACK ) = 0;
00312 
00319         virtual void                                  SetStencilOp( STENCILOP eStencilFail, STENCILOP eZFail, STENCILOP eZPass ) = 0;
00320 
00327         virtual void                                  SetStencilFunc( STENCILFUNC eFunc, unsigned int uiRefValue, unsigned int uiTestMask ) = 0;
00328 
00333         virtual void                                  SetStencilMask( unsigned int uiWriteMask ) = 0;
00334 
00339         virtual void                                  SetTargetMask( bool bWrite ) = 0;
00340 
00345         virtual void                                  SetDefaultTextureFiltering( unsigned int uiMode );
00346 
00351         virtual void                                  SetDefaultMaxAnisotropy( unsigned int uiMaxAnisotropy );
00352 
00360         virtual bool                                  SetStorageSize( unsigned int uiVertexStorageSize, unsigned int uiPolygonStorageSize ) = 0;
00361 
00366         void                                          SetPerspectiveProjection();
00367 
00374         virtual void                                  SetPerspectiveProjection( float fFOV, float fZNear, float fZFar );
00375 
00382         void                                          SetOrthographicProjection();
00383 
00395         virtual void                                  SetOrthographicProjection( float fLeft, float fTop, float fRight, float fBottom, float fZNear = 0.0f, float fZFar = 1.0f );
00396 
00401         virtual void                                  SetCustomProjection( const Matrix &rkMatrix );
00402 
00410         virtual void                                  SetViewport( int iX, int iY, int iWidth, int iHeight ) = 0;
00411 
00420         virtual void                                  Clear( unsigned int uiTargets, const Color &rkColor, float fZValue, unsigned int uiStencilValue ) = 0;
00421 
00425         virtual void                                  Flip() = 0;
00426 
00432         virtual int                                   AddLight( Light *pkLight ) = 0;
00433 
00444         virtual TexturePtr                            LoadTexture( const std::string &rstrFilename, Texture::TEXTURETYPE eTextureType = Texture::TEX2D, Texture::TEXTUREFORMAT eTextureFormat = Texture::DEFAULT, unsigned int uiFlags = Texture::NOFLAGS, unsigned int uiFiltering = 0, unsigned int uiMaxAnisotropy = 1 ) = 0;
00445 
00451         virtual TexturePtr                            GetTexture( const std::string &rstrName ) = 0;
00452 
00460         virtual TexturePtr                            CreateTexture( const std::string &rstrName, Texture::TEXTURETYPE eTextureType = Texture::TEX2D, Texture::TEXTUREFORMAT eTextureFormat = Texture::DEFAULT ) = 0;
00461 
00470         virtual VertexBufferPtr                       CreateVertexBuffer( unsigned int uiType = Buffer::NORMAL, unsigned int uiNumVertices = 0, const VertexDeclaration *pkFormat = 0, const void *pData = 0 ) = 0;
00471 
00480         virtual PolygonBufferPtr                      CreatePolygonBuffer( unsigned int uiType = Buffer::NORMAL, unsigned int uiNumPolygons = 0, const Polygon *pkData = 0, bool bStripify = false ) = 0;
00481 
00489         virtual PolygonStripBufferPtr                 CreatePolygonStripBuffer( unsigned int uiType = Buffer::NORMAL, unsigned int uiNumPolygons = 0, const unsigned short *pusData = 0 ) = 0;
00490 
00499         virtual PixelBuffer                          *CreatePixelBuffer( unsigned int uiWidth, unsigned int uiHeight, unsigned int uiBPP, Texture::TEXTURETYPE eTextureType = Texture::TEX2D ) = 0;
00500 
00506         virtual ProgramPtr                            CreateProgram( Program::PROGRAMTYPE eType ) = 0;
00507 
00514         virtual ProgramPtr                            GetProgram( Program::PROGRAMTYPE eType, const std::string &rstrName ) = 0;
00515 
00520         inline const Matrix                          &GetProjectionMatrix() const { return m_pkProjection->m_kMatrix; }
00521 
00525         inline float                                  GetZNear() const { return m_pkProjection->m_fZNear; }
00526 
00530         inline float                                  GetZFar() const { return m_pkProjection->m_fZFar; }
00531 
00535         inline unsigned int                           GetWidth() { return m_kWindow.m_kResolution.m_uiWidth; }
00536 
00540         inline unsigned int                           GetHeight() { return m_kWindow.m_kResolution.m_uiHeight; }
00541 
00545         inline unsigned int                           GetBPP() { return m_kWindow.m_kResolution.m_uiBPP; }
00546 
00550         inline float                                  GetFOV() const { return m_kPerspectiveProjection.m_fFOV; }
00551 
00556         inline const Viewport                        &GetViewport() const { return m_kViewport; }
00557 
00561         virtual std::string                           GetStatistics() = 0;
00562 
00567         inline const RenderWindow                    &GetWindow() const { return m_kWindow; }
00568 
00573         inline const RenderCaps                      &GetCaps() const { return m_kWindow.m_kCaps; }
00574 
00578         inline Projection::PROJECTIONMODE             GetProjectionMode() const { return m_pkProjection->m_eMode; }
00579 
00583         inline const Matrix                          &GetViewMatrix() const { return m_kViewMatrix; }
00584 
00589         inline unsigned int                           GetDefaultTextureFiltering() { return m_uiDefaultTextureFilter; }
00590 
00596         virtual void                                  SetMousePos( int iX, int iY ) = 0;
00597 
00602         virtual void                                  CaptureMouse( bool bCapture ) = 0;
00603 
00608         virtual void                                  ShowCursor( bool bShow ) = 0;
00609 
00616         virtual void                                  RegisterFrameCallback( FrameCallback::FRAMECALLBACKTYPE eType, FrameCallback *pkCallback, bool bRegister ) = 0;
00617 
00622         virtual void                                  QueryAdapters( std::vector< RenderAdapter > *pvkAdapters ) = 0;
00623 
00629         virtual void                                  QueryResolutions( std::vector< RenderResolution > *pvkResolutions, unsigned int uiAdapter = 0 ) = 0;
00630 };
00631 
00632 }; // namespace NeoEngine
00633 
00634 
00635 #endif  // __NERENDER_H

Generated on Wed Jan 21 14:21:07 2004 for NeoEngine by doxygen 1.3.5