CudaImageDisplayGL.H

Go to the documentation of this file.
00001 /*!@file CUDA/CudaImageDisplayGL.H C++ wrapper for CUDA Image DisplayGL operations */
00002 
00003 // //////////////////////////////////////////////////////////////////// //
00004 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2000-2005   //
00005 // by the University of Southern California (USC) and the iLab at USC.  //
00006 // See http://iLab.usc.edu for information about this project.          //
00007 // //////////////////////////////////////////////////////////////////// //
00008 // Major portions of the iLab Neuromorphic Vision Toolkit are protected //
00009 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency //
00010 // in Visual Environments, and Applications'' by Christof Koch and      //
00011 // Laurent Itti, California Institute of Technology, 2001 (patent       //
00012 // pending; application number 09/912,225 filed July 23, 2001; see      //
00013 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status).     //
00014 // //////////////////////////////////////////////////////////////////// //
00015 // This file is part of the iLab Neuromorphic Vision C++ Toolkit.       //
00016 //                                                                      //
00017 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can   //
00018 // redistribute it and/or modify it under the terms of the GNU General  //
00019 // Public License as published by the Free Software Foundation; either  //
00020 // version 2 of the License, or (at your option) any later version.     //
00021 //                                                                      //
00022 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope  //
00023 // that it will be useful, but WITHOUT ANY WARRANTY; without even the   //
00024 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      //
00025 // PURPOSE.  See the GNU General Public License for more details.       //
00026 //                                                                      //
00027 // You should have received a copy of the GNU General Public License    //
00028 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write   //
00029 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,   //
00030 // Boston, MA 02111-1307 USA.                                           //
00031 // //////////////////////////////////////////////////////////////////// //
00032 //
00033 // Primary maintainer for this file:
00034 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/CUDA/CudaImageDisplayGL.H $
00035 // $Id: CudaImageDisplayGL.H 13222 2010-04-15 00:39:05Z itti $
00036 //
00037 
00038 #ifndef CUDAIMAGEDISPLAYGL_H_DEFINED
00039 #define CUDAIMAGEDISPLAYGL_H_DEFINED
00040 #include "CUDA/cutil.h"
00041 #include <GL/glew.h>
00042 #include <cuda_runtime.h>
00043 #include <cuda_gl_interop.h>
00044 
00045 #if defined(__APPLE__) || defined(MACOSX)
00046 #include <GLUT/glut.h>
00047 #else
00048 #include <GL/glut.h>
00049 #endif
00050 
00051 #include "Image/Image.H"
00052 #include "Image/ImageSet.H"
00053 #include "Image/Pixels.H"
00054 #include "Image/ColorOps.H"
00055 #include "Raster/Raster.H"
00056 #include "CUDA/CudaMathOps.H"
00057 #include "CUDA/CudaFramework.H"
00058 #include "CUDA/CudaImage.H"
00059 #include "CUDA/wrap_c_cuda.h"
00060 #include "CUDA/CudaColorOps.H"
00061 #include "CUDA/CudaDevices.H"
00062 #include "CUDA/CudaImageSet.H"
00063 #include "CUDA/CudaImageSetOps.H"
00064 #include "Util/Timer.H"
00065 
00066 class CudaImageDisplayGL
00067 {
00068 protected:
00069   static CudaImageDisplayGL *instance;
00070 
00071 public:
00072   static inline CudaImageDisplayGL *createCudaDisplay()
00073   {
00074     instance = new CudaImageDisplayGL();
00075     return instance;
00076   }
00077 
00078   void createDisplay(int w, int h);
00079   void runImageFilters(unsigned int *d_dst);
00080   void registerIdleFunction();
00081   void shutDown();
00082   int initGL(int x_size,int y_size);
00083   GLuint compileASMShader(GLenum program_type, const char *code);
00084   void initAllTex();
00085   void initOpenGLBuffers();
00086   void cleanup();
00087   void initMainWindow();
00088   void initDispGL(CudaImage<PixRGB<float> > &src);
00089   void updateDispGL();
00090   // Graphics pipeline processing is here
00091   virtual void displayFunction();
00092   // Do non graphics processing here
00093   virtual void idleFunction();
00094   // Update the frame if the canvas has changed
00095   virtual void timerFunction(int index);
00096   float getFPS();
00097   bool getShutdown();
00098   void setShutdown(bool isShutdown);
00099 
00100 protected:
00101   CudaFramework framework;
00102   int frameCounter;
00103   static inline void idleWrapper() { instance->idleFunction(); }
00104   static inline void displayWrapper() { instance->displayFunction(); }
00105   static void timerWrapper(int index) { instance->timerFunction(index); }
00106   // No instantiations, except from within subclass constructors
00107   CudaImageDisplayGL();
00108 
00109 private:
00110   //OpenGL PBO and texture "names"
00111   GLuint gl_PBO,gl_Tex;
00112   Timer tim;
00113   //Source image on the host side
00114   unsigned int *h_Src;
00115   int mWinW,mWinH;
00116   GLuint shader;
00117   int bufferIndex;
00118   int main_window;
00119   MemoryPolicy mp;
00120   int count_buffer_runs;
00121   int  g_Kernel;
00122   bool g_FPS;
00123   bool g_Diag;
00124   int frameN;
00125   bool shutdown;
00126 // ######################################################################
00127 //shader for displaying floating-point texture
00128 };
00129 #endif
Generated on Sun May 8 08:40:36 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3