00001 #ifndef vgui_utils_h_ 00002 #define vgui_utils_h_ 00003 //: 00004 // \file 00005 // \author fsm 00006 // \brief Useful static functions for vgui. 00007 // 00008 // \verbatim 00009 // Modifications 00010 // 991020 AWF Added inversion of translation+scale. 00011 // This is necessary because zoomers demand exact equality 00012 // when checking if they are 2D transformations. 00013 // \endverbatim 00014 00015 #include <vgui/vgui_gl.h> 00016 #include <vcl_vector.h> 00017 #include <vil1/vil1_rgb.h> 00018 #include <vil1/vil1_memory_image_of.h> 00019 #include <vil/vil_image_view.h> 00020 00021 //: Useful static functions for vgui. 00022 class vgui_utils 00023 { 00024 public: 00025 //: Get a memory image (vil1) corresponding to the OpenGL area 00026 static vil1_memory_image_of<vil1_rgb<unsigned char> > colour_buffer_to_image(); 00027 00028 //: Get an image view corresponding to the OpenGL area 00029 static vil_image_view<vxl_byte> colour_buffer_to_view(); 00030 00031 //: Dump the OpenGL area to the given image filename. 00032 static void dump_colour_buffer(char const *file); 00033 00034 //: Copy front colour buffer to back colour buffer. 00035 static void copy_front_to_back(); 00036 00037 //: Copy back colour buffer to front colour buffer. 00038 static void copy_back_to_front(); 00039 00040 //: Begin software overlay. 00041 static void begin_sw_overlay(); 00042 00043 //: End software overlay. 00044 static void end_sw_overlay(); 00045 00046 // Selection utilities 00047 static GLuint* enter_pick_mode(float x, float y, float w, float h=0); 00048 static unsigned leave_pick_mode(); 00049 static void process_hits(int num_hits, GLuint* ptr, vcl_vector<vcl_vector<unsigned> >& hits); 00050 00051 //: Returns the number of bits per pixel. 00052 static int bits_per_pixel(GLenum format, GLenum type); 00053 00054 private: 00055 static vil1_memory_image_of<vil1_rgb<GLubyte> > get_image(); 00056 static vil_image_view<GLubyte> get_view(); 00057 static void do_copy(); 00058 }; 00059 00060 #endif // vgui_utils_h_