00001 /*======================================================================= 00002 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), *** 00003 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. *** 00004 *** *** 00005 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS *** 00006 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR *** 00007 *** WRITTEN AUTHORIZATION OF FEI S.A.S. *** 00008 *** *** 00009 *** RESTRICTED RIGHTS LEGEND *** 00010 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS *** 00011 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN *** 00012 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT *** 00013 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN *** 00014 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. *** 00015 *** *** 00016 *** COPYRIGHT (C) 1996-2020 BY FEI S.A.S, *** 00017 *** BORDEAUX, FRANCE *** 00018 *** ALL RIGHTS RESERVED *** 00019 **=======================================================================*/ 00020 /*======================================================================= 00021 ** Author : R. ALBOU (Jan 2005) 00022 **=======================================================================*/ 00023 00024 #ifndef _SO_INDEXED_TEXTURE2_ 00025 #define _SO_INDEXED_TEXTURE2_ 00026 00027 #include <Inventor/fields/SoSFFloat.h> 00028 #include <Inventor/fields/SoSFEnum.h> 00029 #include <Inventor/fields/SoSFArray2D.h> 00030 00031 #include <Inventor/nodes/SoNode.h> 00032 #include <Inventor/nodes/SoTexture2.h> 00033 #include <Inventor/threads/SbThreadStorage.h> 00034 #include <Inventor/caches/SoGLTexCacheList.h> 00035 #include <Inventor/caches/SoCache.h> 00036 00037 #include <Inventor/sensors/SoFieldSensor.h> 00038 00039 class SoGLRenderAction ; 00040 class SoCallbackAction ; 00041 class SoColorMap; 00042 00043 #ifdef _MSC_VER 00044 #pragma warning( push ) 00045 #pragma warning(disable:4251) 00046 #endif 00047 00048 /*----------------------------------------------------------------------------*/ 00049 00317 class SoIndexedTexture2 : public SoTexture { 00318 SO_NODE_HEADER(SoIndexedTexture2) ; 00319 00320 public: 00336 SoSFFloat minValue ; 00337 00341 SoSFFloat maxValue ; 00342 00348 SoSFArray2D imageIndex ; 00349 00437 SoSFBool rescaleTexCoord; 00438 00444 SoSFEnum wrapT ; 00445 00450 void computeDataRange(); 00451 00455 SoIndexedTexture2() ; 00456 00457 private: 00458 virtual void doAction( SoAction* action ); 00459 virtual void GLRender( SoGLRenderAction* action ); 00460 00465 virtual SoNode* getAlternateRep( SoAction* action ); 00466 00467 /*----------------------------------------------------------------------------*/ 00468 00469 private: 00470 static void initClass() ; 00471 static void exitClass() ; 00472 00473 SbVec2s getTexSize() const { return m_size; } 00474 00480 virtual SoNode* createAlternateRep( SoAction *action ); 00481 00482 // Manage field dependencies when one of them change AJO eBug #1972 00483 virtual void fieldHasChanged( SoField *field ); // override of SoFieldContainer 00484 00485 00486 private: 00487 // Destructor 00488 virtual ~SoIndexedTexture2() ; 00489 00490 00491 private: 00492 // Display list info for this texture: 00493 SbThreadStorage< SoGLTexCacheList* > m_texList; 00494 SbThreadRWMutex* m_mutex; 00495 00496 GLenum getGLInternalFormat(SoSFArray2D::DataType dataType, SoColorMap *cm) const; 00497 00498 //Map data on the color map 00499 void mapData(SoColorMap *cm); 00500 00501 //Reconstruct m_indexedImageData if imageIndex, max or min change 00502 SbThreadStorage< bool > m_needUpdate; 00503 00504 //Allow to choose the correct delete[] on m_indexedImageData 00505 SoSFArray2D::DataType m_previousType; 00506 void deleteIndexedData(SoSFArray2D::DataType datatype); 00507 00508 SoSFImage::DataType getDataType(SoSFArray2D::DataType dataType, SoColorMap *cm); 00509 00510 //Final indexed data which are sent to OpenGL 00511 void *m_indexedImageData; 00512 00513 // Tesxture size 00514 SbVec2s m_size; 00515 00516 //Check colormap modifications 00517 SbThreadStorage< SoCache* > m_cache; 00518 00519 //Contains the rescaled image 00520 SoSFArray2D m_rescaledImageIndex ; 00521 void scaleTexCoord(); 00522 SbBool m_hasNPOT; 00523 SbBool m_forceScaleImage; //True if texture size > GL_MAX_TEXTURE_SIZE 00524 00525 //Scale the texture but not the image data 00526 void scaleTexture(unsigned char *dest, const unsigned char *src, SbVec2s newSize, SbVec2s size, 00527 SoSFArray2D::DataType dataType); 00528 } ; 00529 /*----------------------------------------------------------------------------*/ 00530 00531 #ifdef _MSC_VER 00532 #pragma warning( pop ) 00533 #endif 00534 00535 #endif /* _SO_INDEXED_TEXTURE2_ */ 00536 00537 00538