MeVisLab Toolbox Reference
View2DShader.h
Go to the documentation of this file.
1 /*************************************************************************************
2 **
3 ** Copyright 2007, MeVis Medical Solutions AG
4 **
5 ** The user may use this file in accordance with the license agreement provided with
6 ** the Software or, alternatively, in accordance with the terms contained in a
7 ** written agreement between the user and MeVis Medical Solutions AG.
8 **
9 ** For further information use the contact form at https://www.mevislab.de/contact
10 **
11 **************************************************************************************/
12 
13 
15 
16 #pragma once
17 
18 #include "SoView2DSystem.h"
19 #include "mlDataTypes.h"
20 
21 #include <Inventor/SbLinear.h>
22 #include "View2DTexture.h"
23 #include "mlGLResourceManager.h"
24 
25 #define VIEW2D_BICUBIC_FILTER_TEX_SIZE 256
26 
27 // declare the LUTData
28 ML_START_NAMESPACE
29 template <typename T> class LUTData;
30 ML_END_NAMESPACE
31 
34 {
35 public:
37  virtual ~View2DShader();
38 
40  virtual const char* name() = 0;
41 
43  virtual void bind(View2DTexture* texture, int tw, int th) = 0;
44 
46  virtual void unbind() = 0;
47 
49  virtual void getRequiredTextureLayout(View2DTexture *texture, GLuint &format, GLuint &internalFormat, GLuint &transferDataType);
50 
52  virtual void setLut(View2DLut* newLut) { _lut = newLut; }
53 
55  View2DLut* getLut() { return _lut; }
56 
58  void invalidateLut() { _lastLutChangeID.reset(); }
59 
61  virtual void bindLutTexture() {};
62 
64  virtual void bindFilterKernelTexture() {};
65 
68 
69  virtual float getLutHeightScaleFactor() { return 0.; }
70 
71  virtual SbVec2s getLutTextureSize() { return SbVec2s(); }
72 
73 protected:
74 
77 
80 
83 };
84 
85 //-----------------------------------------------------------------------------------------------
88 {
89 public:
92 
93  void bindFilterKernelTexture() override;
94 
95  void bindLutTexture() override;
96 
97  float getLutHeightScaleFactor() override;
98 
99  SbVec2s getLutTextureSize() override;
100 
101 protected:
104 
107 
110 
115 
116  static GLint desiredLutTextureFormat();
117 
119  ml::GLTexture _lutTexture;
121 
122  ml::GLTexture _kernelTexture;
123 
130 };
View2DTextureFilter
Filter mode.
#define SOVIEW2D_API
File to resolve system dependencies in View2D library.
A small wrapper class for the LUT data.
Definition: View2DLut.h:23
base class for hardware shaders that can be used on a View2DTexture
Definition: View2DShader.h:34
virtual ~View2DShader()
View2DLut * getLut()
gets the lut
Definition: View2DShader.h:55
virtual void unbind()=0
deactivates the shader
virtual float getLutHeightScaleFactor()
Definition: View2DShader.h:69
View2DLut * _lut
pointer to the LUT data
Definition: View2DShader.h:76
virtual void bindLutTexture()
bind the lut texture to the current texture unit
Definition: View2DShader.h:61
virtual SbVec2s getLutTextureSize()
Definition: View2DShader.h:71
virtual void bindFilterKernelTexture()
bind the filter kernel texture
Definition: View2DShader.h:64
int _lastLutSize
last size of lut
Definition: View2DShader.h:82
virtual const char * name()=0
returns the name of the shader
void invalidateLut()
invalidate the lut
Definition: View2DShader.h:58
virtual void getRequiredTextureLayout(View2DTexture *texture, GLuint &format, GLuint &internalFormat, GLuint &transferDataType)
returns the required texture layout that a GL texture must use, as GL_format enums and datatypes
virtual void setLut(View2DLut *newLut)
sets the lut currently used
Definition: View2DShader.h:52
static void applyTextureFilter(View2DTextureFilter filter)
set the correct texture filtering on the currently bound texture
virtual void bind(View2DTexture *texture, int tw, int th)=0
binds/activates the shader, tw and th give the "poweroftwo" size of current subtexture that is render...
ml::LUTDataId _lastLutChangeID
id of last lut
Definition: View2DShader.h:79
abstract base class for shaders that use a 2D texture for LUT lookup
Definition: View2DShader.h:88
void createLutTexture()
creates a 2D texture from the shader's LUT
void createFilterKernelTexture()
create 1d filter kernel texture (using the approach described in section 20.2 of GPU Gems 2)
void bindFilterKernelTexture() override
bind the filter kernel texture
int _lutTextureHeight
power-of-two height of lut texture
Definition: View2DShader.h:127
float getLutHeightScaleFactor() override
static GLint desiredLutTextureFormat()
ml::GLTexture _kernelTexture
Definition: View2DShader.h:122
int _lutHeight
number of COMPLETE texture rows used by the LUT (an additional row may be used partly)
Definition: View2DShader.h:129
void destroyLutTexture()
frees the lut texture
ml::GLTexture _lutTexture
texture that stores the LUT data
Definition: View2DShader.h:119
void bindLutTexture() override
bind the lut texture to the current texture unit
int _lutTextureWidth
power-of-two width of lut texture
Definition: View2DShader.h:125
void destroyFilterKernelTexture()
destroy the filter kernel
SbVec2s getLutTextureSize() override
void updateLutTexture()
upload the lut to the texture (texture must be already created)
~View2DTextureLUTShader() override
A class to render images as OpenGL Textures.
Definition: View2DTexture.h:47