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 #ifndef MITKGPGPU_H
00020 #define MITKGPGPU_H
00021
00022 #include <GL/glew.h>
00023
00024
00025 #if defined(_WIN32)
00026 #ifdef mitkGPGPU_EXPORTS
00027 #define GPGPU_DLL_API __declspec(dllexport)
00028 #else
00029 #define GPGPU_DLL_API __declspec(dllimport)
00030 #endif
00031 #else
00032 #define GPGPU_DLL_API
00033 #endif
00034
00035
00036 #ifdef _WIN32
00037 #include <windows.h>
00038 #else
00039 #include <GL/glx.h>
00040 #include <X11/Xlib.h>
00041 #endif
00042
00043 #include <GL/gl.h>
00044
00045
00046 #include "mitkCommon.h"
00047
00048
00049 namespace mitk {
00050
00051
00052
00053
00054 class GPGPU_DLL_API GPGPU
00055 {
00056 public:
00057
00058 enum TextureFormat
00059 {
00060 FLOAT32_LUMINANCE,
00061 FLOAT32_LUMINANCE_ALPHA,
00062 FLOAT32_RGBA,
00063 UINT8_RGBA,
00064 };
00065
00066 class GPGPU_DLL_API Texture {
00067
00068 public:
00069
00070 Texture(mitk::GPGPU::TextureFormat format,int width,int height,int depth=0);
00071 ~Texture();
00072
00073 void ActivateAsSource(int unit);
00074 void ActivateAsDestination();
00075 void Upload(mitk::GPGPU::TextureFormat inputformat,const void *src);
00076 void Download(mitk::GPGPU::TextureFormat inputformat,void *dst);
00077 int GetWidth();
00078 int GetHeigth();
00079 int GetDepth();
00080
00081 private:
00082
00083 mitk::GPGPU::TextureFormat myFormat;
00084 int myWidth,myHeight,myDepth;
00085
00086 int glTarget;
00087 int glInternalFormat;
00088 int glTextureHandle;
00089 int glFBOHandle;
00090 };
00091
00092 class GPGPU_DLL_API Shader {
00093
00094 public:
00095
00096 Shader(char *source);
00097 ~Shader();
00098
00099 void Activate();
00100 void SetUniform(char *name,int i0);
00101 void SetUniform(char *name,int i0,int i1);
00102 void SetUniform(char *name,int i0,int i1,int i2);
00103 void SetUniform(char *name,int i0,int i1,int i2,int i3);
00104 void SetUniform(char *name,float i0);
00105 void SetUniform(char *name,float i0,float i1);
00106 void SetUniform(char *name,float i0,float i1,float i2);
00107 void SetUniform(char *name,float i0,float i1,float i2,float i3);
00108
00109 private:
00110
00111 int GetUniformLocation(char *name);
00112
00113 int glHandleVertex;
00114 int glHandleFragment;
00115 int glHandleProgram;
00116
00117
00118 };
00119
00120 GPGPU();
00121 ~GPGPU();
00122
00123 void Activate();
00124 void Deactivate();
00125 void Run();
00126 void Run(float start,float end);
00127
00128 private:
00129 #ifdef _WIN32
00130 HWND windowHandle;
00131 HDC windowsContext;
00132 HGLRC openGLContext;
00133 #else
00134 GLXContext openGLContext;
00135 GLXDrawable GLX_drawable;
00136 Display *X_display;
00137 Window *windowHandle;
00138 #endif
00139
00140
00141 };
00142
00143 }
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204 #endif