MeVisLabToolboxReference
View2DTexture Class Reference

A class to render images as OpenGL Textures. More...

#include <View2DTexture.h>

List of all members.

Public Member Functions

 View2DTexture ()
 create empty texture
 ~View2DTexture ()
void setLut (ml::LUTData< MLuint8 > *newLut)
 sets the lut currently used (NEEDS VALID CURRENT GL CONTEXT!)
ml::LUTData< MLuint8 > * getLut ()
 gets the lut
void setFilter (View2DTextureFilter filter)
 sets the filters that are currently used
View2DTextureFilter getFilter ()
 get the used filter mode
void setData (void *data, MLssize_t sizeX, MLssize_t sizeY, MLssize_t dtype=MLuint8Type, MLssize_t channels=1)
MLDataType getImageDataType ()
 get the data type of the stored image
void allocateData (MLssize_t sizeX, MLssize_t sizeY, MLssize_t dtype=MLuint8Type, MLssize_t channels=1)
 allocates a new data area, frees the old data
void * getData ()
 returns the data pointer (or NULL if empty), free write access is granted
bool hasData ()
 returns TRUE if there is data stored, else it returns false
void freeData ()
 frees the stored data
void setDataChanged ()
 sets a flag that the current data needs to be reload as a texture because it was changed
bool isValidUserID (void *user, MLssize_t id)
 returns true if user and id are correct
bool isValidUser (void *user)
 returns true if user is correct
void setUserID (void *user, MLssize_t id)
 sets current user and id
void getSize (MLssize_t &x, MLssize_t &y)
 gets the current size of image
void loadSliceToTexture (SoSFMLImage *image, MLssize_t slice, MLssize_t timepoint)
 loads image slice to texture (depending on lut it uses a different data type) (LUT MUST be set before!!!)
void bindTexture ()
 binds the texture, needs to be done before drawTexture (NEEDS VALID CURRENT GL CONTEXT!)
void drawTexture (float dx1, float dy1, float dx2, float dy2)
 draws the texture in the given 2d rectangle (NEEDS VALID CURRENT GL CONTEXT!)
void drawTexture (float vp1[3], float vp2[3], float vp3[3])
 draws the texture in the given 3d slice (vp1, vp2, vp3 (4. point is calculated)) (NEEDS VALID CURRENT GL CONTEXT!)
void restoreState ()
 restores the GL state (NEEDS VALID CURRENT GL CONTEXT!)
void freeTexture ()
 frees the allocated texture id
bool needsImageData ()
 check if texture needs image data (NEEDS VALID CURRENT GL CONTEXT!)
void setShader (View2DShader *shader)
 sets the shader that should be used for rendering
void setForceShaderUsage (bool flag)
 forces the usage of the shader, regardless of the format, this also clears the internal image data reloading mechanism
View2DShadergetShader ()
 get the shader (might be NULL);
void setCheckerInterval (size_t interval)
 Set the checkerInterval variable to value interval.
size_t getCheckerInterval () const
 Get the checkerInterval variable value.
void setCheckerTilesInverted (bool inverted)
 Invert the checkerboard, if inverted = TRUE.
bool areCheckerTilesInverted () const
 Get the _areCheckersInverted variable value.

Static Public Member Functions

static MLssize_t getPowerOfTwo (MLssize_t size, bool &subflag)
 returns next power of two and if size is only subpart
static MLssize_t getPowerOfTwo (MLssize_t size)
 returns next power of two

Detailed Description

A class to render images as OpenGL Textures.

This class internally uses OpenGL Textures to render an image of arbitrary size, using multiple textures if the image is bigger than the teture limit of the hardware. Lookuptables are supported for all datatypes. The maximum color channels supported are 4, which is an RGBA image. Setting channels >4 results in undefined behaviour.

  • 1 channel = Luminance
  • 2 channels = Luminance+Alpha
  • 3 channels = RGB
  • 4 channels = RGBA

Definition at line 56 of file View2DTexture.h.


Constructor & Destructor Documentation

View2DTexture::View2DTexture ( )

create empty texture

View2DTexture::~View2DTexture ( )

Member Function Documentation

void View2DTexture::allocateData ( MLssize_t  sizeX,
MLssize_t  sizeY,
MLssize_t  dtype = MLuint8Type,
MLssize_t  channels = 1 
)

allocates a new data area, frees the old data

bool View2DTexture::areCheckerTilesInverted ( ) const

Get the _areCheckersInverted variable value.

void View2DTexture::bindTexture ( )

