# Home    # nevrax.com   
Nevrax
Nevrax.org
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
Docs
 
Documentation  
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  

driver_user.h

Go to the documentation of this file.
00001 
00007 /* Copyright, 2001 Nevrax Ltd.
00008  *
00009  * This file is part of NEVRAX NEL.
00010  * NEVRAX NEL is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2, or (at your option)
00013  * any later version.
00014 
00015  * NEVRAX NEL is distributed in the hope that it will be useful, but
00016  * WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00018  * General Public License for more details.
00019 
00020  * You should have received a copy of the GNU General Public License
00021  * along with NEVRAX NEL; see the file COPYING. If not, write to the
00022  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00023  * MA 02111-1307, USA.
00024  */
00025 
00026 #ifndef NL_DRIVER_USER_H
00027 #define NL_DRIVER_USER_H
00028 
00029 #include "nel/misc/types_nl.h"
00030 #include "nel/misc/common.h"
00031 #include "nel/3d/u_driver.h"
00032 #include "3d/event_mouse_listener.h"
00033 #include "3d/driver.h"
00034 #include "3d/register_3d.h"
00035 #include "3d/vertex_buffer.h"
00036 #include "3d/primitive_block.h"
00037 #include "3d/font_manager.h"
00038 #include "3d/material_user.h"
00039 #include "3d/ptr_set.h"
00040 #include "3d/shape_bank_user.h"
00041 #include "3d/light_user.h"
00042 #include "3d/mesh_skin_manager.h"
00043 #include "3d/async_texture_manager.h"
00044 #include "3d/lod_character_manager.h"
00045 
00046 #define NL3D_MEM_DRIVER                                         NL_ALLOC_CONTEXT( 3dDrv )
00047 
00048 namespace NL3D 
00049 {
00050 
00051 
00052 class   CTextureUser;
00053 class   CTextContextUser;
00054 class   CSceneUser;
00055 
00056 
00057 // ***************************************************************************
00063 class CDriverUser : public UDriver
00064 {
00065 // **********************
00066 protected:
00067         struct  CMatrixContext
00068         {
00069                 CScissor        Scissor;                // Init to fullscreen.
00070                 CViewport       Viewport;               // Init to fullscreen.
00071                 CFrustum        Frustum;
00072                 CMatrix         ViewMatrix;
00073                 CMatrix         ModelMatrix;
00074         };
00075 
00076 
00077 protected:
00078         IDriver                                 *_Driver;
00079         bool                                    _WindowInit;
00080         CMatrixContext                  _CurrentMatrixContext;
00081         CFontManager                    _FontManager;
00082         // Components List.
00083         typedef CPtrSet<CTextureUser>           TTextureSet;
00084         typedef CPtrSet<CMaterialUser>          TMaterialSet;
00085         typedef CPtrSet<CTextContextUser>       TTextContextSet;
00086         typedef CPtrSet<CSceneUser>                     TSceneSet;
00087         TTextureSet                             _Textures;
00088         TMaterialSet                    _Materials;
00089         TTextContextSet                 _TextContexts;
00090         TSceneSet                               _Scenes;
00091         CShapeBankUser                  _ShapeBank;
00092         // There is one MeshSkinManager per driver, and for all scenes.
00093         CMeshSkinManager                _MeshSkinManager;
00094         // There is one AsyncTextureManager per driver, and for all scenes
00095         CAsyncTextureManager    _AsyncTextureManager;
00096         // There is one LodCharacterManager per driver, and for all scenes
00097         CLodCharacterManager    _LodCharacterManager;
00098 
00099         // For 2D/3D Interface.
00100         CVertexBuffer                   _VBFlat;
00101         CVertexBuffer                   _VBColor;
00102         CVertexBuffer                   _VBUv;
00103         CVertexBuffer                   _VBColorUv;
00104         CPrimitiveBlock                 _PBLine, _PBTri, _PBQuad;
00105 
00106         CVertexBuffer                   _VBQuadsColUv;
00107         // For security, texture are initUnlit() at init()/release().
00108         CMaterialUser                   _MatFlat;
00109         CMaterialUser                   _MatText;
00110 
00111 
00112         // StaticInit
00113         static  bool                    _StaticInit;
00114 
00115 protected:
00116         void                    setupMatrixContext();
00117         CMaterial               &convMat(UMaterial &mat);
00118 
00119 
00120 // **********************
00121 public:
00122 
00123 
00125         // @{
00126         CDriverUser();
00127         virtual ~CDriverUser();
00128         // @}
00129 
00130 
00132         // @{
00133 
00135         virtual TModeList               enumModes();
00136 
00137         virtual void                    disableHardwareVertexProgram();
00138         virtual void                    disableHardwareVertexArrayAGP();
00139         virtual void                    disableHardwareTextureShader();
00140 
00142         virtual void                    setDisplay(const CMode &mode) ;
00144         virtual void                    release() ;
00145 
00147         virtual bool                    activate(void);
00149         virtual bool                    isActive();
00150 
00151         // @}
00152 
00153 
00155         // @{
00157         virtual void                    clearRGBABuffer(CRGBA col= CRGBA(255,255,255,255));
00159         virtual void                    clearZBuffer();
00161         virtual void                    clearBuffers(CRGBA col= CRGBA(255,255,255,255));
00163         virtual void                    swapBuffers();
00164 
00165         // @}
00166 
00167 
00168 
00170         // @{
00171         virtual bool                    fogEnabled();
00172         virtual void                    enableFog(bool enable);
00174         virtual void                    setupFog(float start, float end, CRGBA color);
00175         // @}
00176 
00178         // @{
00179         virtual void                    setLight (uint8 num, const ULight& light);
00180         virtual void                    enableLight (uint8 num, bool enable=true);
00181         virtual void                    setAmbientColor (CRGBA color);
00182         // @}
00183 
00184 
00186         // @{
00188         virtual UScene                  *createScene() ;
00190         virtual void                    deleteScene(UScene      *scene) ;
00191         // @}
00192 
00193 
00194 
00196         // @{
00197 
00199         virtual UTextContext    *createTextContext(const std::string fontFileName, const std::string fontExFileName = "") ;
00201         virtual void                    deleteTextContext(UTextContext  *textContext) ;
00203         virtual void                    setFontManagerMaxMemory(uint maxMem) ;
00205         virtual         std::string getFontManagerCacheInformation() const ;
00206 
00207 
00211         virtual UTextureFile    *createTextureFile(const std::string &file) ;
00213         virtual void                    deleteTextureFile(UTextureFile *textfile) ;
00215         virtual UTextureRaw             *createTextureRaw() ;
00217         virtual void                    deleteTextureRaw(UTextureRaw *textraw) ;
00219         virtual UMaterial               *createMaterial() ;
00221         virtual void                    deleteMaterial(UMaterial *mat) ;
00222         // @}
00223 
00224 
00226 
00229         // @{
00230 
00233         virtual void                    setScissor(const CScissor &);
00234         virtual CScissor                getScissor();
00237         virtual void                    setViewport(const CViewport &);
00238         virtual CViewport               getViewport();
00241         virtual void                    setFrustum(const CFrustum &frust) ;
00242         virtual CFrustum                getFrustum() ;
00246         virtual void                    setViewMatrix(const CMatrix &mat) ;
00247         virtual CMatrix                 getViewMatrix() ;
00250         virtual void                    setModelMatrix(const CMatrix &mat) ;
00251         virtual CMatrix                 getModelMatrix() ;
00252 
00253 
00257         virtual void                    setMatrixMode2D(const CFrustum &frust) ;
00262         virtual void                    setMatrixMode3D(UCamera &camera) ;
00263 
00264         // @}
00265 
00266 
00268 
00272         // @{
00273 
00275         virtual void                    drawLine(const NLMISC::CLine &tri, UMaterial &mat) ;
00277         virtual void                    drawLine(const NLMISC::CLineColor &tri, UMaterial &mat) ;
00279         virtual void                    drawLine(const NLMISC::CLineUV &tri, UMaterial &mat) ;
00281         virtual void                    drawLine(const NLMISC::CLineColorUV &tri, UMaterial &mat) ;
00282 
00284         virtual void                    drawTriangle(const NLMISC::CTriangle &tri, UMaterial &mat) ;
00286         virtual void                    drawTriangle(const NLMISC::CTriangleColor &tri, UMaterial &mat) ;
00288         virtual void                    drawTriangle(const NLMISC::CTriangleUV &tri, UMaterial &mat) ;
00290         virtual void                    drawTriangle(const NLMISC::CTriangleColorUV &tri, UMaterial &mat) ;
00291 
00293         virtual void                    drawQuad(const NLMISC::CQuad &tri, UMaterial &mat) ;
00295         virtual void                    drawQuad(const NLMISC::CQuadColor &tri, UMaterial &mat) ;
00297         virtual void                    drawQuad(const NLMISC::CQuadUV &tri, UMaterial &mat) ;
00299         virtual void                    drawQuad(const NLMISC::CQuadColorUV &tri, UMaterial &mat) ;
00300 
00301         virtual void                    drawQuads(const std::vector<NLMISC::CQuadColorUV> &tri, UMaterial &mat) ;
00302         virtual void                    drawQuads(const NLMISC::CQuadColorUV *quads, uint32 nbQuads, UMaterial &mat) ;
00303         
00304         // @}
00305 
00306 
00308 
00310         // @{
00311 
00313         virtual void                    drawBitmap (float x, float y, float width, float height, class UTexture& texture, bool blend=true, CRGBA col= CRGBA(255,255,255,255)) ;
00315         virtual void                    drawLine (float x0, float y0, float x1, float y1, CRGBA col= CRGBA(255,255,255,255)) ;
00317         virtual void                    drawTriangle (float x0, float y0, float x1, float y1, float x2, float y2, CRGBA col) ;
00319         virtual void                    drawQuad (float x0, float y0, float x1, float y1, CRGBA col) ;
00321         virtual void                    drawQuad (float xcenter, float ycenter, float radius, CRGBA col) ;
00323         virtual void                    drawWiredQuad (float x0, float y0, float x1, float y1, CRGBA col) ;
00325         virtual void                    drawWiredQuad (float xcenter, float ycenter, float radius, CRGBA col) ;
00326 
00327         // @}
00328 
00329 
00330 
00332         // @{
00333         virtual uint32                  getImplementationVersion () const;
00334         virtual const char*             getDriverInformation ();
00335         virtual const char*             getVideocardInformation ();
00336         virtual sint                    getNbTextureStages();
00337         virtual void                    getWindowSize (uint32 &width, uint32 &height);
00338         virtual uint                    getWindowWidth ();
00339         virtual uint                    getWindowHeight ();
00340         virtual void                    getBuffer (CBitmap &bitmap) ;
00341         virtual void                    getZBuffer (std::vector<float>  &zbuffer) ;
00342         virtual void                    getBufferPart (CBitmap &bitmap, NLMISC::CRect &rect) ;
00343         virtual void                    getZBufferPart (std::vector<float>  &zbuffer, NLMISC::CRect &rect) ;
00344         virtual bool                    fillBuffer (CBitmap &bitmap);
00345         // @}
00346 
00347 
00349         // @{
00350         virtual NLMISC::IMouseDevice                    *enableLowLevelMouse(bool enable);
00351         //
00352         virtual NLMISC::IKeyboardDevice                 *enableLowLevelKeyboard(bool enable) ;
00353         virtual NLMISC::IInputDeviceManager             *getLowLevelInputDeviceManager();
00355         virtual void                    showCursor (bool b);
00357         virtual void                    setMousePos (float x, float y);
00359         virtual void                    setCapture (bool b);
00360         // @}
00361 
00362 
00364         // @{
00365 
00375         virtual TMessageBoxId   systemMessageBox (const char* message, const char* title, TMessageBoxType type=okType, TMessageBoxIcon icon=noIcon);
00376         
00377 
00384         virtual void                    setPolygonMode (TPolygonMode mode);
00385         virtual U3dMouseListener*       create3dMouseListener ();
00386         virtual void delete3dMouseListener (U3dMouseListener *listener);
00387         virtual TPolygonMode    getPolygonMode () ;
00388         virtual void                    forceDXTCCompression(bool dxtcComp);
00389         virtual void                    forceTextureResize(uint divisor);
00390         virtual bool                    setMonitorColorProperties (const CMonitorColorProperties &properties);
00391         // @}
00392 
00394         // @{
00396         virtual UShapeBank*             getShapeBank()
00397         {
00398                 NL3D_MEM_DRIVER
00399                 return &_ShapeBank;
00400         }
00401         // @}
00402 
00403 
00405         // @{
00406 
00407         virtual void                    profileRenderedPrimitives(CPrimitiveProfile &pIn, CPrimitiveProfile &pOut);
00408 
00409         virtual uint32                  profileAllocatedTextureMemory();
00410 
00411         virtual uint32                  profileSetupedMaterials() const;
00412 
00413         virtual uint32                  profileSetupedModelMatrix() const;
00414 
00415         virtual void                    enableUsedTextureMemorySum (bool enable);
00416         
00417         virtual uint32                  getUsedTextureMemory() const;
00418 
00419         // @}
00420 
00421 
00423         // @{
00424         virtual void                            setupAsyncTextureLod(uint baseLevel, uint maxLevel);
00425         virtual void                            setupAsyncTextureMaxUploadPerFrame(uint maxup);
00426         virtual void                            setupMaxTotalAsyncTextureSize(uint maxText);
00427         virtual void                            setupMaxHLSColoringPerFrame(uint maxCol);
00428         virtual void                            updateAsyncTexture();
00429         virtual uint                            getTotalAsyncTextureSizeAsked() const;
00430         virtual uint                            getLastAsyncTextureSizeGot() const;
00431         virtual void                            loadHLSBank(const std::string &fileName);
00432         // @}
00433 
00434 
00435 public:
00437         // @{
00438         IDriver         *getDriver()
00439         {
00440                 NL3D_MEM_DRIVER
00441                 return _Driver;
00442         }
00443         void            restoreMatrixContext()
00444         {
00445                 NL3D_MEM_DRIVER
00446                 setupMatrixContext();
00447         }
00448         // @}
00449 
00450 };
00451 
00452 
00453 } // NL3D
00454 
00455 
00456 #endif // NL_DRIVER_USER_H
00457 
00458 /* End of driver_user.h */