Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
BIAS::glfTexture Class Reference

Base class for textures. More...

#include <OpenGLFramework/Base/glfTexture.hh>

+ Inheritance diagram for BIAS::glfTexture:

Public Member Functions

void Bind () const
 Binds the texture. More...
 
void BindTU () const
 Binds the texture. More...
 
void BindTU (int number) const
 Binds the texture. More...
 
void Create ()
 Creates the texture but does not upload any data yet. More...
 
void EnlargeToPowerOfTwoIfRequired (bool enlargeToPotIfRequired=true)
 Sets whether to enlarge each texture dimension to the next power of two, if non-power-of-two textures are not supported. More...
 
void GenerateMipMap ()
 Explicitly generates the mipmaps of the texture in hardware. More...
 
GLuint GetTextureID () const
 Returns the OpenGL texture id. More...
 
GLint GetTextureNr ()
 Returns the OpenGL texture number. More...
 
int GetTextureNrInUniformFormat ()
 Returns the OpenGL texture number in uniform format or -1 for error. More...
 
GLenum GetTextureTarget () const
 Returns the OpenGL texture target. More...
 
void SetBaseLevel (int baseLevel)
 Sets the minimum (base) mip map level to be used. More...
 
void SetBorderColor (GLfloat r, GLfloat g, GLfloat b, GLfloat a)
 Sets the border color for the texture to be used. More...
 
void SetGenerateMipMap (bool generateMipMap)
 Sets whether to automatically generate mipmaps when the first mipmap is uploaded. More...
 
void SetMagFilter (GLenum magFilter)
 Sets the magnification function. More...
 
void SetMaxLevel (int maxLevel)
 Sets the maximum mip map level to be used. More...
 
void SetMinFilter (GLenum minFilter)
 Sets the minifying function. More...
 
void SetTextureNr (GLint textureNr)
 Sets the OpenGL texture number (GL_TEXTURE0 - GL_TEXTURE[MaxTextureUnit-1]). More...
 
void SetTextureNrInUniformFormat (int textureNr)
 Sets the OpenGL texture number (0 - MaxTextureUnit-1). More...
 
void SetWrapR (GLenum wrapR)
 Sets the wrapping mode for the 3rd texture coordinate. More...
 
void SetWrapS (GLenum wrapS)
 Sets the wrapping mode for the 1st texture coordinate. More...
 
void SetWrapT (GLenum wrapT)
 Sets the wrapping mode for the 2nd texture coordinate. More...
 
virtual ~glfTexture ()
 

Protected Member Functions

 glfTexture (GLenum target)
 

Static Protected Member Functions

Utility functions used by derived classes.
static int NextPowerOfTwo (int i)
 Returns the smallest power of two that is greater than i. More...
 
static int GetMaxSupportedTextureUnits ()
 Computes a pixel format that can be used with glGetTexImage for an internal format of a texture. More...
 

Protected Attributes

bool enlargeToPot_
 
GLuint id_
 
int MAX_TEXTURE_UNITS_
 
GLenum target_
 
GLint textureNr_
 

Friends

BIASOpenGLFramework_EXPORT void SwapGLObjects (glfTexture &A, glfTexture &B)
 Swap the GL object IDs. More...
 

Detailed Description

Base class for textures.

When creating a texture, call:

  1. Create()
  2. Set texture parameters.
  3. Upload...(...) method of a derived class.
Author
jkollmann

Definition at line 42 of file glfTexture.hh.

Constructor & Destructor Documentation

glfTexture::~glfTexture ( )
virtual

Definition at line 71 of file glfTexture.cpp.

References id_.

glfTexture::glfTexture ( GLenum  target)
protected

Definition at line 63 of file glfTexture.cpp.

References enlargeToPot_, id_, target_, and textureNr_.

Member Function Documentation

void glfTexture::Bind ( ) const
void glfTexture::BindTU ( ) const

Binds the texture.

Set texture active. Use this for multitexturing shaders without the use of a glfbatch.

Attention
For internal usage inside OpenGLFramework Base library only.

Definition at line 249 of file glfTexture.cpp.

References id_, target_, and textureNr_.

Referenced by BIAS::OutputLensDistortion::Draw_().

void glfTexture::BindTU ( int  number) const

Binds the texture.

Sets the texture active with GL_TEXTURE0+number, before binding

Attention
For internal usage inside OpenGLFramework Base library only.

Definition at line 259 of file glfTexture.cpp.

References id_, and target_.

void glfTexture::Create ( )
void glfTexture::EnlargeToPowerOfTwoIfRequired ( bool  enlargeToPotIfRequired = true)

