00001
00032 #ifndef LL_LLDYNAMICTEXTURE_H
00033 #define LL_LLDYNAMICTEXTURE_H
00034
00035 #include "llgl.h"
00036 #include "llcamera.h"
00037 #include "llcoord.h"
00038 #include "llimagegl.h"
00039
00040 class LLDynamicTexture
00041 {
00042 public:
00043 enum EOrder { ORDER_FIRST = 0, ORDER_MIDDLE = 1, ORDER_LAST = 2, ORDER_RESET = 3, ORDER_COUNT = 4 };
00044
00045 LLDynamicTexture(S32 width,
00046 S32 height,
00047 S32 components,
00048 EOrder order,
00049 BOOL clamp);
00050 virtual ~LLDynamicTexture();
00051
00052 S32 getOriginX() { return mOrigin.mX; }
00053 S32 getOriginY() { return mOrigin.mY; }
00054 S32 getWidth() { return mWidth; }
00055 S32 getHeight() { return mHeight; }
00056 S32 getComponents() { return mComponents; }
00057 S32 getSize() { return mWidth * mHeight * mComponents; }
00058
00059 virtual BOOL needsRender() { return TRUE; }
00060 virtual void preRender(BOOL clear_depth = TRUE);
00061 virtual BOOL render();
00062 virtual void postRender(BOOL success);
00063 virtual void bindTexture();
00064 virtual void unbindTexture();
00065
00066 static BOOL updateAllInstances();
00067
00068 static void destroyGL();
00069 static void restoreGL();
00070
00071 protected:
00072 void releaseGLTexture();
00073 void generateGLTexture();
00074 void generateGLTexture(LLGLint internal_format, LLGLenum primary_format, LLGLenum type_format, BOOL swap_bytes = FALSE);
00075
00076 protected:
00077 S32 mWidth;
00078 S32 mHeight;
00079 S32 mComponents;
00080 LLPointer<LLImageGL> mTexture;
00081 F32 mLastBindTime;
00082 BOOL mClamp;
00083 LLCoordGL mOrigin;
00084
00085 LLCamera mCamera;
00086 typedef std::set<LLDynamicTexture*> instance_list_t;
00087 static instance_list_t sInstances[ LLDynamicTexture::ORDER_COUNT ];
00088 static S32 sNumRenders;
00089 };
00090
00091 #endif