Mitsuba Renderer  0.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mitsuba::GLTexture Class Reference

OpenGL-based GPUTexture implementation. More...

#include <mitsuba/hw/gltexture.h>

+ Inheritance diagram for mitsuba::GLTexture:

Public Member Functions

 GLTexture (const std::string &name, Bitmap *bitmap)
 Create a new GLTexture with the given name and bitmap. More...
 
void init ()
 Upload the texture. More...
 
void refresh ()
 Refresh (re-upload) the texture. More...
 
void refresh (const Point2i &offset, const Vector2i &size)
 Refresh (re-upload) a subregion of the texture. More...
 
void cleanup ()
 Free the texture from GPU memory. More...
 
void bind (int textureUnit=0, int textureIndex=0) const
 Bind the texture and enable texturing. More...
 
void download (Bitmap *bitmap=NULL)
 Download the texture (only for render target textures) More...
 
void unbind () const
 Unbind the texture and disable texturing. More...
 
void activateTarget ()
 Activate the render target. More...
 
void activateSide (int side)
 Activate a certain face of a cube map as render target. More...
 
void setTargetRegion (const Point2i &offset, const Vector2i &size)
 Restrict rendering to a sub-region of the texture. More...
 
void releaseTarget ()
 Deactivate the render target. More...
 
void blit (GPUTexture *target, int what) const
 Blit a render buffer into another render buffer. More...
 
void blit (GPUTexture *target, int what, const Point2i &sourceOffset, const Vector2i &sourceSize, const Point2i &destOffset, const Vector2i &destSize) const
 Blit a render buffer into another render buffer. More...
 
void clear ()
 Clear (assuming that this is a render buffer) More...
 
Color3 getPixel (int x, int y) const
 Assuming that this is a 2D RGB framebuffer, read a single pixel from the GPU. More...
 
virtual const ClassgetClass () const
 Retrieve this object's class. More...
 
- Public Member Functions inherited from mitsuba::GPUTexture
 GPUTexture (const std::string &name, Bitmap *bitmap)
 Construct a new texture. More...
 
void setName (const std::string &name)
 Set the texture name. More...
 
const std::string & getName () const
 Get the texture name. More...
 
void setType (ETextureType textureType)
 Set the texture type. More...
 
ETextureType getType () const
 Return the texture type. More...
 
void setPixelFormat (EPixelFormat fmt)
 Set the pixel format of this texture. More...
 
EPixelFormat getPixelFormat () const
 Return the pixel format of this texture. More...
 
void setComponentFormat (EComponentFormat fmt)
 Set the component format of this texture. More...
 
EComponentFormat getComponentFormat () const
 Return the component format of this texture. More...
 
void setFrameBufferType (EFrameBufferType frameBufferType)
 Set the framebuffer type (applies only if type==EFrameBuffer) More...
 
EFrameBufferType getFrameBufferType () const
 Return the framebuffer type (applies only if type==EFrameBuffer) More...
 
void setFilterType (EFilterType filterType)
 Set the filter type. More...
 
EFilterType getFilterType () const
 Return the filter type. More...
 
void setWrapType (EWrapType wrapType)
 Set the wrap type. More...
 
void setWrapTypeU (EWrapType wrapType)
 Set the wrap type along the U axis. More...
 
EWrapType getWrapTypeU ()
 Return the wrap type along the U axis. More...
 
void setWrapTypeV (EWrapType wrapType)
 Set the wrap type along the V axis. More...
 
EWrapType getWrapTypeV ()
 Return the wrap type along the V axis. More...
 
Point3i getSize () const
 Return the size in pixels. More...
 
void setSize (const Point3i &size)
 Set the size in pixels. More...
 
Float getMaxAnisotropy () const
 Get the maximal anisotropy. More...
 
void setMaxAnisotropy (Float maxAnisotropy)
 Set the maximal anisotropy. More...
 
bool isMipMapped () const
 Return whether mipmapping is enabled. More...
 
void setMipMapped (bool mipMapped)
 Define whether mipmapping is enabled. More...
 
EDepthMode getDepthMode () const
 Return the depth map read mode. More...
 
void setDepthMode (EDepthMode mode)
 Set the depth map read mode. More...
 
void setBitmap (unsigned int slot, Bitmap *bitmap)
 Store a bitmap in a bitmap slot. More...
 
BitmapgetBitmap (unsigned int slot=EDefaultPosition)
 Retrieve a bitmap from the given slot. More...
 
const BitmapgetBitmap (unsigned int slot=EDefaultPosition) const
 Retrieve a bitmap from the given slot. More...
 
int getBitmapCount () const
 Return the number of stored bitmaps. More...
 
void release ()
 Dereference the CPU bitmap associated with the texture. More...
 
