Medical Imaging Interaction Toolkit
2016.11.0
Medical Imaging Interaction Toolkit
Home
Manual
API Reference
Download
Bugzilla
Groups
Namespace List
Class List
File List
Examples
File List
File Members
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Modules
Pages
mitkGPGPU.h
Go to the documentation of this file.
1
/*===================================================================
2
3
The Medical Imaging Interaction Toolkit (MITK)
4
5
Copyright (c) German Cancer Research Center,
6
Division of Medical and Biological Informatics.
7
All rights reserved.
8
9
This software is distributed WITHOUT ANY WARRANTY; without
10
even the implied warranty of MERCHANTABILITY or FITNESS FOR
11
A PARTICULAR PURPOSE.
12
13
See LICENSE.txt or http://www.mitk.org for details.
14
15
===================================================================*/
16
17
#ifndef MITKGPGPU_H
18
#define MITKGPGPU_H
19
20
#include <GL/glew.h>
21
22
#include <
MitkGPGPUExports.h
>
23
24
#ifdef _WIN32
25
#include <windows.h>
26
#else
27
#include <GL/glx.h>
28
#include <X11/Xlib.h>
29
#endif
30
31
#include <GL/gl.h>
32
33
#include "
mitkCommon.h
"
34
35
namespace
mitk
36
{
37
//##Documentation
38
//## @brief GPGPU
39
40
class
MITKGPGPU_EXPORT
GPGPU
41
{
42
public
:
43
enum
TextureFormat
44
{
45
FLOAT32_LUMINANCE
,
46
FLOAT32_LUMINANCE_ALPHA
,
47
FLOAT32_RGBA
,
48
UINT8_RGBA
,
49
};
50
51
class
MITKGPGPU_EXPORT
Texture
52
{
53
public
:
54
Texture
(
mitk::GPGPU::TextureFormat
format,
int
width,
int
height,
int
depth = 0);
55
~
Texture
();
56
57
void
ActivateAsSource(
int
unit);
58
void
ActivateAsDestination();
59
void
Upload(
mitk::GPGPU::TextureFormat
inputformat,
const
void
*src);
60
void
Download(
mitk::GPGPU::TextureFormat
inputformat,
void
*dst);
61
int
GetWidth();
62
int
GetHeigth();
63
int
GetDepth();
64
65
private
:
66
mitk::GPGPU::TextureFormat
myFormat;
67
int
myWidth, myHeight, myDepth;
68
69
int
glTarget;
70
int
glTextureHandle;
71
int
glFBOHandle;
72
};
73
74
class
MITKGPGPU_EXPORT
Shader
75
{
76
public
:
77
Shader
(
char
*source);
78
~
Shader
();
79
80
void
Activate();
81
void
SetUniform(
char
*name,
int
i0);
82
void
SetUniform(
char
*name,
int
i0,
int
i1);
83
void
SetUniform(
char
*name,
int
i0,
int
i1,
int
i2);
84
void
SetUniform(
char
*name,
int
i0,
int
i1,
int
i2,
int
i3);
85
void
SetUniform(
char
*name,
float
i0);
86
void
SetUniform(
char
*name,
float
i0,
float
i1);
87
void
SetUniform(
char
*name,
float
i0,
float
i1,
float
i2);
88
void
SetUniform(
char
*name,
float
i0,
float
i1,
float
i2,
float
i3);
89
90
private
:
91
int
GetUniformLocation(
char
*name);
92
93
int
glHandleVertex;
94
int
glHandleFragment;
95
int
glHandleProgram;
96
};
97
98
GPGPU
();
99
~
GPGPU
();
100
101
void
Activate();
102
void
Deactivate();
103
void
Run();
104
void
Run(
float
start,
float
end);
105
106
private
:
107
#ifdef _WIN32
108
HWND windowHandle;
109
HDC windowsContext;
110
HGLRC openGLContext;
111
#else
112
GLXContext openGLContext;
113
GLXDrawable GLX_drawable;
114
Display *X_display;
115
#endif
116
};
117
118
}
// namespace mitk
119
120
/*{
121
mitk::GPGPU *gpu=new mitk::GPGPU();
122
123
gpu->Activate();
124
125
mitk::GPGPU::Texture *input=new mitk::GPGPU::Texture( GLSL_FLOAT32_LUMINANCE , 128,128 );
126
mitk::GPGPU::Texture *output=new mitk::GPGPU::Texture( GLSL_FLOAT32_LUMINANCE , 128,128 );
127
mitk::GPGPU::Shader *shader = new mitk::GPGPU::Shader(
128
"uniform float invsize;\n"
129
"uniform sampler2D input;\n"
130
"uniform sampler2D input2;\n"
131
"uniform sampler2D input3;\n"
132
"void main()\n"
133
"{\n"
134
" vec2 pos=gl_FragCoord.xy*invsize; \n"
135
" int x; \n"
136
" float y; \n"
137
" vec2 z; \n"
138
" vec4 ddd; \n"
139
" vec4 gl_FragColor; \n"
140
" float x = texture2D(input,vec2(x,y) );
141
" gl_FragColor.r = x; \n"
142
"}\n" );
143
144
input->Upload( GLSL_FLOAT32_LUMINANCE, eurerArray);
145
146
147
shader->Activate();
148
shader->SetUniform("input",0);
149
150
gpu->ActivateAsSource(input,0);
151
gpu->ActivateAsDestination(output);
152
gpu->Run();
153
154
155
input2->ActivateAsSource(0);
156
output2->ActivateAsDestination();
157
gpu->Run();
158
159
output->Download( GLSL_FLOAT32_LUMINANCE, zielArray);
160
161
input2->Upload( GLSL_FLOAT32_LUMINANCE, eurerArray);
162
163
input2->ActivateAsSource(0);
164
output2->ActivateAsDestination();
165
shader->SetUniform("input",0);
166
167
168
169
170
171
gpu->Deactivate();
172
173
delete gpu;
174
}*/
175
176
#endif
mitk::GPGPU::FLOAT32_RGBA
Definition:
mitkGPGPU.h:47
mitkCommon.h
mitk
DataCollection - Class to facilitate loading/accessing structured data.
Definition:
GeometryOverview.dox:1
mitk::GPGPU::Texture
Definition:
mitkGPGPU.h:51
mitk::GPGPU::TextureFormat
TextureFormat
Definition:
mitkGPGPU.h:43
mitk::GPGPU::Shader
Definition:
mitkGPGPU.h:74
MitkGPGPUExports.h
mitk::GPGPU::FLOAT32_LUMINANCE_ALPHA
Definition:
mitkGPGPU.h:46
MITKGPGPU_EXPORT
#define MITKGPGPU_EXPORT
Definition:
MitkGPGPUExports.h:15
mitk::GPGPU::UINT8_RGBA
Definition:
mitkGPGPU.h:48
mitk::GPGPU::FLOAT32_LUMINANCE
Definition:
mitkGPGPU.h:45
mitk::GPGPU
GPGPU.
Definition:
mitkGPGPU.h:40
git
MITK
Modules
GPGPU
mitkGPGPU.h
Generated on Fri Feb 3 2017 20:51:59 for Medical Imaging Interaction Toolkit by
1.8.9.1