00001 #ifndef _OSGTEXTUREMANAGER_H_
00002 #define _OSGTEXTUREMANAGER_H_
00003
00004 #ifdef __sgi
00005 #pragma once
00006 #endif
00007
00008 #include <OSGConfig.h>
00009
00010 #include <OSGSystemDef.h>
00011
00012 #include <OSGChunkMaterial.h>
00013 #include <OSGImage.h>
00014
00015 #include <vector>
00016
00017
00018 OSG_BEGIN_NAMESPACE
00019
00020
00021
00022
00023 class DVRVolume;
00024 class BrickSet;
00025 class Brick;
00026 class DrawActionBase;
00027
00033 struct TextureRecord
00034 {
00035 ImagePtr _image;
00036 UInt32 _internalFormat;
00037 UInt32 _externalFormat;
00038 Int32 _textureStage0;
00039 Int32 _textureStage1;
00040
00041 TextureRecord(ImagePtr img,
00042 UInt32 internal,
00043 UInt32 externalFormat,
00044 Int32 stage0,
00045 Int32 stage1);
00046 ~TextureRecord(void);
00047
00048 private:
00049
00052
00053 TextureRecord(const TextureRecord &source);
00054 void operator =(const TextureRecord &source);
00055 };
00056
00057
00058 typedef std::vector<TextureRecord *> TextureSet;
00059
00060
00061 class OSG_SYSTEMLIB_DLLMAPPING TextureManager
00062 {
00063 public:
00064
00066 enum TextureMode
00067 {
00068 TM_3D = 0,
00069 TM_2D,
00070 TM_2D_Multi,
00071 NUM_TEXTURE_MODES
00072 };
00073
00075 enum BrickingMode
00076 {
00077 BRICK_SUBDIVIDE_ON_TEXTURE_MEMORY = 0,
00078 BRICK_SUBDIVIDE_STATIC,
00079 BRICK_SUBDIVIDE_ON_BRICK_SIZE,
00080 NUM_BRICKING_MODES
00081 };
00082
00084 TextureManager(DVRVolume *volume);
00085 ~TextureManager(void);
00086
00088
00104 Int32 registerTexture(ImagePtr image,
00105 UInt32 internalFormat,
00106 UInt32 externalFormat,
00107 bool doBricking = 1,
00108 Int32 textureStage0 = 0,
00109 Int32 textureStage1 = -1);
00110
00112 void unregisterTexture(Int32 id);
00113
00115 void reloadTexture(Int32 id, DrawActionBase * action);
00116
00118 void clearTextures(ChunkMaterialPtr material = NullFC);
00119
00121 void buildTextures(ChunkMaterialPtr material,
00122 DVRVolume *volume,
00123 TextureMode mode = TM_3D);
00124
00126 Brick *sortBricks(DrawActionBase *da,
00127 Matrix modelMat,
00128 Vec3f eyePoint,
00129 DVRVolume *volume,
00130 TextureMode mode);
00131
00133 void dump( UInt32 uiIndent = 0,
00134 const BitVector bvFlags = 0) const;
00135
00136 private:
00137
00138 TextureSet _registeredTextures;
00139 DVRVolume *_parent;
00140
00141 BrickSet *_brickSets;
00142
00144 static Vec3f calcBrickSubdivision(Int32 resX,
00145 Int32 resY,
00146 Int32 resZ,
00147 Int32 dataSize,
00148 DVRVolume *volume);
00149
00150 friend struct BrickSet;
00151 };
00152
00153 OSG_END_NAMESPACE
00154
00155 #endif