00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052 #ifndef _SO_TEXTURE_2_
00053 #define _SO_TEXTURE_2_
00054
00055 #include <Inventor/fields/SoSFColor.h>
00056 #include <Inventor/fields/SoSFEnum.h>
00057 #include <Inventor/fields/SoSFImage.h>
00058 #include <Inventor/fields/SoSFFilePathString.h>
00059 #include <Inventor/fields/SoSFNode.h>
00060 #include <Inventor/fields/SoSFBool.h>
00061 #include <Inventor/nodes/SoNode.h>
00062 #include <Inventor/nodes/SoTexture.h>
00063 #include <Inventor/image/SbRasterImage.h>
00064
00065 #include <Inventor/sys/SoGLType.h>
00066 #include <Inventor/threads/SbThreadStorage.h>
00067 #include <Inventor/threads/SbThreadMutex.h>
00068 #include <Inventor/elements/SoTextureImageElement.h>
00069
00070 class SoSensor;
00071
00072 #ifdef _MSC_VER
00073 #pragma warning( push )
00074 #pragma warning(disable:4251)
00075 #endif
00076
00078
00079
00080
00081
00082
00084
00085 class SoTexture2;
00086 typedef SbBool PrequalifyFileCallback(const SbString &, void *, SoTexture2 *);
00087
00263 class SoTexture2 : public SoTexture {
00264
00265 SO_NODE_HEADER(SoTexture2);
00266
00267 public:
00268
00272 typedef void SoTexture2CB(void *userData, SoTexture2 *tex);
00273
00275 enum Loading {
00279 AUTO = 0,
00280
00284 MANUAL
00285 };
00286
00299 SoSFFilePathString filename;
00300
00308 SoSFImage image;
00309
00315 SoSFEnum wrapT;
00316
00323 SoSFEnum loadingMode;
00324
00325
00337 SoSFNode renderToTextureProperty;
00338
00343 void setStartLoadingCallback(SoTexture2CB* cb, void* userData);
00344
00349 void setFinishLoadingCallback(SoTexture2CB* cb, void* userData);
00350
00351
00352
00381 void loadTexture();
00382
00386 SoTexture2();
00387
00388 private:
00389 virtual void doAction(SoAction *action);
00390 virtual void GLRender(SoGLRenderAction *action);
00391 virtual void callback(SoCallbackAction *action);
00392 virtual void doActionOnRTT(SoAction *action);
00393
00394 static void setPrequalifyFileCallBack(PrequalifyFileCallback *p_cb, void *u_data);
00395 static PrequalifyFileCallback *getPrequalifyFileCallBack( void *&user_data );
00396 void allowPrequalifyFile(SbBool);
00397 SbBool isAllowPrequalifyFile() const;
00398
00399
00400 private:
00401 static void initClass();
00402 static void exitClass();
00403 const SbString &getOverrideURL() { return overrideURL; }
00404 void setOverrideURL(const SbString &path) { overrideURL = path; }
00405
00406
00407 virtual void notify(SoNotList *list);
00408
00409
00410 virtual void fieldHasChanged( SoField *field );
00411
00412
00413 SbBool readImage(void);
00414
00415 void setIsTextureLoaded(SbBool isTextureLoaded) { m_isTextureLoaded = isTextureLoaded; }
00416
00417 private:
00418
00419 virtual SbBool readInstance(SoInput *in, unsigned short flags);
00420
00421 virtual ~SoTexture2();
00422
00423 virtual void copyContents(const SoFieldContainer *fromFC, SbBool copyConnections);
00424
00428 void checkTexturesFormat( SoState* state );
00429
00432 virtual GLenum getGLInternalFormat(SoSFImage& image, float quality = 1.0);
00433
00440 virtual bool isTextureConfigurationValid(SoState* state, const SoTextureImageElement::SoTexImageData& config);
00441
00442 private:
00444 void handleSubTexture(SoState* state);
00445
00447 SoTextureImageElement::SoTexImageData getTextureConfiguration(SoState* state);
00448
00449 SbString overrideURL;
00450
00451 static PrequalifyFileCallback *prequalifyFileCB;
00452 static void *prequalifyFileCB_udata;
00453 SbBool prequalifyFileFlag;
00454
00455
00456 void image_HasChanged(void);
00457 void filename_HasChanged(void);
00458 void wrapS_HasChanged(void);
00459 void wrapT_HasChanged(void);
00460 void renderToTextureProperty_HasChanged(void);
00461 void maxAnisotropy_HasChanged(void);
00462 void useAutoMipmap_HasChanged(void);
00463 void internalFormat_HasChanged(void);
00464
00465 SbThreadMutex m_mutex;
00466
00467
00468
00469 void setTrueInternalFormat();
00470 InternalFormat m_trueInternalFormat;
00471
00472 SbRasterImage* m_compressedImage;
00473
00474
00475 SoTexture2CB *m_loadStartCB;
00476 SoTexture2CB *m_loadFinishCB;
00477
00478 void *m_loadStartCBData;
00479 void *m_loadFinishCBData;
00480
00481
00482 SbBool m_isTextureLoaded;
00483 SbBool m_isTextureRGBE;
00484
00485 int m_numRenderCaches;
00486 };
00487
00488 #ifdef _MSC_VER
00489 #pragma warning( pop )
00490 #endif
00491
00492 #endif
00493
00494
00495