00001 #ifndef Impala_Visualization_RgbOglImage_h 00002 #define Impala_Visualization_RgbOglImage_h 00003 00004 #ifndef Impala_Core_Array_Arrays_h 00005 #include "Core/Array/Arrays.h" 00006 #endif 00007 00008 // RvB: Commented as only OGLImage.h is necessary 00009 //#ifndef OGLWND_H 00010 //#include "Link/OGL/OGLWnd.h" 00011 //#endif 00012 00013 #ifndef OGLIMAGE_H 00014 #include "Link/OGL/OGLImage.h" 00015 #endif 00016 00017 namespace Impala { 00018 namespace Visualization { 00019 00020 class RgbOglImage 00021 { 00022 public: 00023 typedef Impala::Core::Array::Array2dVec3UInt8 Array2dVec3UInt8; 00024 00025 static OGLIMAGE* OglImage(Array2dVec3UInt8* im) 00026 { 00027 if (!im) return 0; 00028 00029 OGLIMAGE* oglIm = oglSys.OglImage(GL_RGB, im->CW(), im->CH()); 00030 oglIm->imDataFunc = OglImdataFunc; 00031 oglIm->onDestroy = OglImdataDestroyFunc; 00032 oglIm->imageHandle = im; 00033 sNrCreatedImages++; 00034 return oglIm; 00035 } 00036 00037 static int NrCreatedImages() { return sNrCreatedImages; } 00038 00039 private: 00040 static void* OglImdataFunc(OGLIMAGE* oglIm) 00041 { 00042 // Obtain our 'im' stored as 'imageHandle' 00043 Array2dVec3UInt8* ar = (Array2dVec3UInt8 *) oglIm->imageHandle; 00044 00045 // Set oglIm dimensions to our 'im' dimensions 00046 oglIm->w = ar->CW(); 00047 oglIm->h = ar->CH(); 00048 oglIm->changed = 0; 00049 00050 return (void *) ar->CPB(0, 0); // Pointer to the image pixels 00051 } 00052 00053 static void OglImdataDestroyFunc(OGLIMAGE* oglIm) 00054 { 00055 if (!oglIm) return; 00056 00057 Array2dVec3UInt8* ar = (Array2dVec3UInt8 *) oglIm->imageHandle; 00058 if (ar) delete ar; 00059 sNrCreatedImages--; 00060 } 00061 00062 static int sNrCreatedImages; 00063 }; 00064 00065 int RgbOglImage::sNrCreatedImages = 0; 00066 00067 } // namespace Visualization 00068 } // namespace Impala 00069 00070 #endif 00071