CudaImageDisplayGL.H
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
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
00091 virtual void displayFunction();
00092
00093 virtual void idleFunction();
00094
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
00107 CudaImageDisplayGL();
00108
00109 private:
00110
00111 GLuint gl_PBO,gl_Tex;
00112 Timer tim;
00113
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
00128 };
00129 #endif