binds the texture, needs to be done before drawTexture (NEEDS VALID CURRENT GL CONTEXT!)

void View2DTexture::drawTexture ( float  dx1,
float  dy1,
float  dx2,
float  dy2 
)

draws the texture in the given 2d rectangle (NEEDS VALID CURRENT GL CONTEXT!)

void View2DTexture::drawTexture ( float  vp1[3],
float  vp2[3],
float  vp3[3] 
)

draws the texture in the given 3d slice (vp1, vp2, vp3 (4. point is calculated)) (NEEDS VALID CURRENT GL CONTEXT!)

void View2DTexture::freeData ( )

frees the stored data

void View2DTexture::freeTexture ( )

frees the allocated texture id

size_t View2DTexture::getCheckerInterval ( ) const

Get the checkerInterval variable value.

void* View2DTexture::getData ( void  ) [inline]

returns the data pointer (or NULL if empty), free write access is granted

Definition at line 93 of file View2DTexture.h.

View2DTextureFilter View2DTexture::getFilter ( ) [inline]

get the used filter mode

Definition at line 73 of file View2DTexture.h.

MLDataType View2DTexture::getImageDataType ( ) [inline]

get the data type of the stored image

Definition at line 87 of file View2DTexture.h.

ml::LUTData<MLuint8>* View2DTexture::getLut ( )

gets the lut

static MLssize_t View2DTexture::getPowerOfTwo ( MLssize_t  size,
bool &  subflag 
) [static]

returns next power of two and if size is only subpart

static MLssize_t View2DTexture::getPowerOfTwo ( MLssize_t  size) [static]

returns next power of two

View2DShader* View2DTexture::getShader ( ) [inline]

get the shader (might be NULL);

Definition at line 145 of file View2DTexture.h.

void View2DTexture::getSize ( MLssize_t x,
MLssize_t y 
) [inline]

gets the current size of image

Definition at line 114 of file View2DTexture.h.

bool View2DTexture::hasData ( ) [inline]

returns TRUE if there is data stored, else it returns false

Definition at line 96 of file View2DTexture.h.

bool View2DTexture::isValidUser ( void *  user) [inline]

returns true if user is correct

Definition at line 108 of file View2DTexture.h.

bool View2DTexture::isValidUserID ( void *  user,
MLssize_t  id 
)

returns true if user and id are correct

void View2DTexture::loadSliceToTexture ( SoSFMLImage image,
MLssize_t  slice,
MLssize_t  timepoint 
)

loads image slice to texture (depending on lut it uses a different data type) (LUT MUST be set before!!!)

bool View2DTexture::needsImageData ( )

check if texture needs image data (NEEDS VALID CURRENT GL CONTEXT!)

void View2DTexture::restoreState ( )

restores the GL state (NEEDS VALID CURRENT GL CONTEXT!)

void View2DTexture::setCheckerInterval ( size_t  interval)

Set the checkerInterval variable to value interval.

Results in every interval-th voxel drawn.

void View2DTexture::setCheckerTilesInverted ( bool  inverted)

Invert the checkerboard, if inverted = TRUE.

void View2DTexture::setData ( void *  data,
MLssize_t  sizeX,
MLssize_t  sizeY,
MLssize_t  dtype = MLuint8Type,
MLssize_t  channels = 1 
)

sets the current data and its size default is uint8 index data, the size in pixels is given as sizeX and sizeY. For color data, you can pass in a value of channels==3 for RGB and channels==4 for RGBA. The data is expected as RGB interleaved data, as in OpenGL. The size can be bigger than the maximum size of a single texture in OpenGL and it is allowed to be a non-power of two. NOTE: the right to free the data is moved to the View2DTexture object, you dont own the data anymore, the data needs to be allocated with malloc!

void View2DTexture::setDataChanged ( ) [inline]

sets a flag that the current data needs to be reload as a texture because it was changed

Definition at line 102 of file View2DTexture.h.

void View2DTexture::setFilter ( View2DTextureFilter  filter)

sets the filters that are currently used

void View2DTexture::setForceShaderUsage ( bool  flag)

forces the usage of the shader, regardless of the format, this also clears the internal image data reloading mechanism

void View2DTexture::setLut ( ml::LUTData< MLuint8 > *  newLut)

sets the lut currently used (NEEDS VALID CURRENT GL CONTEXT!)

void View2DTexture::setShader ( View2DShader shader)

sets the shader that should be used for rendering

void View2DTexture::setUserID ( void *  user,
MLssize_t  id 
)

sets current user and id


The documentation for this class was generated from the following file: