OSGTextureObjChunk.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002  *                                OpenSG                                     *
00003  *                                                                           *
00004  *                                                                           *
00005  *             Copyright (C) 2000-2002 by the OpenSG Forum                   *
00006  *                                                                           *
00007  *                            www.opensg.org                                 *
00008  *                                                                           *
00009  *   contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zghdv.de          *
00010  *                                                                           *
00011 \*---------------------------------------------------------------------------*/
00012 /*---------------------------------------------------------------------------*\
00013  *                                License                                    *
00014  *                                                                           *
00015  * This library is free software; you can redistribute it and/or modify it   *
00016  * under the terms of the GNU Library General Public License as published    *
00017  * by the Free Software Foundation, version 2.                               *
00018  *                                                                           *
00019  * This library is distributed in the hope that it will be useful, but       *
00020  * WITHOUT ANY WARRANTY; without even the implied warranty of                *
00021  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU         *
00022  * Library General Public License for more details.                          *
00023  *                                                                           *
00024  * You should have received a copy of the GNU Library General Public         *
00025  * License along with this library; if not, write to the Free Software       *
00026  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                 *
00027  *                                                                           *
00028 \*---------------------------------------------------------------------------*/
00029 /*---------------------------------------------------------------------------*\
00030  *                                Changes                                    *
00031  *                                                                           *
00032  *                                                                           *
00033  *                                                                           *
00034  *                                                                           *
00035  *                                                                           *
00036  *                                                                           *
00037 \*---------------------------------------------------------------------------*/
00038 
00039 #ifndef _OSGTEXTUREOBJCHUNK_H_
00040 #define _OSGTEXTUREOBJCHUNK_H_
00041 #ifdef __sgi
00042 #pragma once
00043 #endif
00044 
00045 #include "OSGConfig.h"
00046 #include "OSGImage.h"
00047 #include "OSGTextureObjChunkBase.h"
00048 #include "OSGStatElemDesc.h"
00049 #include "OSGStatElemTypes.h"
00050 #include "OSGWindow.h"
00051 
00052 OSG_BEGIN_NAMESPACE
00053 
00058 class OSG_SYSTEM_DLLMAPPING TextureObjChunk : public TextureObjChunkBase
00059 {
00060     /*==========================  PUBLIC  =================================*/
00061 
00062   public:
00063 
00064      static StatElemDesc<StatIntOnceElem> statNTextures;
00065      static StatElemDesc<StatIntOnceElem> statNTexBytes;
00066 
00067     // Flags can be OR-ed, e.g. NPotTexScale for old gpu and YFlip for videos.
00068 
00069     enum NPOTMatrixScaleE 
00070     { 
00071         None_TT         = 0, 
00072         NPotTexScale_TT = 1, 
00073         XFlip_TT        = 2, 
00074         YFlip_TT        = 4, 
00075         ZFlip_TT        = 8 
00076     };
00077 
00078     /*---------------------------------------------------------------------*/
00083     /*---------------------------------------------------------------------*/
00088     /*---------------------------------------------------------------------*/
00092     virtual bool isCubeTexture(void);
00093 
00095     /*---------------------------------------------------------------------*/
00099     virtual void changed(ConstFieldMaskArg whichField,
00100                          UInt32            origin,
00101                          BitVector         details);
00102 
00104     /*---------------------------------------------------------------------*/
00108     virtual void dump(      UInt32    uiIndent = 0,
00109                       const BitVector bvFlags  = 0) const;
00110 
00112     /*---------------------------------------------------------------------*/
00116     virtual void activate   (DrawEnv    *pEnv,
00117                              UInt32      index = 0);
00118 
00119     virtual void changeFrom (DrawEnv    *pEnv,
00120                              StateChunk *pOld,
00121                              UInt32      index = 0);
00122 
00123     virtual void deactivate (DrawEnv    *pEnv,
00124                              UInt32      index = 0);
00125 
00126     virtual bool isTransparent (void) const;
00127 
00129     /*---------------------------------------------------------------------*/
00133     GLenum determineTextureTarget(Window *pWindow) const;
00134 
00136     /*---------------------------------------------------------------------*/
00140     virtual Real32 switchCost(StateChunk * chunk);
00141 
00142     virtual bool   operator <  (const StateChunk &other) const;
00143 
00144     virtual bool   operator == (const StateChunk &other) const;
00145     virtual bool   operator != (const StateChunk &other) const;
00146 
00148     /*---------------------------------------------------------------------*/
00152     void imageContentChanged  (Int32 minx = -1, Int32 maxx = -1,
00153                                Int32 miny = -1, Int32 maxy = -1,
00154                                Int32 minz = -1, Int32 maxz = -1);
00155 
00157     /*---------------------------------------------------------------------*/
00162     /*=========================  PROTECTED  ===============================*/
00163 
00164   protected:
00165 
00166     /*---------------------------------------------------------------------*/
00170     void onCreate      (const TextureObjChunk *source      = NULL);
00171     void onCreateAspect(const TextureObjChunk *createAspect,
00172                         const TextureObjChunk *source      = NULL);
00173 
00175     /*---------------------------------------------------------------------*/
00179     TextureObjChunk(void);
00180     TextureObjChunk(const TextureObjChunk &source);
00181 
00183     /*---------------------------------------------------------------------*/
00187     virtual ~TextureObjChunk(void);
00188 
00190     /*---------------------------------------------------------------------*/
00194     static void initMethod(InitPhase ePhase);
00195 
00197     /*---------------------------------------------------------------------*/
00201     void handleTexture(Window                  *win,
00202                        UInt32                   id,
00203                        GLenum                   bindtarget,
00204                        GLenum                   paramtarget,
00205                        GLenum                   imgtarget,
00206                        Window::GLObjectStatusE  mode,
00207                        ImagePtr                 img,
00208                        Int32                    side = 0);
00209 
00211     /*---------------------------------------------------------------------*/
00212 
00213     // extension indices for used extensions;
00214     static UInt32 _extTex3D;
00215     static UInt32 _sgisGenerateMipmap;
00216     static UInt32 _arbTextureCompression;
00217     static UInt32 _arbTextureRectangle;
00218     static UInt32 _arbTextureNonPowerOfTwo;
00219     static UInt32 _extTextureFilterAnisotropic;
00220     static UInt32 _extShadow;
00221     static UInt32 _extDepthTexture;
00222 
00223     // extension indices for used fucntions;
00224     static UInt32 _funcTexImage3D;
00225     static UInt32 _funcTexSubImage3D;
00226     static UInt32 _arbCubeTex;
00227     static UInt32 _funcCompressedTexImage1D;
00228     static UInt32 _funcCompressedTexSubImage1D;
00229     static UInt32 _funcCompressedTexImage2D;
00230     static UInt32 _funcCompressedTexSubImage2D;
00231     static UInt32 _funcCompressedTexImage3D;
00232     static UInt32 _funcCompressedTexSubImage3D;
00233 
00234     // class. Used for indexing in State
00235     // protected to give CubeTextureChunk access
00236 
00237     /*==========================  PRIVATE  ================================*/
00238 
00239   private:
00240 
00241     typedef TextureObjChunkBase Inherited;
00242 
00243     friend class FieldContainer;
00244     friend class TextureObjChunkBase;
00245 
00246     /*---------------------------------------------------------------------*/
00250     void handleGL(DrawEnv *pEnv, UInt32 id, Window::GLObjectStatusE mode);
00251     static void handleDestroyGL(DrawEnv *pEnv, UInt32 id, Window::GLObjectStatusE mode);
00252 
00254     /*---------------------------------------------------------------------*/
00255 
00256     // prohibit default functions (move to 'public' if you need one)
00257     void operator =(const TextureObjChunk &source);
00258 };
00259 
00260 typedef TextureObjChunk *TextureObjChunkP;
00261 
00262 OSG_END_NAMESPACE
00263 
00264 #include "OSGTextureObjChunkBase.inl"
00265 #include "OSGTextureObjChunk.inl"
00266 
00267 #endif /* _OSGTEXTUREOBJCHUNK_H_ */