void initAndRelease ()
 Run init, followed by release. More...
 
const std::set< int > & getTextureUnits () const
 Return the texture units, to which this texture is currently bound. More...
 
void setSampleCount (int samples)
 Set the number of samples (for multisample color render targets) More...
 
int getSampleCount () const
 Return the number of samples (for multisample color render targets) More...
 
void setBorderColor (const Color3 &borderColor)
 Set the border color (applicable if wrapMode=EClamp/EClampToBorder) More...
 
const Color3getBorderColor () const
 Return the border color. More...
 
std::string toString () const
 Return a string representation. More...
 
- Public Member Functions inherited from Object
 Object ()
 Construct a new object. More...
 
int getRefCount () const
 Return the current reference count. More...
 
void incRef () const
 Increase the reference count of the object by one. More...
 
void decRef (bool autoDeallocate=true) const
 Decrease the reference count of the object and possibly deallocate it. More...
 

Static Public Attributes

static Classm_theClass
 
- Static Public Attributes inherited from mitsuba::GPUTexture
static Classm_theClass
 
- Static Public Attributes inherited from Object
static Classm_theClass
 Pointer to the object's class descriptor. More...
 

Protected Member Functions

virtual ~GLTexture ()
 Virtual destructor. More...
 
void lookupGLConstants ()
 Look up relevant constants. More...
 
void configureTexture ()
 Configure texture filtering. More...
 
- Protected Member Functions inherited from mitsuba::GPUTexture
virtual ~GPUTexture ()
 Virtual destructor. More...
 
- Protected Member Functions inherited from Object
virtual ~Object ()
 Virtual private deconstructor. (Will only be called by ref) More...
 

Protected Attributes

uint32_t m_id
 
uint32_t m_glType
 
uint32_t m_format
 
uint32_t m_internalFormat
 
uint32_t m_dataFormat
 
uint32_t m_fboId
 
uint32_t m_depthId
 
bool m_needsUpdate
 
- Protected Attributes inherited from mitsuba::GPUTexture
std::string m_name
 
ETextureType m_type
 
EPixelFormat m_pixelFormat
 
EComponentFormat m_componentFormat
 
EFilterType m_filterType
 
EWrapType m_wrapTypeU
 
EWrapType m_wrapTypeV
 
EFrameBufferType m_fbType
 
EDepthMode m_depthMode
 
bool m_mipmapped
 
PrimitiveThreadLocal< std::set
< int > > 
m_textureUnits
 
Float m_maxAnisotropy
 
int m_samples
 
std::vector< Bitmap * > m_bitmaps
 
Point3i m_size
 
Color3 m_borderColor
 

Additional Inherited Members

- Public Types inherited from mitsuba::GPUTexture
enum  ETextureType { ETexture1D = 0, ETexture2D, ETexture3D, ETextureCubeMap }
 Available texture types. More...
 
enum  EFrameBufferType { ENone = 0x00, EColorBuffer = 0x01, EDepthBuffer = 0x02, EColorAndDepthBuffer = 0x03 }
 If the texture type is set to EFrameBuffer, the configuration must be one of the following constants. More...
 
enum  EComponentFormat {
  EUInt8, EUInt16, EUInt32, EFloat16,
  EFloat32, EFloat64
}
 Supported per-component data formats. More...
 
enum  EPixelFormat {
  EDepth = 0, ELuminance, ELuminanceAlpha, ERGB,
  ERGBA
}
 Supported pixel format types. More...
 
enum  ETexturePosition {
  EDefaultPosition = 0, ECubeMapPositiveX = 0, ECubeMapNegativeX, ECubeMapPositiveY,
  ECubeMapNegativeY, ECubeMapPositiveZ, ECubeMapNegativeZ, ELastPosition
}
 A texture has one more slots into which bitmaps can be placed. More...
 
enum  EWrapType {
  EClamp = 0, EClampToEdge, EClampToBorder, ERepeat,
  EMirror
}
 Texture wrapping mode when texture coordinates exit the [0, 1] range. More...
 
enum  EFilterType { ENearest = 0, ELinear, EMipMapNearest, EMipMapLinear }
 The interpolation filter determines which texture pixels are considered when shading a fragment. More...
 
enum  EDepthMode { ENormal, ECompare }
 When this texture contains a depth buffer, the following modes control the read behavior of the associated texture unit. 'ENormal' means that texture values are returned as with any other texture, whereas 'ECompare' causes a depth comparison to take place (this is the default). More...
 
- Static Public Member Functions inherited from Object
static void staticInitialization ()
 Initializes the built-in reference count debugger (if enabled) More...
 
static void staticShutdown ()
 Free the memory taken by staticInitialization() More...
 

