63 _name(name), _type(type),
_width(0),
_height(0), _deswizzle(deswizzle) {
65 set(name, image, type, txi, deswizzle);
128 e.
add(
"Failed to reload texture \"%s\" (%d)",
_name.
c_str(), type);
143 return _image->dumpTGA(fileName);
164 if (
_image->isCubeMap()) {
173 glTexParameteri(target, GL_TEXTURE_WRAP_S, wrapModeX);
174 glTexParameteri(target, GL_TEXTURE_WRAP_T, wrapModeY);
183 switch (
_image->getFormatRaw()) {
213 glPixelStorei(GL_UNPACK_ALIGNMENT, alignment);
220 glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
221 glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
223 glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
224 glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
229 if (
_image->getMipMapCount() == 1) {
232 glTexParameteri(target, GL_GENERATE_MIPMAP, GL_TRUE);
233 glTexParameteri(target, GL_TEXTURE_BASE_LEVEL, 0);
234 glTexParameteri(target, GL_TEXTURE_MAX_LEVEL, 9);
238 glTexParameteri(target, GL_GENERATE_MIPMAP, GL_FALSE);
239 glTexParameteri(target, GL_TEXTURE_BASE_LEVEL, 0);
240 glTexParameteri(target, GL_TEXTURE_MAX_LEVEL,
_image->getMipMapCount() - 1);
247 if (
_image->isCompressed()) {
251 glTexImage2D(target, mipMap,
_image->getFormatRaw(),
261 setWrap(GL_TEXTURE_2D, GL_REPEAT, GL_REPEAT);
273 for (
size_t i = 0; i <
_image->getMipMapCount(); i++)
279 glBindTexture(GL_TEXTURE_CUBE_MAP,
_textureID);
282 setWrap(GL_TEXTURE_CUBE_MAP, GL_REPEAT, GL_REPEAT);
293 assert(
_image->getLayerCount() == 6);
295 static const GLenum faceTarget[6] = {
296 GL_TEXTURE_CUBE_MAP_POSITIVE_X,
297 GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
298 GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
299 GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
300 GL_TEXTURE_CUBE_MAP_POSITIVE_Z,
301 GL_TEXTURE_CUBE_MAP_NEGATIVE_Z
305 for (
size_t i = 0; i <
_image->getLayerCount(); i++)
306 for (
size_t j = 0; j <
_image->getMipMapCount(); j++)
313 texture =
new PLTFile(name, *imageStream);
336 for (
size_t i = 0; i < 6; i++) {
342 layers[i] =
loadImage(imageStream, type, txi, deswizzle);
359 image =
loadImage(imageStream, type, txi, deswizzle);
366 for (
size_t i = 0; i <
ARRAYSIZE(layers); i++)
369 e.
add(
"Failed to create texture \"%s\" (%d)", name.
c_str(), type);
373 return new Texture(name, image, type, txi, deswizzle);
383 return new Texture(
"", image, type, txi, deswizzle);
387 TXI *txi,
bool deswizzle) {
423 return loadImage(name, type, 0, deswizzle);
427 TXI *txi,
bool deswizzle) {
430 if (!isFileCubeMap) {
435 return loadImage(imageStream, type, txi, deswizzle);
441 for (
size_t i = 0; i < 6; i++) {
447 layers[i] =
loadImage(imageStream, type, txi, deswizzle);
453 for (
size_t i = 0; i <
ARRAYSIZE(layers); i++)
461 TXI *txi,
bool deswizzle) {
470 image =
new TGA(*imageStream, isCubeMap);
472 image =
new DDS(*imageStream);
474 image =
new TPC(*imageStream);
476 image =
new TXB(*imageStream);
478 image =
new SBM(*imageStream, deswizzle);
488 if (
GfxMan.needManualDeS3TC())
509 txi =
new TXI(*txiStream);
#define ResMan
Shortcut for accessing the sound manager.
static const TXI kEmptyTXI
Generic image decoder interface.
Inter-thread request events.
void add(const char *s,...) GCC_PRINTF(2
DDS texture (DirectDraw Surface or BioWare's own format) loading).
The global graphics manager.
const TXI & getTXI() const
Return the TXI.
A class holding an UTF-8 string.
static Texture * createPLT(const Common::UString &name, Common::SeekableReadStream *imageStream)
void setMipMapData(GLenum target, size_t layer, size_t mipMap)
UString composeString(T value)
Convert any POD integer, float/double or bool type into a string.
static Texture * create(const Common::UString &name, bool deswizzle=false)
Create a texture from this image resource.
Common::ScopedArray< byte > data
The mip map's data.
static TXI * loadTXI(const Common::UString &name)
#define ARRAYSIZE(x)
Macro which determines the number of entries in a fixed size array.
void addToQueue(QueueType queue)
Utility templates and functions for working with strings and streams.
int height
The mip map's height.
Exception that provides a stack of explanations.
void decompress()
Manually decompress the texture image data.
void exceptionDispatcherWarning(const char *s,...)
Exception dispatcher that prints the exception as a warning, and adds another reason on top...
const ImageDecoder & getImage() const
Return the image.
Basic exceptions to throw.
Font, character bitmap data.
const char * c_str() const
Return the (utf8 encoded) string data.
BioWare's own texture format, TPC.
Common::ScopedPtr< TXI > _txi
The TXI.
Utility templates and functions.
void set(const Common::UString &name, ImageDecoder *image, ::Aurora::FileType type, TXI *txi, bool deswizzle=false)
static ImageDecoder * loadImage(const Common::UString &name, bool deswizzle=false)
Load an image in any of the common texture formats.
TXB (another one of BioWare's own texture formats) loading.
A class creating a cube map by combining six images.
bool empty() const
Is the string empty?
Low-level type definitions to handle fixed width types portably.
void setFilter(GLenum target)
Common::UString _name
The name of the texture's image's file.
RequestList::iterator RequestID
Our very own intermediate texture format.
void removeFromQueue(QueueType queue)
Basic reading stream interfaces.
Decoding SBM (font bitmap data).
virtual bool isDynamic() const
Is this a dynamic texture, or a shared static one?
TextureID _textureID
OpenGL texture ID.
PointerType get() const
Returns the plain pointer value.
bool dumpTGA(const Common::UString &fileName) const
Dump the texture into a TGA.
int width
The mip map's width.
Decoding TGA (TarGa) images.
A texture as used in the Aurora engines.
FileType
Various file types used by the Aurora engine and found in archives.
TPC (BioWare's own texture format) loading.
Image, Truevision TARGA image.
A generic interface for image decoders.
Another one of BioWare's own texture formats, TXB.
virtual bool reload()
Try to reload the texture.
const Features & getFeatures() const
void setMipMaps(GLenum target)
size_t getMipMapCount() const
Return the number of mip maps contained in the image.
void createCubeMapTexture()
::Aurora::FileType _type
The type of the texture's image's file.
uint32 size
The mip map's size in bytes.
Interface for a seekable & readable data stream.
Texture, DirectDraw Surface.
BioWare's Packed Layered Texture.
#define GfxMan
Shortcut for accessing the graphics manager.
The global resource manager for Aurora resources.
void setWrap(GLenum target, GLint wrapModeX, GLint wrapModeY)
PFNGLCOMPRESSEDTEXIMAGE2DPROC glCompressedTexImage2D
Common::ScopedPtr< ImageDecoder > _image
The actual image.