25 #include "glfCubeMap.hh"
26 #include "glfException.hh"
27 #include <Base/Image/ImageIO.hh>
28 #include "glfFormatDB.hh"
33 const int BORDER_WIDTH = 0;
40 GLenum internalFormat,
int mipmap)
47 image.
Pad(paddedImage, potWidth, potHeight);
48 UploadImage(target, paddedImage, internalFormat, mipmap);
54 if (internalFormat == 0) {
64 glTexImage2D(target, mipmap, internalFormat,
68 GLF_THROW_ON_OPENGL_ERROR;
72 GLenum internalFormat,
int mipmap)
76 GLF_THROW_EXCEPTION(
"Could not load image: " << fileName);
80 GLF_THROW_ON_OPENGL_ERROR;
84 GLenum internalFormat,
int mipmap)
96 for (
int i = 0; i < 6; i++) {
97 glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, mipmap,
98 internalFormat, width, height, BORDER_WIDTH,
99 format, GL_UNSIGNED_BYTE, NULL);
102 GLF_THROW_ON_OPENGL_ERROR;
111 Allocate(width, height, internalFormat, mipmap);
119 GLenum internalFormat;
120 glGetTexLevelParameteriv(target, mipmap,
121 GL_TEXTURE_INTERNAL_FORMAT,
122 (GLint*)&internalFormat);
138 image.
Init(width, height, numChannels, storageType);
144 glGetTexImage(target, mipmap, format, type, image.
GetImageData());
146 GLF_THROW_ON_OPENGL_ERROR;
150 GLenum format,
int mipmap)
168 case GL_LUMINANCE_ALPHA:
180 GLF_THROW_EXCEPTION(
"Invalid format for CopyToImage");
189 image.
Init(width, height, numChannels, storageType);
195 glGetTexImage(target, mipmap, format, type, image.
GetImageData());
197 GLF_THROW_ON_OPENGL_ERROR;
204 glGetTexLevelParameteriv(
target_, mipmap, GL_TEXTURE_WIDTH, &width);
205 GLF_THROW_ON_OPENGL_ERROR;
213 glGetTexLevelParameteriv(
target_, mipmap, GL_TEXTURE_HEIGHT, &height);
214 GLF_THROW_ON_OPENGL_ERROR;
EColorModel
These are the most often used color models.
static int NextPowerOfTwo(int i)
Returns the smallest power of two that is greater than i.
bool IsEmpty() const
check if ImageData_ points to allocated image buffer or not
void Bind() const
Binds the texture.
unsigned int GetWidth() const
void UploadImageFromFile(GLenum target, const std::string &fileName, GLenum internalFormat=0, int mipmap=0)
Uploads an image loaded from a file to a mipmap of one side of the cube map.
const void * GetImageData() const
void Allocate(int width, int height, GLenum internalFormat, int mipmap=0)
Creates a cube map with undefined content.
int Pad(BIAS::ImageBase &dest, const unsigned int &newwidth, const unsigned int &newheight, const int &padVal=0) const
void CopyChannelsToImage(GLenum target, ImageBase &image, GLenum format, int mipmap=0)
Copies the pixels of a mipmap of a side of the cube map to a BIAS::ImageBase and interprets the textu...
unsigned int GetHeight() const
int GetHeight(int mipmap=0) const
Returns the height of a mipmap of each side of the cube map.
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...
enum EStorageType GetStorageType() const
int GetWidth(int mipmap=0) const
Returns the width of a mipmap of each side of the cube map.
void UploadImage(GLenum target, const BIAS::ImageBase &image, GLenum internalFormat=0, int mipmap=0)
Uploads a BIAS::Image to a mipmap of one side of the cube map.
void CopyToImage(GLenum target, ImageBase &image, int mipmap=0)
Copies the pixels of a mipmap of a side of the cube map to a BIAS::ImageBase.
This is the base class for images in BIAS.