25 #include "glfTexture2D.hh"
26 #include "glfException.hh"
27 #include <Base/Image/ImageIO.hh>
28 #include "glfFormatDB.hh"
30 #include <Gui/biasgl.h>
34 const int BORDER_WIDTH = 0;
58 GLenum wrapT, GLint textureNr)
79 image.
Pad(paddedImage, potWidth, potHeight);
86 if (internalFormat == 0)
98 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
102 GLF_THROW_ON_OPENGL_ERROR;
107 GLenum internalFormat,
int mipmap)
112 GLF_THROW_EXCEPTION(
"Could not load image: " << fileName);
116 GLF_THROW_ON_OPENGL_ERROR;
134 GLenum type = GL_UNSIGNED_BYTE;
135 if (internalFormat == GL_DEPTH24_STENCIL8_EXT)
136 type = GL_UNSIGNED_INT_24_8_EXT;
138 glTexImage2D(
target_, mipmap, internalFormat, width, height, BORDER_WIDTH,
141 GLF_THROW_ON_OPENGL_ERROR;
150 Allocate(width, height, internalFormat, mipmap);
159 GLenum internalFormat;
160 glGetTexLevelParameteriv(
target_, mipmap, GL_TEXTURE_INTERNAL_FORMAT,
161 (GLint*) &internalFormat);
178 image.
Init(width, height, numChannels, storageType);
184 glPixelStorei(GL_PACK_ALIGNMENT, 1);
188 GLF_THROW_ON_OPENGL_ERROR;
210 image.
Init(width, height, numChannels, storageType);
215 glPixelStorei(GL_PACK_ALIGNMENT, 1);
219 GLF_THROW_ON_OPENGL_ERROR;
227 glGetTexLevelParameteriv(
target_, mipmap, GL_TEXTURE_WIDTH, &width);
228 GLF_THROW_ON_OPENGL_ERROR;
237 glGetTexLevelParameteriv(
target_, mipmap, GL_TEXTURE_HEIGHT, &height);
238 GLF_THROW_ON_OPENGL_ERROR;
EColorModel
These are the most often used color models.
void DumpUC_RGBA(const std::string &fileName)
Uses CopyToImage to dump a Unsigned Char image comprising RGBA channels to file.
void Allocate(int width, int height, GLenum internalFormat, int mipmap=0)
Creates a texture with undefined content.
static int NextPowerOfTwo(int i)
Returns the smallest power of two that is greater than i.
int GetWidth(int mipmap=0) const
Returns the width of a mipmap of the texture.
bool IsEmpty() const
check if ImageData_ points to allocated image buffer or not
void Bind() const
Binds the texture.
void SetWrapS(GLenum wrapS)
Sets the wrapping mode for the 1st texture coordinate.
void UploadImage(const BIAS::ImageBase &image, GLenum internalFormat=0, int mipmap=0)
Uploads a BIAS::Image to a mipmap of the texture.
void CopyToImage(ImageBase &image, int mipmap=0)
Copies the pixels of a mipmap of the texture to a BIAS::ImageBase.
unsigned int GetWidth() const
void SetMinFilter(GLenum minFilter)
Sets the minifying function.
const void * GetImageData() const
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.
int Pad(BIAS::ImageBase &dest, const unsigned int &newwidth, const unsigned int &newheight, const int &padVal=0) const
int GetHeight(int mipmap=0) const
Returns the height of a mipmap of the texture.
unsigned int GetChannelCount() const
returns the number of Color channels, e.g.
void SetWrapT(GLenum wrapT)
Sets the wrapping mode for the 2nd texture coordinate.
unsigned int GetHeight() const
static int Save(const std::string &filename, const ImageBase &img, const enum TFileFormat FileFormat=FF_auto, const bool sync=BIAS_DEFAULT_SYNC, const int c_jpeg_quality=BIAS_DEFAULT_IMAGE_QUALITY, const bool forceNewID=BIAS_DEFAULT_FORCENEWID, const bool &writeMetaData=true)
Export image as file using extrnal libs.
void Release(const bool reset_storage_type=false)
Free the allocated data structures Hands off: Do !!NOT!! change the default of reset_storage_type: Im...
enum EColorModel GetColorModel() const
void Init(unsigned int width, unsigned int height, unsigned int nChannels=1, enum EStorageType storageType=ST_unsignedchar, const bool interleaved=true)
Initialize image size and channels.
static int Load(const std::string &FileName, ImageBase &img)
first tries a call to Read MIP image and if that fails, tries to Import Image with all other availabl...
void Set(GLenum minFilter=GL_NEAREST, GLenum magFilter=GL_NEAREST, GLenum wrapS=GL_CLAMP, GLenum wrapT=GL_CLAMP, GLint textureNr=GL_TEXTURE0)
Convenience wrapper.
enum EStorageType GetStorageType() const
void SetTextureNr(GLint textureNr)
Sets the OpenGL texture number (GL_TEXTURE0 - GL_TEXTURE[MaxTextureUnit-1]).
This is the base class for images in BIAS.
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 th...
void SetMagFilter(GLenum magFilter)
Sets the magnification function.