HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RE_IconTextureCache.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: RE_IconTextureCache.h (RE Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __RE_IconTextureCache__
12 #define __RE_IconTextureCache__
13 
14 #include "RE_API.h"
15 
16 #include <SYS/SYS_Math.h>
17 #include <SYS/SYS_Types.h>
18 #include <UT/UT_IntArray.h>
19 #include <UT/UT_ValArray.h>
20 #include <UT/UT_Array.h>
21 #include <UT/UT_Rect.h>
22 #include "RE_Texture.h"
23 
24 class RE_Render;
25 class PXL_Raster;
26 
28 {
29 public:
31  { }
33  short x, short y, short w, short h,
34  float alpha, float z)
35  : myTex(tex),
36  myClip(clip),
37  myX(x),
38  myY(y),
39  myW(w),
40  myH(h),
41  myAlpha(alpha),
42  myZ(z)
43  { }
44 
47  short myX;
48  short myY;
49  short myW;
50  short myH;
51  float myAlpha;
52  float myZ;
53 };
55 
57 {
58 public:
61 
62  /// Add a regular texture from a raster and return its unique ID.
63  RE_Texture *addTexture(RE_Render *r, PXL_Raster *texture);
64 
65  /// Add a texture from a raster, and automatically generate the mip-map
66  /// levels for it.
67  RE_Texture *addMipMapTexture(RE_Render *r, PXL_Raster *texture);
68 
69  /// Add a mip-mapped texture, with many levels defined by the rasters passed
70  /// as levels, and return its unique ID. The levels must all be powers of
71  /// two in size, and must follow the progression from 2^Nx2^N,
72  /// 2^(N-1)x2^(N-1), ..., 1x1.
73  RE_Texture *addMipMapTexture(RE_Render *r,
75 
76  /// Remove a texture from the cache.
77  void removeTexture(RE_Texture *tex);
78 
79  /// Free all textures.
80  void clearTextureCache();
81 
82  /// Returns a version # for the cache; every time it is cleared, this
83  /// number is bumped;
84  int getTextureVersion() const { return myVersion; }
85 
86  /// Render a given texture at (x, y) with width and height w, h.
87  void renderTexture(RE_Render *r, int x, int y, int w, int h,
88  RE_Texture *tex, float alpha, float z);
89 
90  /// These methods record the textures to be drawn, and draws them all at
91  /// once when endTextureDefer() is called. If you need all cached textures
92  /// to be drawn immediately without doing an end, call flushTextureDefer().
93  void beginTextureDefer(RE_Render *r);
94  void endTextureDefer(RE_Render *r);
95  void flushTextureDefer(RE_Render *r);
96 
97  int64 getCacheSize() const { return myCacheSize; }
98 
99 private:
100  RE_Texture *createTextureObject(RE_Render *r, PXL_Raster *image,
102  bool mipmap, bool autogen,
103  RE_TexFiltType min_filter,
105  RE_Texture *addTextureObject(RE_Texture *texture);
106 
107  /// An array of OpenGL texture IDs.
108  UT_ValArray<RE_Texture *> myTextures;
109 
110  /// Cache Version #; bumped at every cache clear.
111  int myVersion;
112  int64 myCacheSize;
113 
114  /// Data for the texture defer system, which batches icon rendering together
115  /// for improved GL performance.
116  UT_Array<re_DeferTexDraw> myDeferTexDraw;
117  UT_IntArray myTextureDeferStart;
118 };
119 
120 /// Get the one and only texture cache.
122 
123 #endif
124 
#define RE_API
Definition: RE_API.h:10
GLdouble GLdouble GLdouble z
Definition: glcorearb.h:847
GLint y
Definition: glcorearb.h:102
png_bytepp image
Definition: png.h:1849
RE_TexFiltType
long long int64
Definition: SYS_Types.h:106
int64 getCacheSize() const
RE_TexClampType
GLfloat GLfloat GLfloat alpha
Definition: glcorearb.h:111
GLsizei levels
Definition: glcorearb.h:2223
GLfloat GLfloat GLfloat GLfloat h
Definition: glcorearb.h:2001
IMATH_INTERNAL_NAMESPACE_HEADER_ENTER T clip(const T &p, const Box< T > &box)
Definition: ImathBoxAlgo.h:89
SYS_DECLARE_IS_POD(re_DeferTexDraw)
GLint GLenum GLint x
Definition: glcorearb.h:408
re_DeferTexDraw(RE_Texture *tex, const UT_DimRect &clip, short x, short y, short w, short h, float alpha, float z)
getOption("OpenEXR.storage") storage
Definition: HDK_Image.dox:276
GLuint texture
Definition: glcorearb.h:414
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:856
GLboolean r
Definition: glcorearb.h:1221
RE_TextureCompress
RE_API RE_IconTextureCache * REgetIconTextureCache()
Get the one and only texture cache.
int getTextureVersion() const
GLenum clamp
Definition: glcorearb.h:1233