00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef NL_U_DRIVER_H
00027 #define NL_U_DRIVER_H
00028
00029 #include "nel/misc/types_nl.h"
00030 #include "nel/3d/viewport.h"
00031 #include "nel/3d/scissor.h"
00032 #include "nel/3d/frustum.h"
00033 #include "nel/misc/geom_ext.h"
00034 #include "nel/misc/matrix.h"
00035 #include "nel/misc/rgba.h"
00036 #include "nel/misc/rect.h"
00037 #include "nel/misc/bitmap.h"
00038 #include "nel/misc/event_server.h"
00039 #include "nel/misc/event_listener.h"
00040 #include "nel/3d/primitive_profile.h"
00041
00042
00043
00044 namespace NLMISC
00045 {
00046 struct IMouseDevice;
00047 struct IKeyboardDevice;
00048 struct IInputDeviceManager;
00049 }
00050
00051
00052 namespace NL3D
00053 {
00054
00055
00056 using NLMISC::CVector;
00057 using NLMISC::CMatrix;
00058 using NLMISC::CRGBA;
00059 using NLMISC::CBitmap;
00060
00061
00062 class UScene;
00063 class UCamera;
00064 class UTextureFile;
00065 class UTextureRaw;
00066 class UMaterial;
00067 class UTextContext;
00068 class UShapeBank;
00069 class U3dMouseListener;
00070 class ULight;
00071
00072
00074
00075 {
00076 float Contrast[3];
00077 float Luminosity[3];
00078 float Gamma[3];
00079 };
00080
00081
00094 class UDriver
00095 {
00096 public:
00097
00099 class CMode
00100 {
00101 public:
00102 bool Windowed;
00103 uint16 Width;
00104 uint16 Height;
00105 uint8 Depth;
00106
00107 CMode(void)
00108 {
00109 Windowed=false;
00110 Width=0;
00111 Height=0;
00112 Depth=0;
00113 }
00114 CMode(uint16 w, uint16 h, uint8 d, bool windowed= true)
00115 {
00116 Windowed=windowed;
00117 Width=w;
00118 Height=h;
00119 Depth=d;
00120 }
00121 };
00122
00123 typedef std::vector<CMode> TModeList;
00124
00125
00127 enum TMessageBoxId { okId=0, yesId, noId, abortId, retryId, cancelId, ignoreId, idCount };
00128 enum TMessageBoxType { okType=0, okCancelType, yesNoType, abortRetryIgnoreType, yesNoCancelType, retryCancelType, typeCount };
00129 enum TMessageBoxIcon { noIcon=0, handIcon, questionIcon, exclamationIcon, asteriskIcon, warningIcon, errorIcon, informationIcon, stopIcon, iconCount };
00130
00132 enum TPolygonMode { Filled=0, Line, Point };
00133
00134
00135 public:
00137 NLMISC::CEventServer EventServer;
00139 NLMISC::CEventListenerAsync AsyncListener;
00140
00141
00142 public:
00143
00145
00146 UDriver();
00147 virtual ~UDriver();
00148
00149
00150
00152
00155
00156 virtual void disableHardwareVertexProgram()=0;
00157 virtual void disableHardwareVertexArrayAGP()=0;
00158 virtual void disableHardwareTextureShader()=0;
00159
00160
00161
00163
00164
00166 virtual TModeList enumModes()=0;
00167
00169 virtual void setDisplay(const CMode &mode) =0;
00171 virtual void release() =0;
00172
00174 virtual bool activate(void)=0;
00176 virtual bool isActive()=0;
00177
00178
00179
00180
00181
00183
00185
00187
00189
00191
00192
00193
00194
00195
00196
00198
00199 virtual bool fogEnabled()=0;
00200 virtual void enableFog(bool enable)=0;
00202 virtual void setupFog(float start, float end, CRGBA color)=0;
00203
00204
00206
00207 virtual void setLight (uint8 num, const ULight& light) = 0;
00208 virtual void enableLight (uint8 num, bool enable=true) = 0;
00209 virtual void setAmbientColor (CRGBA color) = 0;
00210
00211
00212
00214
00216
00218
00219
00220
00221
00223
00224
00225
00227 virtual UTextContext *createTextContext(const std::string fontFileName, const std::string fontExFileName = "") =0;
00229 virtual void deleteTextContext(UTextContext *textContext) =0;
00231 virtual void setFontManagerMaxMemory(uint maxMem)=0;
00233 virtual std::string getFontManagerCacheInformation() const =0;
00234
00235
00240 virtual UTextureFile *createTextureFile(const std::string &file) =0;
00242 virtual void deleteTextureFile(UTextureFile *textfile) =0;
00244 virtual UTextureRaw *createTextureRaw() =0;
00246 virtual void deleteTextureRaw(UTextureRaw *textraw) =0;
00248 virtual UMaterial *createMaterial() =0;
00250 virtual void deleteMaterial(UMaterial *mat) =0;
00251
00252
00253
00255
00262
00263
00266 virtual void setScissor(const CScissor &)=0;
00267 virtual CScissor getScissor()=0;
00270 virtual void setViewport(const CViewport &)=0;
00271 virtual CViewport getViewport()=0;
00274 virtual void setFrustum(const CFrustum &frust) =0;
00275 virtual CFrustum getFrustum() =0;
00279 virtual void setViewMatrix(const CMatrix &mat) =0;
00280 virtual CMatrix getViewMatrix() =0;
00283 virtual void setModelMatrix(const CMatrix &mat) =0;
00284 virtual CMatrix getModelMatrix() =0;
00285
00286
00290 virtual void setMatrixMode2D(const CFrustum &frust) =0;
00292 void setMatrixMode2D11();
00294 void setMatrixMode2D43();
00299 virtual void setMatrixMode3D(UCamera &camera) =0;
00300
00301
00302
00303
00305
00309
00310
00312 virtual void drawLine(const NLMISC::CLine &tri, UMaterial &mat) =0;
00314 virtual void drawLine(const NLMISC::CLineColor &tri, UMaterial &mat) =0;
00316 virtual void drawLine(const NLMISC::CLineUV &tri, UMaterial &mat) =0;
00318 virtual void drawLine(const NLMISC::CLineColorUV &tri, UMaterial &mat) =0;
00319
00321 virtual void drawTriangle(const NLMISC::CTriangle &tri, UMaterial &mat) =0;
00323 virtual void drawTriangle(const NLMISC::CTriangleColor &tri, UMaterial &mat) =0;
00325 virtual void drawTriangle(const NLMISC::CTriangleUV &tri, UMaterial &mat) =0;
00327 virtual void drawTriangle(const NLMISC::CTriangleColorUV &tri, UMaterial &mat) =0;
00328
00330 virtual void drawQuad(const NLMISC::CQuad &tri, UMaterial &mat) =0;
00332 virtual void drawQuad(const NLMISC::CQuadColor &tri, UMaterial &mat) =0;
00334 virtual void drawQuad(const NLMISC::CQuadUV &tri, UMaterial &mat) =0;
00336 virtual void drawQuad(const NLMISC::CQuadColorUV &tri, UMaterial &mat) =0;
00337
00338 virtual void drawQuads(const std::vector<NLMISC::CQuadColorUV> &tri, UMaterial &mat) =0;
00339 virtual void drawQuads(const NLMISC::CQuadColorUV *qs, uint32 nbq, UMaterial &mat) =0;
00340
00341
00342
00343
00345
00347
00348
00350 virtual void drawBitmap (float x, float y, float width, float height, class UTexture& texture, bool blend=true, CRGBA col= CRGBA(255,255,255,255)) =0;
00352 virtual void drawLine (float x0, float y0, float x1, float y1, CRGBA col= CRGBA(255,255,255,255)) =0;
00354 virtual void drawTriangle (float x0, float y0, float x1, float y1, float x2, float y2, CRGBA col) =0;
00356 virtual void drawQuad (float x0, float y0, float x1, float y1, CRGBA col) =0;
00358 virtual void drawQuad (float xcenter, float ycenter, float radius, CRGBA col) =0;
00360 virtual void drawWiredQuad (float x0, float y0, float x1, float y1, CRGBA col) =0;
00362 virtual void drawWiredQuad (float xcenter, float ycenter, float radius, CRGBA col) =0;
00363
00364
00365
00366
00367
00369
00375 virtual uint32 getImplementationVersion () const = 0;
00376
00381 virtual const char* getDriverInformation () = 0;
00382
00387 virtual const char* getVideocardInformation () = 0;
00388
00390 virtual sint getNbTextureStages()=0;
00391
00393 virtual void getWindowSize (uint32 &width, uint32 &height) = 0;
00395 virtual uint getWindowWidth () =0;
00397 virtual uint getWindowHeight () =0;
00398
00403 virtual void getBuffer (CBitmap &bitmap) = 0;
00404
00409 virtual void getZBuffer (std::vector<float> &zbuffer) = 0;
00410
00417 virtual void getBufferPart (CBitmap &bitmap, NLMISC::CRect &rect) = 0;
00418
00425 virtual void getZBufferPart (std::vector<float> &zbuffer, NLMISC::CRect &rect) = 0;
00426
00432 virtual bool fillBuffer (CBitmap &bitmap) = 0;
00433
00434
00435
00436
00438
00447 virtual NLMISC::IMouseDevice *enableLowLevelMouse(bool enable) = 0;
00448
00454 virtual NLMISC::IKeyboardDevice *enableLowLevelKeyboard(bool enable) = 0;
00455
00459 virtual NLMISC::IInputDeviceManager *getLowLevelInputDeviceManager() = 0;
00460
00464 virtual void showCursor (bool b) = 0;
00465
00467 virtual void setMousePos (float x, float y) = 0;
00468
00472 virtual void setCapture (bool b) = 0;
00473
00474
00476
00477
00487 virtual TMessageBoxId systemMessageBox (const char* message, const char* title, TMessageBoxType type=okType, TMessageBoxIcon icon=noIcon) =0;
00488
00489
00496 virtual void setPolygonMode (TPolygonMode mode) =0;
00497
00503 virtual TPolygonMode getPolygonMode () =0;
00504
00509 virtual U3dMouseListener* create3dMouseListener () =0;
00510
00515 virtual void delete3dMouseListener (U3dMouseListener *listener) =0;
00516
00521 virtual void forceDXTCCompression(bool dxtcComp)=0;
00522
00528 virtual void forceTextureResize(uint divisor)=0;
00529
00534 virtual bool setMonitorColorProperties (const CMonitorColorProperties &properties) = 0;
00535
00536
00537
00539
00544 virtual UShapeBank* getShapeBank() = 0;
00545
00546
00547
00549
00550
00556 virtual void profileRenderedPrimitives(CPrimitiveProfile &pIn, CPrimitiveProfile &pOut) =0;
00557
00561 virtual uint32 profileAllocatedTextureMemory() =0;
00562
00565 virtual uint32 profileSetupedMaterials() const =0;
00566
00569 virtual uint32 profileSetupedModelMatrix() const =0;
00570
00573 virtual void enableUsedTextureMemorySum (bool enable=true) =0;
00574
00578 virtual uint32 getUsedTextureMemory() const =0;
00579
00580
00581
00582
00584
00592 virtual void setupAsyncTextureLod(uint baseLevel, uint maxLevel) =0;
00594 virtual void setupAsyncTextureMaxUploadPerFrame(uint maxup) =0;
00596 virtual void setupMaxTotalAsyncTextureSize(uint maxText) =0;
00598 virtual void setupMaxHLSColoringPerFrame(uint maxCol) =0;
00602 virtual void updateAsyncTexture() =0;
00603
00605 virtual uint getTotalAsyncTextureSizeAsked() const =0;
00607 virtual uint getLastAsyncTextureSizeGot() const =0;
00608
00612 virtual void loadHLSBank(const std::string &fileName) =0;
00613
00614
00615
00616
00617 public:
00618
00622 static UDriver *createDriver();
00623
00624 };
00625
00626
00627 }
00628
00629
00630 #endif // NL_U_DRIVER_H
00631
00632