30#include "CEGUI/Exceptions.h"
31#include "CEGUI/System.h"
32#include "CEGUI/ImageCodec.h"
90 RawDataContainer texFile;
91 System::getSingleton().getResourceProvider()->loadRawDataContainer(filename, texFile, resourceGroup);
94 System* sys = System::getSingletonPtr();
95 Divide::DIVIDE_ASSERT(sys,
"CEGUI::System object has not been created: unable to access ImageCodec.");
97 Texture* res = sys->getImageCodec().load(texFile,
this);
100 System::getSingleton().getResourceProvider()->unloadRawDataContainer(texFile);
102 Divide::DIVIDE_ASSERT(res, (sys->getImageCodec().getIdentifierString() +
" failed to load image '" + filename +
"'.").c_str());
107 Divide::DIVIDE_ASSERT(
isPixelFormatSupported(pixel_format),
"Data was supplied in an unsupported pixel format.");
155 static float maxSize = -1;
162 maxSize = float(GFXDevice::GetDeviceInformation()._maxTextureSize);
165 Divide::DIVIDE_ASSERT(!(
_size.d_width > maxSize ||
_size.d_height > maxSize),
"DVDTexture:: size too big");
176 size_t image_size = 0u;
179 size_t blocksize = 16;
186 image_size = size_t(std::ceil( area.getSize().d_width / 4 ) *
187 std::ceil( area.getSize().d_height / 4 ) *
202 image_size = size_t(area.getSize().d_width *
203 area.getSize().d_height) *
213 offset.
x = to_U16(area.left());
214 offset.
y = to_U16(area.top());
218 dimensions.
width = to_U16(area.getWidth());
219 dimensions.
height = to_U16(area.getHeight());
220 dimensions.
depth = 1u;
221 Get(
_texture)->replaceData( (
const Byte*)sourceData, image_size, offset, dimensions, pixelUnpackAlignment );
229 auto data = Get(
_texture)->readData(0u, pixelPackAlignment);
230 memcpy(targetData, data._data.data(), data._data.size());
237 thread_local size_t TEXTURE_IDX = 0u;
245 case Texture::PixelFormat::PF_RGB:
246 case Texture::PixelFormat::PF_RGB_565:
248 targetFormat = GFXImageFormat::RGB;
249 if (
_format == Texture::PixelFormat::PF_RGB_565 )
251 targetPacking = GFXImagePacking::RGB_565;
254 case Texture::PixelFormat::PF_RGBA:
255 case Texture::PixelFormat::PF_RGBA_4444:
257 targetFormat = GFXImageFormat::RGBA;
258 if (
_format == Texture::PixelFormat::PF_RGBA_4444 )
260 targetPacking = GFXImagePacking::RGBA_4444;
263 case Texture::PixelFormat::PF_RGB_DXT1:
265 targetFormat = GFXImageFormat::DXT1_RGB;
267 case Texture::PixelFormat::PF_RGBA_DXT1:
269 targetFormat = GFXImageFormat::DXT1_RGBA;
271 case Texture::PixelFormat::PF_RGBA_DXT3:
273 targetFormat = GFXImageFormat::DXT3_RGBA;
275 case Texture::PixelFormat::PF_RGBA_DXT5:
277 targetFormat = GFXImageFormat::DXT5_RGBA;
279 case Texture::PixelFormat::PF_PVRTC2:
280 case Texture::PixelFormat::PF_PVRTC4:
287 resDescriptor.waitForReady(
true );
291 texDescriptor.
_packing = targetPacking;
296 _texture = CreateResource( resDescriptor );
bool isPixelFormatSupported(PixelFormat fmt) const override
DVDTexture(CEGUIRenderer &owner, const String &name)
Basic constructor.
bool _isCompressed
Whether Texture format is a compressed format.
void updateCachedScaleValues()
updates cached scale value used to map pixels to texture co-ords.
Divide::Handle< Divide::Texture > _texture
The Divide texture used for storing this DVDTexture's data.
void blitFromMemory(const void *sourceData, const Rectf &area) override
void setTextureSize(const Sizef &sz)
set the size of the internal texture.
Divide::SamplerDescriptor _sampler
A Divide sampler hash used for sampling from this texture in shaders.
void setDVDTexture(Divide::Handle< Divide::Texture > tex, const Sizef &size)
set the Divide::Texture that this Texture is based on to the specified texture, with the specified si...
void loadFromMemory(const void *buffer, const Sizef &buffer_size, PixelFormat pixel_format) override
Sizef _dataSize
original size of pixel data loaded into texture
void generateDVDTexture()
generate the DVD texture and set some initial options.
void setTextureSize_impl(const Sizef &sz, PixelFormat format)
internal texture resize function (does not reset format or other fields)
void blitToMemory(void *targetData) override
void loadFromFile(const String &filename, const String &resourceGroup) override
PixelFormat _format
Texture format.
Sizef _size
Size of the texture.
Handle console commands that start with a forward slash.
GFXImageFormat _baseFormat
MipMappingState _mipMappingState
PropertyDescriptor< T > _propertyDescriptor
TextureFilter _minFilter
Texture filtering mode.
TextureWrap _wrapU
Texture wrap mode (Or S-R-T)
U8 _anisotropyLevel
The value must be in the range [0...255] and is automatically clamped by the max HW supported level.
TextureMipSampling _mipSampling