00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef _SO_EXTTEXTURE_2_
00025 #define _SO_EXTTEXTURE_2_
00026
00027 #include <Inventor/nodes/SoTexture.h>
00028 #include <Inventor/fields/SoSFInt32.h>
00029 #include <Inventor/fields/SoSFFilePathString.h>
00030 #include <Inventor/fields/SoSFTime.h>
00031 #include <Inventor/threads/SbThreadStorage.h>
00032 #include <Inventor/caches/SoGLTexCacheList.h>
00033
00034 #include <Inventor/image/SbRasterImage.h>
00035 #include <Inventor/sys/SoGLType.h>
00036
00037 class SoSensor;
00038 class SoDither;
00039
00040 #ifdef _MSC_VER
00041 #pragma warning( push )
00042 #pragma warning(disable:4251)
00043 #endif
00044
00046
00047
00048
00049
00050
00052
00053 class SoExtTexture2;
00057 typedef SbBool ExtPrequalifyFileCallback(const SbString &, void *, SoExtTexture2 *);
00058
00179 class SoExtTexture2 : public SoTexture {
00180
00181 SO_NODE_HEADER(SoExtTexture2);
00182
00183 public:
00187 typedef void SoExtTexture2CB(void *userData, SoExtTexture2 *tex);
00188
00190 enum Sync
00191 {
00195 SYNCHRONOUS = 0,
00196
00200 ASYNCHRONOUS
00201 };
00202
00204 enum Loading {
00208 AUTO = 0,
00209
00213 MANUAL
00214 };
00215
00228 SoSFFilePathString filename;
00229
00235 SoSFEnum wrapT;
00236
00241 SoSFBool loadingStatus;
00242
00247 SoSFEnum syncMode;
00248
00253 SoSFEnum loadingMode;
00254
00259 SoSFInt32 loadingThreadPriority;
00260
00264 SoExtTexture2();
00265
00279 static void setPrequalifyFileCallBack(ExtPrequalifyFileCallback *p_cb, void *u_data);
00280
00284 void allowPrequalifyFile(SbBool);
00285
00290 void getImageSize(SbVec2s &size, int &nc);
00291
00296 static void setMemorySpace(double megaBytes);
00297
00302 static double getMemorySpace();
00303
00307 static double getGlobalMemoryUsed();
00308
00317 static void useTexturePalette(SbBool value);
00318
00319
00320
00325 void addOnLoadStartCB(SoExtTexture2CB* cb, void* userData);
00326
00331 void addOnLoadFinishCB(SoExtTexture2CB* cb, void* userData);
00332
00338 void addOnUnloadCB(SoExtTexture2CB* cb, void* userData);
00339
00340
00341
00345 void loadTexture();
00346
00347 private:
00348 virtual void doAction(SoAction *action);
00349 virtual void GLRender(SoGLRenderAction *action);
00350 virtual void write(SoWriteAction* action);
00351
00352 private:
00353
00354 enum textureFormat {
00355 RGB_FORMAT,
00356 PALETTED,
00357 COLORTABLE
00358 };
00359
00360 static void initClass();
00361 static void exitClass();
00362
00363 const SbString &getOverrideURL() { return overrideURL; }
00364 void setOverrideURL(const SbString &path) { overrideURL = path; }
00365
00366
00367 static void *manageLoading(void *userData, SbBool isCallTouch=TRUE);
00368
00369
00370
00371
00372
00373 static void *manageLoadingThread(void *userData);
00374
00375
00376 SoSFTime sysTime;
00377
00378
00379 int getNextTexNameIndex();
00380
00381
00382 virtual void fieldHasChanged( SoField *field );
00383
00384
00385 static int glLUTExt;
00386
00387 private:
00388
00389
00390 virtual SbBool readInstance(SoInput *in, unsigned short flags);
00391
00392 virtual ~SoExtTexture2();
00393
00394 virtual void copyContents(const SoFieldContainer *fromFC,
00395 SbBool copyConnections);
00396
00397 private:
00398
00399 static void checkOGLExtensions() ;
00400
00401
00402 SbThreadStorage< SoGLTexCacheList* > m_texList;
00403 SbThreadRWMutex* m_mutex;
00404
00405
00406
00407 unsigned char *m_palette;
00408
00409
00410 SbThread *m_loadingThread;
00411
00412 SbString overrideURL;
00413
00414 static ExtPrequalifyFileCallback *prequalifyFileCB;
00415 static void *prequalifyFileCB_udata;
00416 SbBool prequalifyFileFlag;
00417
00418 static void readTextureFile(SoExtTexture2 *tex);
00419
00420 SoDither *m_dither;
00421
00422
00423 void filename_HasChanged(void);
00424 void wrap_HasChanged(void);
00425 void maxAnisotropy_HasChanged(void);
00426
00427
00428 SoExtTexture2CB *m_loadStartCB;
00429 SoExtTexture2CB *m_loadFinishCB;
00430 SoExtTexture2CB *m_unloadCB;
00431
00432 void *m_loadStartCBData;
00433 void *m_loadFinishCBData;
00434 void *m_unloadCBData;
00435
00436 static GLint maxTexSize;
00437
00438
00439 static long m_globalMemoryUsed;
00440
00441
00442 long m_memoryUsed;
00443
00444
00445 static SbPList m_nodeList;
00446
00447
00448 static long memorySpace;
00449
00450 static int m_numNodes;
00451 static int m_numTexObjs;
00452 static int m_numNodeMax;
00453
00454
00455 static SbBool m_useTextureLUT;
00456
00457 static void manageNodeListAlloc(SoExtTexture2 *node);
00458
00459 SbRasterImage* m_rasterImage;
00460
00461
00462 SbStringList currentDirStack;
00463
00464 int m_numRenderCaches;
00465 };
00466
00467 #ifdef _MSC_VER
00468 #pragma warning( pop )
00469 #endif
00470
00471 #endif
00472
00473