core/vgui/vgui_cache_wizard.h
Go to the documentation of this file.
00001 // This is core/vgui/vgui_cache_wizard.h
00002 #ifndef vgui_cache_wizard_h_
00003 #define vgui_cache_wizard_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007 //:
00008 // \file
00009 // \author Marko Bacic
00010 // \date   17 Aug 2000
00011 // \brief Provides support for caching of large images
00012 //
00013 //  Contains classes: vgui_cache_wizard
00014 //
00015 // \verbatim
00016 //  Modifications
00017 //   17-AUG-2000 Initial version. Marko Bacic,Oxford RRG
00018 //   Feb.2002 - Peter Vanroose - brief doxygen comment placed on single line
00019 // \endverbatim
00020 
00021 #include <vcl_vector.h>
00022 #include <vcl_list.h>
00023 #include <vcl_utility.h>
00024 
00025 #include <vil1/vil1_image.h>
00026 #include <vgui/vgui_gl.h>
00027 
00028 //: Provides support for caching of large images.
00029 class vgui_cache_wizard
00030 {
00031  public:
00032   //: Each image consists of MxN quadrants. M,N is to be determined on runtime
00033   typedef vcl_vector <GLuint> image_cache_quadrants;
00034   typedef vcl_pair<vil1_image,image_cache_quadrants *> wizard_image;
00035   typedef vcl_pair<int,int> dimension;
00036 
00037   //: Loads an image into the memory
00038   int load_image(vil1_image);
00039 
00040   //: Get the texture names for the current viewport
00041   bool get_section(int id, int x, int y,int width,int height,
00042                    image_cache_quadrants *quadrants,dimension *pos,dimension *size);
00043 
00044   //:
00045   void TexImage2D_Brownie(vil1_image img);
00046 
00047   //: Get the image quadrant width
00048   int get_quadrant_width() const { return quadrant_width_; }
00049 
00050   //: Get the image quadrant height
00051   int get_quadrant_height() const { return quadrant_height_; }
00052 
00053   //: Get the class instance
00054   static vgui_cache_wizard *Instance();
00055 
00056   //: Constructor - set the image quadrant size here.
00057   vgui_cache_wizard(int quadrant_width, //= DEFAULT_QUADRANT_WIDTH,
00058                     int quadrant_height); //= DEFAULT_QUADRANT_HEIGHT);
00059 
00060   //: Destructor.
00061   ~vgui_cache_wizard();
00062 
00063  private:
00064   //: Hold a vector of images that have been loaded
00065   vcl_vector <wizard_image *> images_;
00066 
00067   //: Dimensions of images in quadrants units
00068   vcl_vector <dimension *>  dimensions_;
00069 
00070   //:
00071   int quadrant_width_;
00072 
00073   int quadrant_height_;
00074 
00075   //:
00076   // Maximum number of textures(limited by memory size - driver dependent,
00077   // as some drivers will do their one caching so that the number of textures
00078   // is only limited by the size of virtual memory
00079   unsigned int max_texture_num_;
00080 
00081   GLuint *texture_names_;
00082 
00083   //: Cache queue
00084   vcl_list <GLuint> cache_queue_;
00085 };
00086 
00087 #endif // vgui_cache_wizard_h_