Depth of Field  0.1
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros
simplePBO.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Class SimplePBO for encapsulating pixel buffer and texturing.
3 *******************************************************************************/
4 #ifndef __SIMPLEPBO_H
5 #define __SIMPLEPBO_H
6 
7 #include <qglbuffer.h>
8 #include <cuda_runtime.h>
9 #include <cuda_gl_interop.h>
10 
11 //#include "glm/glm.hpp"
12 //#include "glm/gtc/matrix_transform.hpp"
13 #include "globals.h"
14 #include <time.h>
15 
16 
23 class SimplePBO
24 {
25  public:
26  SimplePBO(void);
27  ~SimplePBO(void);
28 
29  bool volren;
30  int dataset;
31  float alpha;
32 
36  void initCuda(void *h_volume, cudaExtent volumeSize);
40  void resize(int w, int h);
44  void bind();
48  void release();
52  void runCuda(int time);
56  void cleanupCuda();
57 
58  // camera handling
59  void handleRotation(int timediff, int dx, int dy);
60  void handleTranslation(int timediff, int dx, int dy);
61  void handleZoom(int timediff, int dy);
62  void setXRotation(int angle);
63  void setYRotation(int angle);
64  void setZRotation(int angle);
65  void setViewChanged(bool changed);
66 
67  private:
68  void createPBO();
69  void deletePBO();
70  void createTexture();
71  void deleteTexture();
72 
73  private:
74  unsigned int image_width;
75  unsigned int image_height;
76  QGLBuffer* pixelBuffer;
77  GLuint* textureID;
78 
79  void* data; // the volume data on the host
80  uint* d_output; // the volume data on the gpu
81  dim3 blockSize;
82  dim3 gridSize;
83  dim3 volumeSize;
84 
85  // function for updating inverse view matrix for cuda
86  void updateView();
87  bool viewChanged; // flag that tells if the view has changed
88 
89  // matrices responsible for "camera movement"
90  float3 viewRotation;
91  float3 viewTranslation;
92  float invViewMatrix[12];
93 
94  float density;
95  float brightness;
96  float transferOffset;
97  float transferScale;
98  bool linearFiltering;
99 
100  // the focus point and camera position in model coordinates (model is always positioned at (0,0,0) in world
101  float4 focusPoint;
102  float4 camPos;
103  float4 mult(float *m, float4 v);
104 };
105 
106 #endif