MeVisLab Toolbox Reference
|
A class to render images as OpenGL Textures. More...
#include <View2DTexture.h>
Public Member Functions | |
View2DTexture () | |
create empty texture | |
virtual | ~View2DTexture () |
void | setLut (View2DLut *newLut) |
sets the lut currently used (NEEDS VALID CURRENT GL CONTEXT!) | |
View2DLut * | 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, MLDataType dtype=MLuint8Type, MLssize_t channels=1, bool ownsData=true) |
MLDataType | getImageDataType () |
get the data type of the stored image | |
void | allocateData (MLssize_t sizeX, MLssize_t sizeY, MLDataType 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 | forgetData () |
forget the data, without freeing it. | |
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 | |
MLssize_t | getChannels () const |
Get the number of color channels. | |
bool | isNPOT () |
Get if the texture is a non-power of two texture. | |
double | getDataShift () |
double | getDataScale () |
void | getSize (MLssize_t &x, MLssize_t &y) |
gets the current size of image | |
void | loadSliceToTexture (SoSFMLImage *image, MLssize_t slice, MLssize_t timepoint, MLssize_t userIndex, bool useNPOT=false) |
loads image slice to texture (depending on lut it uses a different data type) (LUT MUST be set before!!!) | |
void | loadSliceToTexture (ml::PagedImage *image, MLssize_t slice, MLssize_t timepoint, MLssize_t userIndex, bool useNPOT=false) |
void | loadSliceToTexture (SoSFMLImage *image, const ml::SubImageBox §ion, bool useNPOT=false) |
loads part of a slice to texture, z, t, and u should have size 1 | |
void | loadSliceToTexture (ml::PagedImage *image, const ml::SubImageBox §ion, bool useNPOT=false) |
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 | drawTextureRegion (float vp1[3], float vp2[3], float vp3[3], int startX, int startY, int endX, int endY) |
draws the texture region in the given 3d slice (vp1, vp2, vp3 (4. | |
void | drawTextureAsBorderImage (float dx1, float dy1, float dx2, float dy2, float borderWidth, float borderHeight) |
draws the image texture from dx1,dy1 to dx2,dy2 using 3x3 quads (the corners/border regions defined by borderWidth and borderHeight (in texels) are not stretched while the rest of the image is stretched to fill the box) For example usages, google for "css border-image". | |
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 | |
View2DShader * | getShader () |
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. | |
void | internalBindFirstTexture () |
Just binds the first texture. Only for internal use! | |
GLint | internalGetFirstTexture () |
void | createRenderToTextureTarget (int width, int height, int channels, GLenum format, GLenum internalFormat) |
MLuint64 | getSizeInBytesOnGPU () const |
Returns the number of bytes used on the GPU. | |
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 | |
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 texture 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.
Definition at line 46 of file View2DTexture.h.
View2DTexture::View2DTexture | ( | ) |
create empty texture
|
virtual |
void View2DTexture::allocateData | ( | MLssize_t | sizeX, |
MLssize_t | sizeY, | ||
MLDataType | 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::createRenderToTextureTarget | ( | int | width, |
int | height, | ||
int | channels, | ||
GLenum | format, | ||
GLenum | internalFormat ) |
draws the texture in the given 2d rectangle (NEEDS VALID CURRENT GL CONTEXT!)
draws the texture in the given 3d slice (vp1, vp2, vp3 (4. point is calculated)) (NEEDS VALID CURRENT GL CONTEXT!)
void View2DTexture::drawTextureAsBorderImage | ( | float | dx1, |
float | dy1, | ||
float | dx2, | ||
float | dy2, | ||
float | borderWidth, | ||
float | borderHeight ) |
draws the image texture from dx1,dy1 to dx2,dy2 using 3x3 quads (the corners/border regions defined by borderWidth and borderHeight (in texels) are not stretched while the rest of the image is stretched to fill the box) For example usages, google for "css border-image".
In contrast to drawTexture(), this method calls bindTexture() and restoreState(), so it does not require further setup calls before drawing. NOTE: This method only supports textures that are smaller than the maximum GL texture size.
void View2DTexture::drawTextureRegion | ( | float | vp1[3], |
float | vp2[3], | ||
float | vp3[3], | ||
int | startX, | ||
int | startY, | ||
int | endX, | ||
int | endY ) |
draws the texture region in the given 3d slice (vp1, vp2, vp3 (4.
point is calculated)) (NEEDS VALID CURRENT GL CONTEXT!) The region is given in pixel coordinates. This only works on textures that fit in a single GL texture.
void View2DTexture::forgetData | ( | ) |
forget the data, without freeing it.
void View2DTexture::freeData | ( | ) |
frees the stored data
void View2DTexture::freeTexture | ( | ) |
frees the allocated texture id
|
inline |
Get the number of color channels.
Definition at line 108 of file View2DTexture.h.
size_t View2DTexture::getCheckerInterval | ( | ) | const |
Get the checkerInterval variable value.
|
inline |
returns the data pointer (or NULL if empty), free write access is granted
Definition at line 84 of file View2DTexture.h.
|
inline |
Definition at line 114 of file View2DTexture.h.
|
inline |
Definition at line 113 of file View2DTexture.h.
|
inline |
get the used filter mode
Definition at line 63 of file View2DTexture.h.
|
inline |
get the data type of the stored image
Definition at line 78 of file View2DTexture.h.
View2DLut * View2DTexture::getLut | ( | ) |
gets the lut
returns next power of two and if size is only subpart
|
inline |
get the shader (might be NULL);
Definition at line 166 of file View2DTexture.h.
gets the current size of image
Definition at line 117 of file View2DTexture.h.
MLuint64 View2DTexture::getSizeInBytesOnGPU | ( | ) | const |
Returns the number of bytes used on the GPU.
|
inline |
returns TRUE if there is data stored, else it returns false
Definition at line 87 of file View2DTexture.h.
void View2DTexture::internalBindFirstTexture | ( | ) |
Just binds the first texture. Only for internal use!
GLint View2DTexture::internalGetFirstTexture | ( | ) |
|
inline |
Get if the texture is a non-power of two texture.
Definition at line 111 of file View2DTexture.h.
returns true if user is correct
Definition at line 102 of file View2DTexture.h.
References mlrange_cast().
returns true if user and id are correct
void View2DTexture::loadSliceToTexture | ( | ml::PagedImage * | image, |
const ml::SubImageBox & | section, | ||
bool | useNPOT = false ) |
void View2DTexture::loadSliceToTexture | ( | ml::PagedImage * | image, |
MLssize_t | slice, | ||
MLssize_t | timepoint, | ||
MLssize_t | userIndex, | ||
bool | useNPOT = false ) |
void View2DTexture::loadSliceToTexture | ( | SoSFMLImage * | image, |
const ml::SubImageBox & | section, | ||
bool | useNPOT = false ) |
loads part of a slice to texture, z, t, and u should have size 1
void View2DTexture::loadSliceToTexture | ( | SoSFMLImage * | image, |
MLssize_t | slice, | ||
MLssize_t | timepoint, | ||
MLssize_t | userIndex, | ||
bool | useNPOT = false ) |
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!)
Set the checkerInterval variable to value interval.
Results in every interval-th voxel drawn.
Invert the checkerboard, if inverted = TRUE.
void View2DTexture::setData | ( | void * | data, |
MLssize_t | sizeX, | ||
MLssize_t | sizeY, | ||
MLDataType | dtype = MLuint8Type, | ||
MLssize_t | channels = 1, | ||
bool | ownsData = true ) |
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! If ownsData == false, the ownership stays with the caller.
|
inline |
sets a flag that the current data needs to be reload as a texture because it was changed
Definition at line 96 of file View2DTexture.h.
void View2DTexture::setFilter | ( | View2DTextureFilter | filter | ) |
sets the filters that are currently used
forces the usage of the shader, regardless of the format, this also clears the internal image data reloading mechanism
sets the lut currently used (NEEDS VALID CURRENT GL CONTEXT!)
void View2DTexture::setShader | ( | View2DShader * | shader | ) |
sets the shader that should be used for rendering