Basic Image AlgorithmS Library
2.8.0
|
A 2D texture. More...
#include <OpenGLFramework/Base/glfTexture2D.hh>
Public Member Functions | |
void | Allocate (int width, int height, GLenum internalFormat, int mipmap=0) |
Creates a texture with undefined content. More... | |
void | Allocate (int width, int height, ImageBase::EStorageType storageType, ImageBase::EColorModel colorModel, int mipmap=0) |
Creates a texture with undefined content. More... | |
void | Bind () const |
Binds the texture. More... | |
void | BindTU () const |
Binds the texture. More... | |
void | BindTU (int number) const |
Binds the texture. More... | |
void | CopyChannelsToImage (ImageBase &image, GLenum format, int mipmap=0) |
Copies the pixels of a mipmap of the texture to a BIAS::ImageBase and interprets the texture using the given format. More... | |
void | CopyToImage (ImageBase &image, int mipmap=0) |
Copies the pixels of a mipmap of the texture to a BIAS::ImageBase. More... | |
void | Create () |
Creates the texture but does not upload any data yet. More... | |
void | DumpUC_RGBA (const std::string &fileName) |
Uses CopyToImage to dump a Unsigned Char image comprising RGBA channels to file. 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... | |
int | GetHeight (int mipmap=0) const |
Returns the height of a mipmap of the texture. 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... | |
int | GetWidth (int mipmap=0) const |
Returns the width of a mipmap of the texture. More... | |
glfTexture2D () | |
void | Set (GLenum minFilter=GL_NEAREST, GLenum magFilter=GL_NEAREST, GLenum wrapS=GL_CLAMP, GLenum wrapT=GL_CLAMP, GLint textureNr=GL_TEXTURE0) |
Convenience wrapper. 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... | |
void | UploadImage (const BIAS::ImageBase &image, GLenum internalFormat=0, int mipmap=0) |
Uploads a BIAS::Image to a mipmap of the texture. More... | |
void | UploadImageFromFile (const std::string &fileName, GLenum internalFormat=0, int mipmap=0) |
Uploads an image loaded from a file to a mipmap of the texture. More... | |
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_ |
A 2D texture.
Allocate
methods need not be called, if one of the Upload...
methods is used.Definition at line 40 of file glfTexture2D.hh.
glfTexture2D::glfTexture2D | ( | ) |
Definition at line 36 of file glfTexture2D.cpp.
void glfTexture2D::Allocate | ( | int | width, |
int | height, | ||
GLenum | internalFormat, | ||
int | mipmap = 0 |
||
) |
Creates a texture with undefined content.
This can be used for textures in conjuction with framebuffer objects.
See glTexImage2D
documentation for a list of valid internal formats.
Definition at line 120 of file glfTexture2D.cpp.
References BIAS::glfTexture::Bind(), BIAS::glfTexture::enlargeToPot_, BIAS::glfFormatDB::GetFormatForInternalFormat(), BIAS::glfTexture::NextPowerOfTwo(), and BIAS::glfTexture::target_.
Referenced by Allocate(), BIAS::Texture2DPool::Create(), and BIAS::DistortionRendering::Init().
void glfTexture2D::Allocate | ( | int | width, |
int | height, | ||
ImageBase::EStorageType | storageType, | ||
ImageBase::EColorModel | colorModel, | ||
int | mipmap = 0 |
||
) |
Creates a texture with undefined content.
This can be used for textures in conjuction with framebuffer objects.
The internal format is chosen based on the given BIAS storage type and color model.
Definition at line 145 of file glfTexture2D.cpp.
References Allocate(), and BIAS::glfFormatDB::ProposeInternalFormat().
|
inherited |
Binds the texture.
Definition at line 242 of file glfTexture.cpp.
References BIAS::glfTexture::id_, and BIAS::glfTexture::target_.
Referenced by BIAS::glfCubeMap::Allocate(), Allocate(), BIAS::glfTexture3D::Allocate3DImage(), BIAS::glfCubeMap::CopyChannelsToImage(), CopyChannelsToImage(), BIAS::glfCubeMap::CopyToImage(), CopyToImage(), BIAS::glfTexture::GenerateMipMap(), BIAS::glfCubeMap::GetHeight(), GetHeight(), BIAS::glfCubeMap::GetWidth(), GetWidth(), BIAS::glfTexture::SetBaseLevel(), BIAS::glfTexture::SetBorderColor(), BIAS::glfTexture::SetGenerateMipMap(), BIAS::glfTexture::SetMagFilter(), BIAS::glfTexture::SetMaxLevel(), BIAS::glfTexture::SetMinFilter(), BIAS::glfTexture::SetWrapR(), BIAS::glfTexture::SetWrapS(), BIAS::glfTexture::SetWrapT(), BIAS::TriangleMeshSplatRendering::Splat(), BIAS::glfTexture3D::Upload2DImage(), BIAS::glfCubeMap::UploadImage(), and UploadImage().
|
inherited |
Binds the texture.
Set texture active. Use this for multitexturing shaders without the use of a glfbatch.
Definition at line 249 of file glfTexture.cpp.
References BIAS::glfTexture::id_, BIAS::glfTexture::target_, and BIAS::glfTexture::textureNr_.
Referenced by BIAS::OutputLensDistortion::Draw_().
|
inherited |
Binds the texture.
Sets the texture active with GL_TEXTURE0+number, before binding
Definition at line 259 of file glfTexture.cpp.
References BIAS::glfTexture::id_, and BIAS::glfTexture::target_.
void glfTexture2D::CopyChannelsToImage | ( | BIAS::ImageBase & | image, |
GLenum | format, | ||
int | mipmap = 0 |
||
) |
Copies the pixels of a mipmap of the texture to a BIAS::ImageBase and interprets the texture using the given format.
Can be used to only copy one channel of the texture to an image. Valid formats are: GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA, GL_RGB, GL_BGR, GL_RGBA, GL_BGRA, GL_LUMINANCE, GL_LUMINANCE_ALPHA
Definition at line 192 of file glfTexture2D.cpp.
References BIAS::glfTexture::Bind(), BIAS::glfFormatDB::ChannelsFromGLFormat(), GetHeight(), BIAS::ImageBase::GetImageData(), BIAS::glfFormatDB::GetPixelTypeForStorageType(), BIAS::ImageBase::GetStorageType(), GetWidth(), BIAS::ImageBase::Init(), BIAS::ImageBase::IsEmpty(), BIAS::ImageBase::Release(), and BIAS::glfTexture::target_.
Referenced by BIAS::SimpleMultiPassFragmentShader::CopyChannelsToImage().
void glfTexture2D::CopyToImage | ( | ImageBase & | image, |
int | mipmap = 0 |
||
) |
Copies the pixels of a mipmap of the texture to a BIAS::ImageBase.
The image will be initialized with the size of the texture and the appropriate number of channels based on the textures internal format.
Definition at line 154 of file glfTexture2D.cpp.
References BIAS::glfTexture::Bind(), BIAS::ImageBase::GetChannelCount(), BIAS::glfFormatDB::GetFormatForInternalFormat(), GetHeight(), BIAS::ImageBase::GetHeight(), BIAS::ImageBase::GetImageData(), BIAS::glfFormatDB::GetPixelTypeForStorageType(), BIAS::ImageBase::GetStorageType(), GetWidth(), BIAS::ImageBase::GetWidth(), BIAS::ImageBase::Init(), and BIAS::glfTexture::target_.
Referenced by BIAS::SimpleMultiPassFragmentShader::CopyToImage(), and DumpUC_RGBA().
|
inherited |
Creates the texture but does not upload any data yet.
Definition at line 80 of file glfTexture.cpp.
References BIAS::glfTexture::id_.
Referenced by BIAS::Texture2DPool::Create(), BIAS::OutputLensDistortion::CreateLookupTable(), BIAS::FramebufferSetupPool::CreateSetup(), BIAS::DistortionRendering::Init(), BIAS::MultipleDepthWarp::Init(), BIAS::TemplateSpecializedBatch::InitTextureData_(), BIAS::MultipleDepthWarp::SetupNViewsWarp(), and BIAS::Texture2DPool::UploadImage().
void glfTexture2D::DumpUC_RGBA | ( | const std::string & | fileName | ) |
Uses CopyToImage to dump a Unsigned Char image comprising RGBA channels to file.
Definition at line 243 of file glfTexture2D.cpp.
References CopyToImage(), and BIAS::ImageIO::Save().
|
inherited |
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 BIAS::glfTexture::enlargeToPot_.
|
inherited |
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 BIAS::glfTexture::Bind(), and BIAS::glfTexture::target_.
Referenced by BIAS::DistortionRendering::EndRendering(), and BIAS::DistortionRendering::Init().
int glfTexture2D::GetHeight | ( | int | mipmap = 0 | ) | const |
Returns the height of a mipmap of the texture.
Definition at line 233 of file glfTexture2D.cpp.
References BIAS::glfTexture::Bind(), and BIAS::glfTexture::target_.
Referenced by CopyChannelsToImage(), CopyToImage(), BIAS::SimpleMultiPassFragmentShader::Execute(), BIAS::SeparableBilateralFilter::SetColorAndSourceAndDest(), and BIAS::TriangleMeshSplatRendering::Splat().
|
staticprotectedinherited |
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.
Returns the OpenGL pixel type (GL_UNSIGNED_BYTE etc.) for a BIAS storage type.
Returns the OpenGL pixel format (GL_RGB etc.) for a BIAS color model.
cp from glfBatch
Definition at line 185 of file glfTexture.cpp.
Referenced by BIAS::glfTexture::SetTextureNr(), and BIAS::glfTexture::SetTextureNrInUniformFormat().
|
inlineinherited |
Returns the OpenGL texture id.
Definition at line 144 of file glfTexture.hh.
Referenced by BIAS::clfImage2D::AllocateFromTexture2D(), BIAS::clfImage3D::AllocateFromTexture3D(), and BIAS::glfFramebufferObject::AttachTexture().
|
inlineinherited |
Returns the OpenGL texture number.
Definition at line 156 of file glfTexture.hh.
|
inlineinherited |
Returns the OpenGL texture number in uniform format or -1 for error.
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_().
|
inlineinherited |
Returns the OpenGL texture target.
Definition at line 150 of file glfTexture.hh.
Referenced by BIAS::clfImage2D::AllocateFromTexture2D(), BIAS::clfImage3D::AllocateFromTexture3D(), and BIAS::glfFramebufferObject::AttachTexture().
int glfTexture2D::GetWidth | ( | int | mipmap = 0 | ) | const |
Returns the width of a mipmap of the texture.
Definition at line 223 of file glfTexture2D.cpp.
References BIAS::glfTexture::Bind(), and BIAS::glfTexture::target_.
Referenced by CopyChannelsToImage(), CopyToImage(), BIAS::SimpleMultiPassFragmentShader::Execute(), BIAS::SeparableBilateralFilter::SetColorAndSourceAndDest(), BIAS::SeparabelBoxFilter::SetSourceAndDest(), and BIAS::TriangleMeshSplatRendering::Splat().
|
staticprotectedinherited |
Returns the smallest power of two that is greater than i
.
Definition at line 269 of file glfTexture.cpp.
Referenced by BIAS::glfCubeMap::Allocate(), Allocate(), BIAS::glfCubeMap::UploadImage(), and UploadImage().
void glfTexture2D::Set | ( | GLenum | minFilter = GL_NEAREST , |
GLenum | magFilter = GL_NEAREST , |
||
GLenum | wrapS = GL_CLAMP , |
||
GLenum | wrapT = GL_CLAMP , |
||
GLint | textureNr = GL_TEXTURE0 |
||
) |
Convenience wrapper.
Definition at line 57 of file glfTexture2D.cpp.
References BIAS::glfTexture::SetMagFilter(), BIAS::glfTexture::SetMinFilter(), BIAS::glfTexture::SetTextureNr(), BIAS::glfTexture::SetWrapS(), and BIAS::glfTexture::SetWrapT().
Referenced by BIAS::Texture2DPool::Create(), BIAS::TemplateSpecializedBatch::InitTextureData_(), and BIAS::Texture2DPool::UploadImage().
|
inherited |
Sets the minimum (base) mip map level to be used.
Definition at line 137 of file glfTexture.cpp.
References BIAS::glfTexture::Bind(), and BIAS::glfTexture::target_.
|
inherited |
Sets the border color for the texture to be used.
Definition at line 153 of file glfTexture.cpp.
References BIAS::glfTexture::Bind(), and BIAS::glfTexture::target_.
|
inherited |
Sets whether to automatically generate mipmaps when the first mipmap is uploaded.
Definition at line 129 of file glfTexture.cpp.
References BIAS::glfTexture::Bind(), and BIAS::glfTexture::target_.
|
inherited |
Sets the magnification function.
Valid values are: GL_NEAREST, GL_LINEAR.
Definition at line 97 of file glfTexture.cpp.
References BIAS::glfTexture::Bind(), and BIAS::glfTexture::target_.
Referenced by BIAS::OutputLensDistortion::CreateLookupTable(), BIAS::DistortionRendering::Init(), BIAS::glfTexture3D::Set(), and Set().
|
inherited |
Sets the maximum mip map level to be used.
Definition at line 145 of file glfTexture.cpp.
References BIAS::glfTexture::Bind(), and BIAS::glfTexture::target_.
|
inherited |
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.
Definition at line 89 of file glfTexture.cpp.
References BIAS::glfTexture::Bind(), and BIAS::glfTexture::target_.
Referenced by BIAS::OutputLensDistortion::CreateLookupTable(), BIAS::DistortionRendering::Init(), BIAS::glfTexture3D::Set(), and Set().
|
inherited |
Sets the OpenGL texture number (GL_TEXTURE0 - GL_TEXTURE[MaxTextureUnit-1]).
Definition at line 207 of file glfTexture.cpp.
References BIAS::glfTexture::GetMaxSupportedTextureUnits(), BIAS::glfTexture::MAX_TEXTURE_UNITS_, and BIAS::glfTexture::textureNr_.
Referenced by BIAS::OutputLensDistortion::CreateLookupTable(), BIAS::glfTexture3D::Set(), and Set().
|
inherited |
Sets the OpenGL texture number (0 - MaxTextureUnit-1).
Definition at line 224 of file glfTexture.cpp.
References BIAS::glfTexture::GetMaxSupportedTextureUnits(), BIAS::glfTexture::MAX_TEXTURE_UNITS_, and BIAS::glfTexture::textureNr_.
|
inherited |
Sets the wrapping mode for the 3rd texture coordinate.
Definition at line 121 of file glfTexture.cpp.
References BIAS::glfTexture::Bind(), and BIAS::glfTexture::target_.
|
inherited |
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.
Definition at line 105 of file glfTexture.cpp.
References BIAS::glfTexture::Bind(), and BIAS::glfTexture::target_.
Referenced by BIAS::OutputLensDistortion::CreateLookupTable(), BIAS::DistortionRendering::Init(), BIAS::glfTexture3D::Set(), and Set().
|
inherited |
Sets the wrapping mode for the 2nd texture coordinate.
Definition at line 113 of file glfTexture.cpp.
References BIAS::glfTexture::Bind(), and BIAS::glfTexture::target_.
Referenced by BIAS::OutputLensDistortion::CreateLookupTable(), BIAS::DistortionRendering::Init(), BIAS::glfTexture3D::Set(), and Set().
void glfTexture2D::UploadImage | ( | const BIAS::ImageBase & | image, |
GLenum | internalFormat = 0 , |
||
int | mipmap = 0 |
||
) |
Uploads a BIAS::Image to a mipmap of the texture.
If the given internalFormat
is 0, the internal format is chosen based on the storage type and color model of the image.
Definition at line 68 of file glfTexture2D.cpp.
References BIAS::glfTexture::Bind(), BIAS::glfTexture::enlargeToPot_, BIAS::ImageBase::GetColorModel(), BIAS::glfFormatDB::GetFormatForColorModel(), BIAS::ImageBase::GetHeight(), BIAS::ImageBase::GetImageData(), BIAS::glfFormatDB::GetPixelTypeForStorageType(), BIAS::ImageBase::GetStorageType(), BIAS::ImageBase::GetWidth(), BIAS::glfTexture::NextPowerOfTwo(), BIAS::ImageBase::Pad(), BIAS::glfFormatDB::ProposeInternalFormat(), and BIAS::glfTexture::target_.
Referenced by BIAS::Texture2DPool::Create(), BIAS::OutputLensDistortion::CreateLookupTable(), BIAS::DistortionRendering::Init(), BIAS::Texture2DPool::UploadImage(), UploadImageFromFile(), and BIAS::TemplateSpecializedBatch::UploadTextureImage().
void glfTexture2D::UploadImageFromFile | ( | const std::string & | fileName, |
GLenum | internalFormat = 0 , |
||
int | mipmap = 0 |
||
) |
Uploads an image loaded from a file to a mipmap of the texture.
If the given internalFormat
is 0, the internal format is chosen based on the storage type and color model of the image.
Definition at line 106 of file glfTexture2D.cpp.
References BIAS::ImageIO::Load(), and UploadImage().
|
protectedinherited |
Definition at line 246 of file glfTexture.hh.
Referenced by BIAS::glfCubeMap::Allocate(), Allocate(), BIAS::glfTexture::EnlargeToPowerOfTwoIfRequired(), BIAS::glfTexture::glfTexture(), BIAS::glfCubeMap::UploadImage(), and UploadImage().
|
protectedinherited |
Definition at line 242 of file glfTexture.hh.
Referenced by BIAS::glfTexture::Bind(), BIAS::glfTexture::BindTU(), BIAS::glfTexture::Create(), BIAS::glfTexture::glfTexture(), BIAS::SwapGLObjects(), and BIAS::glfTexture::~glfTexture().
|
protectedinherited |
Definition at line 245 of file glfTexture.hh.
Referenced by BIAS::glfTexture::SetTextureNr(), and BIAS::glfTexture::SetTextureNrInUniformFormat().
|
protectedinherited |
Definition at line 243 of file glfTexture.hh.
Referenced by Allocate(), BIAS::glfTexture3D::Allocate3DImage(), BIAS::glfTexture::Bind(), BIAS::glfTexture::BindTU(), CopyChannelsToImage(), CopyToImage(), BIAS::glfTexture::GenerateMipMap(), BIAS::glfCubeMap::GetHeight(), GetHeight(), BIAS::glfCubeMap::GetWidth(), GetWidth(), BIAS::glfTexture::glfTexture(), BIAS::glfTexture::SetBaseLevel(), BIAS::glfTexture::SetBorderColor(), BIAS::glfTexture::SetGenerateMipMap(), BIAS::glfTexture::SetMagFilter(), BIAS::glfTexture::SetMaxLevel(), BIAS::glfTexture::SetMinFilter(), BIAS::glfTexture::SetWrapR(), BIAS::glfTexture::SetWrapS(), BIAS::glfTexture::SetWrapT(), BIAS::SwapGLObjects(), and UploadImage().
|
protectedinherited |
Definition at line 244 of file glfTexture.hh.
Referenced by BIAS::glfTexture::BindTU(), BIAS::glfTexture::glfTexture(), BIAS::glfTexture::SetTextureNr(), and BIAS::glfTexture::SetTextureNrInUniformFormat().