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
29template <typename T> class LUTData;
31
34{
35public:
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
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
73protected:
74
77
80
83};
84
85//-----------------------------------------------------------------------------------------------
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
virtual ~View2DShader()
virtual void unbind()=0
deactivates the shader
virtual float getLutHeightScaleFactor()
View2DLut * _lut
pointer to the LUT data
virtual void bindLutTexture()
bind the lut texture to the current texture unit
virtual SbVec2s getLutTextureSize()
virtual void bindFilterKernelTexture()
bind the filter kernel texture
int _lastLutSize
last size of lut
virtual const char * name()=0
returns the name of the shader
void invalidateLut()
invalidate the lut
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
View2DLut * getLut()
gets the lut
virtual void setLut(View2DLut *newLut)
sets the lut currently used
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
abstract base class for shaders that use a 2D texture for LUT lookup
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
float getLutHeightScaleFactor() override
static GLint desiredLutTextureFormat()
ml::GLTexture _kernelTexture
int _lutHeight
number of COMPLETE texture rows used by the LUT (an additional row may be used partly)
void destroyLutTexture()
frees the lut texture
ml::GLTexture _lutTexture
texture that stores the LUT data
void bindLutTexture() override
bind the lut texture to the current texture unit
int _lutTextureWidth
power-of-two width of lut texture
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.
Target mlrange_cast(Source arg)
Generic version of checked ML casts.