Detailed Description

OpenGL-based GPUTexture implementation.

Constructor & Destructor Documentation

mitsuba::GLTexture::GLTexture ( const std::string &  name,
Bitmap bitmap 
)

Create a new GLTexture with the given name and bitmap.

virtual mitsuba::GLTexture::~GLTexture ( )
protectedvirtual

Virtual destructor.

Member Function Documentation

void mitsuba::GLTexture::activateSide ( int  side)
virtual

Activate a certain face of a cube map as render target.

Implements mitsuba::GPUTexture.

void mitsuba::GLTexture::activateTarget ( )
virtual

Activate the render target.

Implements mitsuba::GPUTexture.

void mitsuba::GLTexture::bind ( int  textureUnit = 0,
int  textureIndex = 0 
) const
virtual

Bind the texture and enable texturing.

Parameters
textureUnitSpecifies the unit to which this texture should be bound
textureIndexWhen this texture has multiple sub-textures (e.g. a color and depth map in the case of a EColorAndDepthBuffer texture), this parameter specifies the one to be bound

Implements mitsuba::GPUTexture.

void mitsuba::GLTexture::blit ( GPUTexture target,
int  what 
) const
virtual

Blit a render buffer into another render buffer.

Parameters
targetSpecifies the target render buffer (or NULL for the framebuffer)
whatA bitwise-OR of the components in EFrameBufferType to copy

Implements mitsuba::GPUTexture.

void mitsuba::GLTexture::blit ( GPUTexture target,
int  what,
const Point2i sourceOffset,
const Vector2i sourceSize,
const Point2i destOffset,
const Vector2i destSize 
) const
virtual

Blit a render buffer into another render buffer.

Parameters
targetSpecifies the target render buffer (or NULL for the framebuffer)
whatA bitwise-OR of the components in EFrameBufferType to copy
sourceOffsetOffset in the source render buffer
sourceOffsetSize of the region to be copied from the source render buffer
destOffsetOffset in the destination render buffer
destOffsetSize of the region to be copied into the dest destination buffer

Implements mitsuba::GPUTexture.

void mitsuba::GLTexture::cleanup ( )
virtual

Free the texture from GPU memory.

Implements mitsuba::GPUTexture.

void mitsuba::GLTexture::clear ( )
virtual

Clear (assuming that this is a render buffer)

Implements mitsuba::GPUTexture.

void mitsuba::GLTexture::configureTexture ( )
protected

Configure texture filtering.

void mitsuba::GLTexture::download ( Bitmap bitmap = NULL)
virtual

Download the texture (only for render target textures)

Implements mitsuba::GPUTexture.

virtual const Class* mitsuba::GLTexture::getClass ( ) const
virtual

Retrieve this object's class.

Reimplemented from mitsuba::GPUTexture.

Color3 mitsuba::GLTexture::getPixel ( int  x,
int  y 
) const
virtual

Assuming that this is a 2D RGB framebuffer, read a single pixel from the GPU.

Implements mitsuba::GPUTexture.

void mitsuba::GLTexture::init ( )
virtual

Upload the texture.

Implements mitsuba::GPUTexture.

void mitsuba::GLTexture::lookupGLConstants ( )
protected

Look up relevant constants.

void mitsuba::GLTexture::refresh ( )
virtual

Refresh (re-upload) the texture.

Implements mitsuba::GPUTexture.

void mitsuba::GLTexture::refresh ( const Point2i offset,
const Vector2i size 
)
virtual

Refresh (re-upload) a subregion of the texture.

Note: this is only implemented for 2D textures

Implements mitsuba::GPUTexture.

void mitsuba::GLTexture::releaseTarget ( )
virtual

Deactivate the render target.

Implements mitsuba::GPUTexture.

void mitsuba::GLTexture::setTargetRegion ( const Point2i offset,
const Vector2i size 
)
virtual

Restrict rendering to a sub-region of the texture.

Implements mitsuba::GPUTexture.

void mitsuba::GLTexture::unbind ( ) const
virtual

Unbind the texture and disable texturing.

Implements mitsuba::GPUTexture.

Member Data Documentation

uint32_t mitsuba::GLTexture::m_dataFormat
protected
uint32_t mitsuba::GLTexture::m_depthId
protected
uint32_t mitsuba::GLTexture::m_fboId
protected
uint32_t mitsuba::GLTexture::m_format
protected
uint32_t mitsuba::GLTexture::m_glType
protected
uint32_t mitsuba::GLTexture::m_id
protected
uint32_t mitsuba::GLTexture::m_internalFormat
protected
bool mitsuba::GLTexture::m_needsUpdate
mutableprotected
Class* mitsuba::GLTexture::m_theClass
static

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