HDK
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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_Array.h>
20 #include <UT/UT_Rect.h>
21 #include "RE_Texture.h"
22 
23 class RE_Render;
24 class PXL_Raster;
25 
27 {
28 public:
30  { }
32  short x, short y, short w, short h,
33  float alpha, float z)
34  : myTex(tex),
35  myClip(clip),
36  myX(x),
37  myY(y),
38  myW(w),
39  myH(h),
40  myAlpha(alpha),
41  myZ(z)
42  { }
43 
46  short myX;
47  short myY;
48  short myW;
49  short myH;
50  float myAlpha;
51  float myZ;
52 };
54 
56 {
57 public:
60 
61  /// Add a regular texture from a raster and return its unique ID.
62  RE_Texture *addTexture(RE_Render *r, PXL_Raster *texture);
63 
64  /// Add a texture from a raster, and automatically generate the mip-map
65  /// levels for it.
66  RE_Texture *addMipMapTexture(RE_Render *r, PXL_Raster *texture);
67 
68  /// Add a mip-mapped texture, with many levels defined by the rasters passed
69  /// as levels, and return its unique ID. The levels must all be powers of
70  /// two in size, and must follow the progression from 2^Nx2^N,
71  /// 2^(N-1)x2^(N-1), ..., 1x1.
72  RE_Texture *addMipMapTexture(RE_Render *r,
74 
75  /// Remove a texture from the cache.
76  void removeTexture(RE_Texture *tex);
77 
78  /// Free all textures.
79  void clearTextureCache();
80 
81  /// Returns a version # for the cache; every time it is cleared, this
82  /// number is bumped;
83  int getTextureVersion() const { return myVersion; }
84 
85  /// Render a given texture at (x, y) with width and height w, h.
86  void renderTexture(RE_Render *r, int x, int y, int w, int h,
87  RE_Texture *tex, float alpha, float z);
88 
89  /// These methods record the textures to be drawn, and draws them all at
90  /// once when endTextureDefer() is called. If you need all cached textures
91  /// to be drawn immediately without doing an end, call flushTextureDefer().
92  void beginTextureDefer(RE_Render *r);
93  void endTextureDefer(RE_Render *r);
94  void flushTextureDefer(RE_Render *r);
95 
96  int64 getCacheSize() const { return myCacheSize; }
97 
98 private:
99  RE_Texture *createTextureObject(RE_Render *r, PXL_Raster *image,
101  bool mipmap, bool autogen,
102  RE_TexFiltType min_filter,
104  RE_Texture *addTextureObject(RE_Texture *texture);
105 
106  /// An array of OpenGL texture IDs.
107  UT_Array<RE_Texture *> myTextures;
108 
109  /// Cache Version #; bumped at every cache clear.
110  int myVersion;
111  int64 myCacheSize;
112 
113  /// Data for the texture defer system, which batches icon rendering together
114  /// for improved GL performance.
115  UT_Array<re_DeferTexDraw> myDeferTexDraw;
116  UT_IntArray myTextureDeferStart;
117 };
118 
119 /// Get the one and only texture cache.
121 
122 #endif
123 
GLenum clamp
Definition: glcorearb.h:1234
#define RE_API
Definition: RE_API.h:10
getFileOption("OpenEXR:storage") storage
Definition: HDK_Image.dox:276
GLdouble GLdouble GLdouble z
Definition: glcorearb.h:848
GLenum GLenum GLsizei void * image
Definition: glad.h:5132
GLint y
Definition: glcorearb.h:103
RE_TexFiltType
int64 getCacheSize() const
RE_TexClampType
long long int64
Definition: SYS_Types.h:116
GLfloat GLfloat GLfloat alpha
Definition: glcorearb.h:112
GLint GLenum GLint x
Definition: glcorearb.h:409
GLsizei levels
Definition: glcorearb.h:2224
GLfloat GLfloat GLfloat GLfloat h
Definition: glcorearb.h:2002
SYS_DECLARE_IS_POD(re_DeferTexDraw)
re_DeferTexDraw(RE_Texture *tex, const UT_DimRect &clip, short x, short y, short w, short h, float alpha, float z)
GLuint texture
Definition: glcorearb.h:415
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:857
GLboolean r
Definition: glcorearb.h:1222
RE_TextureCompress
IMATH_INTERNAL_NAMESPACE_HEADER_ENTER IMATH_HOSTDEVICE IMATH_CONSTEXPR14 T clip(const T &p, const Box< T > &box) IMATH_NOEXCEPT
Definition: ImathBoxAlgo.h:29
RE_API RE_IconTextureCache * REgetIconTextureCache()
Get the one and only texture cache.
int getTextureVersion() const