10 // Comment this out if you do not have GLEW installed.
31 #ifdef HAVE_APPLE_OPENGL_FRAMEWORK
32 #include <OpenGL/gl.h>
43 * Represent a texture in video memory, with optional caching.
45 * Honours many IplImage fields like nChannels, depth, align, and origin.
50 IplTexture(IplImage
*image
=0, bool cache
=true, bool smooth
=true)
51 : im(image
), downsampled(0), allowCache(cache
), reload(true),
52 smooth(smooth
), textureGenerated(false), refcnt(1) {}
54 virtual ~IplTexture();
56 //! Only call genTexture from a valid OpenGL context !
59 void disableTexture();
60 void update() { reload
=true; }
61 void setImage(IplImage
*image
);
62 IplImage
*getImage() { return im
; }
63 IplImage
*getIm() { return im
; }
64 const IplImage
*getIm() const { return im
; }
65 void freeImage() { if (this && im
) { cvReleaseImage(&im
); } }
67 //! Get the U texel coordinates from pixel coordinate x.
68 double u(double x
) { return x
*uScale
; }
70 //! Get the V texel coordinates from pixel coordinate y (axis pointing down).
71 double v(double y
) { return y
*vScale
+ vOrigin
; }
73 //! force texture regeneration.
76 //! Add a reference to the reference counter.
77 void addRef() { refcnt
++; }
79 /*! Removes a reference to the reference counter, and delete the
80 * texture if it reaches 0.
84 void clearWithoutDelete() { im
= downsampled
= 0; }
88 IplImage
*downsampled
;
93 bool textureGenerated
;
96 double uScale
, vScale
, vOrigin
;
97 int texWidth
, texHeight
;