1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2000-2002 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zghdv.de *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
37 \*---------------------------------------------------------------------------*/
39 #ifndef _OSGTEXTUREOBJCHUNK_H_
40 #define _OSGTEXTUREOBJCHUNK_H_
45 #include "OSGTextureObjChunkBase.h"
49 /*! \brief State chunk for textures. See \ref PageSystemTextureObjChunk
51 \ingroup GrpSystemStateBaseChunks
52 \ingroup GrpLibOSGSystem
56 class OSG_SYSTEM_DLLMAPPING TextureObjChunk
: public TextureObjChunkBase
58 /*========================== PUBLIC =================================*/
62 static StatElemDesc
<StatIntOnceElem
> statNTextures
;
63 static StatElemDesc
<StatIntOnceElem
> statNTexBytes
;
65 // Flags can be OR-ed, e.g. NPotTexScale for old gpu and YFlip for videos.
76 /*---------------------------------------------------------------------*/
77 /*! \name Chunk Class Access */
81 /*---------------------------------------------------------------------*/
82 /*! \name Static Chunk Class Access */
86 /*---------------------------------------------------------------------*/
90 virtual bool isCubeTexture(void);
93 /*---------------------------------------------------------------------*/
97 virtual void changed(ConstFieldMaskArg whichField
,
102 /*---------------------------------------------------------------------*/
106 virtual void dump( UInt32 uiIndent
= 0,
107 const BitVector bvFlags
= 0) const;
110 /*---------------------------------------------------------------------*/
114 virtual void activate (DrawEnv
*pEnv
,
117 virtual void changeFrom (DrawEnv
*pEnv
,
121 virtual void deactivate (DrawEnv
*pEnv
,
124 virtual bool isTransparent (void) const;
127 /*---------------------------------------------------------------------*/
131 GLenum
determineTextureTarget (Window
*pWindow
) const;
132 void determineFormats (GLenum
&internalFormat
,
133 GLenum
&externalFormat
) const;
136 /*---------------------------------------------------------------------*/
137 /*! \name Comparison */
140 virtual Real32
switchCost(StateChunk
* chunk
);
142 virtual bool operator < (const StateChunk
&other
) const;
144 virtual bool operator == (const StateChunk
&other
) const;
145 virtual bool operator != (const StateChunk
&other
) const;
148 /*---------------------------------------------------------------------*/
149 /*! \name Texture specific */
152 void imageContentChanged (Int32 minx
= -1, Int32 maxx
= -1,
153 Int32 miny
= -1, Int32 maxy
= -1,
154 Int32 minz
= -1, Int32 maxz
= -1);
157 /*---------------------------------------------------------------------*/
158 /*! \name Multitexture handling */
161 virtual void validate (DrawEnv
*pEnv
);
162 virtual Int32
getOpenGLId (DrawEnv
*pEnv
);
163 virtual GLenum
determineInternalFormat(void );
166 /*========================= PROTECTED ===============================*/
170 /*---------------------------------------------------------------------*/
174 void onCreate (const TextureObjChunk
*source
= NULL
);
175 void onCreateAspect(const TextureObjChunk
*createAspect
,
176 const TextureObjChunk
*source
= NULL
);
177 void onDestroy ( UInt32 uiContainerId
);
180 /*---------------------------------------------------------------------*/
181 /*! \name Constructors */
184 TextureObjChunk(void);
185 TextureObjChunk(const TextureObjChunk
&source
);
188 /*---------------------------------------------------------------------*/
189 /*! \name Destructors */
192 virtual ~TextureObjChunk(void);
195 /*---------------------------------------------------------------------*/
199 static void initMethod(InitPhase ePhase
);
202 /*---------------------------------------------------------------------*/
206 void handleTexture(Window
*win
,
211 Window::GLObjectStatusE mode
,
216 /*---------------------------------------------------------------------*/
218 // extension indices for used extensions;
219 static UInt32 _extTex3D
;
220 static UInt32 _extTextureArray
;
221 static UInt32 _sgisGenerateMipmap
;
222 static UInt32 _arbTextureCompression
;
223 static UInt32 _arbTextureRectangle
;
224 static UInt32 _arbTextureNonPowerOfTwo
;
225 static UInt32 _extTextureFilterAnisotropic
;
226 static UInt32 _extShadow
;
227 static UInt32 _extDepthTexture
;
229 // extension indices for used fucntions;
230 static UInt32 _funcTexImage3D
;
231 static UInt32 _funcTexImage3DExt
;
232 static UInt32 _funcTexSubImage3D
;
233 static UInt32 _funcTexSubImage3DExt
;
234 static UInt32 _arbCubeTex
;
235 static UInt32 _funcCompressedTexImage1D
;
236 static UInt32 _funcCompressedTexSubImage1D
;
237 static UInt32 _funcCompressedTexImage2D
;
238 static UInt32 _funcCompressedTexSubImage2D
;
239 static UInt32 _funcCompressedTexImage3D
;
240 static UInt32 _funcCompressedTexSubImage3D
;
242 // class. Used for indexing in State
243 // protected to give CubeTextureChunk access
245 /*========================== PRIVATE ================================*/
249 typedef TextureObjChunkBase Inherited
;
251 friend class FieldContainer
;
252 friend class TextureObjChunkBase
;
254 /*---------------------------------------------------------------------*/
258 UInt32
handleGL (DrawEnv
*pEnv
,
260 Window::GLObjectStatusE mode
,
263 static void handleDestroyGL(DrawEnv
*pEnv
,
265 Window::GLObjectStatusE mode
);
268 /*---------------------------------------------------------------------*/
270 // prohibit default functions (move to 'public' if you need one)
271 void operator =(const TextureObjChunk
&source
);
274 typedef TextureObjChunk
*TextureObjChunkP
;
278 #include "OSGTextureObjChunkBase.inl"
279 #include "OSGTextureObjChunk.inl"
281 #endif /* _OSGTEXTUREOBJCHUNK_H_ */