fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / State / Base / OSGTextureObjChunk.h
blobac0580669929b820eb4b866b5e5569d34150b32d
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2000-2002 by the OpenSG Forum *
6 * *
7 * www.opensg.org *
8 * *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zghdv.de *
10 * *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
13 * License *
14 * *
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. *
18 * *
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. *
23 * *
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. *
27 * *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
30 * Changes *
31 * *
32 * *
33 * *
34 * *
35 * *
36 * *
37 \*---------------------------------------------------------------------------*/
39 #ifndef _OSGTEXTUREOBJCHUNK_H_
40 #define _OSGTEXTUREOBJCHUNK_H_
41 #ifdef __sgi
42 #pragma once
43 #endif
45 #include "OSGTextureObjChunkBase.h"
47 OSG_BEGIN_NAMESPACE
49 /*! \brief State chunk for textures. See \ref PageSystemTextureObjChunk
50 for a description.
51 \ingroup GrpSystemStateBaseChunks
52 \ingroup GrpLibOSGSystem
53 \includebasedoc
56 class OSG_SYSTEM_DLLMAPPING TextureObjChunk : public TextureObjChunkBase
58 /*========================== PUBLIC =================================*/
60 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.
67 enum NPOTMatrixScaleE
69 None_TT = 0,
70 NPotTexScale_TT = 1,
71 XFlip_TT = 2,
72 YFlip_TT = 4,
73 ZFlip_TT = 8
76 /*---------------------------------------------------------------------*/
77 /*! \name Chunk Class Access */
78 /*! \{ */
80 /*! \} */
81 /*---------------------------------------------------------------------*/
82 /*! \name Static Chunk Class Access */
83 /*! \{ */
85 /*! \} */
86 /*---------------------------------------------------------------------*/
87 /*! \name Chunk Id */
88 /*! \{ */
90 virtual bool isCubeTexture(void);
92 /*! \} */
93 /*---------------------------------------------------------------------*/
94 /*! \name Sync */
95 /*! \{ */
97 virtual void changed(ConstFieldMaskArg whichField,
98 UInt32 origin,
99 BitVector details);
101 /*! \} */
102 /*---------------------------------------------------------------------*/
103 /*! \name Output */
104 /*! \{ */
106 virtual void dump( UInt32 uiIndent = 0,
107 const BitVector bvFlags = 0) const;
109 /*! \} */
110 /*---------------------------------------------------------------------*/
111 /*! \name State */
112 /*! \{ */
114 virtual void activate (DrawEnv *pEnv,
115 UInt32 index = 0);
117 virtual void changeFrom (DrawEnv *pEnv,
118 StateChunk *pOld,
119 UInt32 index = 0);
121 virtual void deactivate (DrawEnv *pEnv,
122 UInt32 index = 0);
124 virtual bool isTransparent (void) const;
126 /*! \} */
127 /*---------------------------------------------------------------------*/
128 /*! \name query */
129 /*! \{ */
131 GLenum determineTextureTarget (Window *pWindow ) const;
132 void determineFormats (GLenum &internalFormat,
133 GLenum &externalFormat ) const;
135 /*! \} */
136 /*---------------------------------------------------------------------*/
137 /*! \name Comparison */
138 /*! \{ */
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;
147 /*! \} */
148 /*---------------------------------------------------------------------*/
149 /*! \name Texture specific */
150 /*! \{ */
152 void imageContentChanged (Int32 minx = -1, Int32 maxx = -1,
153 Int32 miny = -1, Int32 maxy = -1,
154 Int32 minz = -1, Int32 maxz = -1);
156 /*! \} */
157 /*---------------------------------------------------------------------*/
158 /*! \name Multitexture handling */
159 /*! \{ */
161 virtual void validate (DrawEnv *pEnv);
162 virtual Int32 getOpenGLId (DrawEnv *pEnv);
163 virtual GLenum determineInternalFormat(void );
165 /*! \} */
166 /*========================= PROTECTED ===============================*/
168 protected:
170 /*---------------------------------------------------------------------*/
171 /*! \name Init */
172 /*! \{ */
174 void onCreate (const TextureObjChunk *source = NULL);
175 void onCreateAspect(const TextureObjChunk *createAspect,
176 const TextureObjChunk *source = NULL);
177 void onDestroy ( UInt32 uiContainerId );
179 /*! \} */
180 /*---------------------------------------------------------------------*/
181 /*! \name Constructors */
182 /*! \{ */
184 TextureObjChunk(void);
185 TextureObjChunk(const TextureObjChunk &source);
187 /*! \} */
188 /*---------------------------------------------------------------------*/
189 /*! \name Destructors */
190 /*! \{ */
192 virtual ~TextureObjChunk(void);
194 /*! \} */
195 /*---------------------------------------------------------------------*/
196 /*! \name Init */
197 /*! \{ */
199 static void initMethod(InitPhase ePhase);
201 /*! \} */
202 /*---------------------------------------------------------------------*/
203 /*! \name GL */
204 /*! \{ */
206 void handleTexture(Window *win,
207 UInt32 id,
208 GLenum bindtarget,
209 GLenum paramtarget,
210 GLenum imgtarget,
211 Window::GLObjectStatusE mode,
212 Image *img,
213 Int32 side = 0);
215 /*! \} */
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 ================================*/
247 private:
249 typedef TextureObjChunkBase Inherited;
251 friend class FieldContainer;
252 friend class TextureObjChunkBase;
254 /*---------------------------------------------------------------------*/
255 /*! \name GL */
256 /*! \{ */
258 UInt32 handleGL (DrawEnv *pEnv,
259 UInt32 id,
260 Window::GLObjectStatusE mode,
261 UInt64 uiOptions);
263 static void handleDestroyGL(DrawEnv *pEnv,
264 UInt32 id,
265 Window::GLObjectStatusE mode );
267 /*! \} */
268 /*---------------------------------------------------------------------*/
270 // prohibit default functions (move to 'public' if you need one)
271 void operator =(const TextureObjChunk &source);
274 typedef TextureObjChunk *TextureObjChunkP;
276 OSG_END_NAMESPACE
278 #include "OSGTextureObjChunkBase.inl"
279 #include "OSGTextureObjChunk.inl"
281 #endif /* _OSGTEXTUREOBJCHUNK_H_ */