Sets whether to enlarge each texture dimension to the next power of two, if non-power-of-two textures are not supported.

Otherwise, uploading a non-power-of-two texture will cause an exception to be thrown, if the hardware does not support it. The default is 'false'. Must be called before any data is uploaded to the texture.

Definition at line 163 of file glfTexture.cpp.

References enlargeToPot_.

void glfTexture::GenerateMipMap ( )

Explicitly generates the mipmaps of the texture in hardware.

This can be used, when the texture was generated by rendering to a framebuffer object.

Definition at line 194 of file glfTexture.cpp.

References Bind(), and target_.

Referenced by BIAS::DistortionRendering::EndRendering(), and BIAS::DistortionRendering::Init().

int glfTexture::GetMaxSupportedTextureUnits ( )
staticprotected

Computes a pixel format that can be used with glGetTexImage for an internal format of a texture.

Also returns the number of channels. For example: If internalFormat = GL_R3_G3_B2, then format = GL_RGB and numChannels = 3.

Deprecated:
use glfFormatDB

Returns the OpenGL pixel type (GL_UNSIGNED_BYTE etc.) for a BIAS storage type.

Deprecated:
use glfFormatDB

Returns the OpenGL pixel format (GL_RGB etc.) for a BIAS color model.

Deprecated:
use glfFormatDB

cp from glfBatch

Definition at line 185 of file glfTexture.cpp.

Referenced by SetTextureNr(), and SetTextureNrInUniformFormat().

GLuint BIAS::glfTexture::GetTextureID ( ) const
inline

Returns the OpenGL texture id.

Attention
For internal usage inside OpenGLFramework Base library only.

Definition at line 144 of file glfTexture.hh.

Referenced by BIAS::clfImage2D::AllocateFromTexture2D(), BIAS::clfImage3D::AllocateFromTexture3D(), and BIAS::glfFramebufferObject::AttachTexture().

GLint BIAS::glfTexture::GetTextureNr ( )
inline

Returns the OpenGL texture number.

Attention
For internal usage inside OpenGLFramework Base library only.

Definition at line 156 of file glfTexture.hh.

int BIAS::glfTexture::GetTextureNrInUniformFormat ( )
inline

Returns the OpenGL texture number in uniform format or -1 for error.

Attention
For internal usage inside OpenGLFramework Base library only.

Intended usage:

renderedTexture.SetTextureNr(GL_TEXTURE5);

renderedTexture2.SetTextureNr(GL_TEXTURE6);

shaderProg.SetUniform("renderedTexture", renderedTexture.GetTextureNrInUniformFormat());

shaderProg.SetUniform("renderedTexture2", renderedTexture2.GetTextureNrInUniformFormat());

Definition at line 183 of file glfTexture.hh.

Referenced by BIAS::OutputLensDistortion::Draw_().

GLenum BIAS::glfTexture::GetTextureTarget ( ) const
inline

Returns the OpenGL texture target.

Attention
For internal usage inside OpenGLFramework Base library only.

Definition at line 150 of file glfTexture.hh.

Referenced by BIAS::clfImage2D::AllocateFromTexture2D(), BIAS::clfImage3D::AllocateFromTexture3D(), and BIAS::glfFramebufferObject::AttachTexture().

int glfTexture::NextPowerOfTwo ( int  i)
staticprotected

Returns the smallest power of two that is greater than i.

Definition at line 269 of file glfTexture.cpp.

Referenced by BIAS::glfCubeMap::Allocate(), BIAS::glfTexture2D::Allocate(), BIAS::glfCubeMap::UploadImage(), and BIAS::glfTexture2D::UploadImage().

void glfTexture::SetBaseLevel ( int  baseLevel)

Sets the minimum (base) mip map level to be used.

Definition at line 137 of file glfTexture.cpp.

References Bind(), and target_.

void glfTexture::SetBorderColor ( GLfloat  r,
GLfloat  g,
GLfloat  b,
GLfloat  a 
)

Sets the border color for the texture to be used.

Definition at line 153 of file glfTexture.cpp.

References Bind(), and target_.

void glfTexture::SetGenerateMipMap ( bool  generateMipMap)

Sets whether to automatically generate mipmaps when the first mipmap is uploaded.

Definition at line 129 of file glfTexture.cpp.

References Bind(), and target_.

void glfTexture::SetMagFilter ( GLenum  magFilter)

Sets the magnification function.

Valid values are: GL_NEAREST, GL_LINEAR.

Examples:
ExampleMultisampleBlit.cpp.

Definition at line 97 of file glfTexture.cpp.

References Bind(), and target_.

Referenced by BIAS::OutputLensDistortion::CreateLookupTable(), BIAS::DistortionRendering::Init(), BIAS::glfTexture3D::Set(), and BIAS::glfTexture2D::Set().

void glfTexture::SetMaxLevel ( int  maxLevel)

Sets the maximum mip map level to be used.

Definition at line 145 of file glfTexture.cpp.

References Bind(), and target_.

void glfTexture::SetMinFilter ( GLenum  minFilter)

Sets the minifying function.

Valid values are: GL_NEAREST, GL_LINEAR, GL_NEAREST_MIPMAP_NEAREST, GL_LINEAR_MIPMAP_NEAREST, GL_NEAREST_MIPMAP_LINEAR, GL_LINEAR_MIPMAP_LINEAR.

Examples:
ExampleMultisampleBlit.cpp.

Definition at line 89 of file glfTexture.cpp.

References Bind(), and target_.

Referenced by BIAS::OutputLensDistortion::CreateLookupTable(), BIAS::DistortionRendering::Init(), BIAS::glfTexture3D::Set(), and BIAS::glfTexture2D::Set().

void glfTexture::SetTextureNr ( GLint  textureNr)

Sets the OpenGL texture number (GL_TEXTURE0 - GL_TEXTURE[MaxTextureUnit-1]).

Attention
For internal usage inside OpenGLFramework Base library only.

Definition at line 207 of file glfTexture.cpp.

References GetMaxSupportedTextureUnits(), MAX_TEXTURE_UNITS_, and textureNr_.

Referenced by BIAS::OutputLensDistortion::CreateLookupTable(), BIAS::glfTexture3D::Set(), and BIAS::glfTexture2D::Set().

void glfTexture::SetTextureNrInUniformFormat ( int  textureNr)

Sets the OpenGL texture number (0 - MaxTextureUnit-1).

Definition at line 224 of file glfTexture.cpp.

References GetMaxSupportedTextureUnits(), MAX_TEXTURE_UNITS_, and textureNr_.

void glfTexture::SetWrapR ( GLenum  wrapR)

Sets the wrapping mode for the 3rd texture coordinate.

See Also
TextureParameters::SetWrapS.

Definition at line 121 of file glfTexture.cpp.

References Bind(), and target_.

void glfTexture::SetWrapS ( GLenum  wrapS)

Sets the wrapping mode for the 1st texture coordinate.

Valid values are: GL_CLAMP, GL_CLAMP_TO_BORDER, GL_CLAMP_TO_EDGE, GL_MIRRORED_REPEAT, GL_REPEAT.

Examples:
ExampleMultisampleBlit.cpp.

Definition at line 105 of file glfTexture.cpp.

References Bind(), and target_.

Referenced by BIAS::OutputLensDistortion::CreateLookupTable(), BIAS::DistortionRendering::Init(), BIAS::glfTexture3D::Set(), and BIAS::glfTexture2D::Set().

void glfTexture::SetWrapT ( GLenum  wrapT)

Sets the wrapping mode for the 2nd texture coordinate.

See Also
TextureParameters::SetWrapS.
Examples:
ExampleMultisampleBlit.cpp.

Definition at line 113 of file glfTexture.cpp.

References Bind(), and target_.

Referenced by BIAS::OutputLensDistortion::CreateLookupTable(), BIAS::DistortionRendering::Init(), BIAS::glfTexture3D::Set(), and BIAS::glfTexture2D::Set().

Friends And Related Function Documentation

BIASOpenGLFramework_EXPORT void SwapGLObjects ( glfTexture A,
glfTexture B 
)
friend

Swap the GL object IDs.

Will throw an exception if one texture has id 0 or if textures have different targets.

Author
bartczak 03/2009

Definition at line 31 of file glfTexture.cpp.

Member Data Documentation

bool BIAS::glfTexture::enlargeToPot_
protected
GLuint BIAS::glfTexture::id_
protected

Definition at line 242 of file glfTexture.hh.

Referenced by Bind(), BindTU(), Create(), glfTexture(), BIAS::SwapGLObjects(), and ~glfTexture().

int BIAS::glfTexture::MAX_TEXTURE_UNITS_
protected

Definition at line 245 of file glfTexture.hh.

Referenced by SetTextureNr(), and SetTextureNrInUniformFormat().

GLenum BIAS::glfTexture::target_
protected
GLint BIAS::glfTexture::textureNr_
protected

Definition at line 244 of file glfTexture.hh.

Referenced by BindTU(), glfTexture(), SetTextureNr(), and SetTextureNrInUniformFormat().


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