forked from Mirrorlandia_minetest/irrlicht
Drop createImagesFromFile in favor of createImageFromFile
This commit is contained in:
parent
fc0440ff89
commit
5eb607f86f
@ -959,28 +959,6 @@ namespace video
|
||||
\return The current texture creation flag enabled mode. */
|
||||
virtual bool getTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag) const =0;
|
||||
|
||||
//! Creates a software images from a file.
|
||||
/** No hardware texture will be created for those images. This
|
||||
method is useful for example if you want to read a heightmap
|
||||
for a terrain renderer.
|
||||
\param filename Name of the file from which the images are created.
|
||||
\param type Pointer to E_TEXTURE_TYPE where a recommended type of the texture will be stored.
|
||||
\return The array of created images.
|
||||
If you no longer need those images, you should call IImage::drop() on each of them.
|
||||
See IReferenceCounted::drop() for more information. */
|
||||
virtual core::array<IImage*> createImagesFromFile(const io::path& filename, E_TEXTURE_TYPE* type = 0) = 0;
|
||||
|
||||
//! Creates a software images from a file.
|
||||
/** No hardware texture will be created for those images. This
|
||||
method is useful for example if you want to read a heightmap
|
||||
for a terrain renderer.
|
||||
\param file File from which the image is created.
|
||||
\param type Pointer to E_TEXTURE_TYPE where a recommended type of the texture will be stored.
|
||||
\return The array of created images.
|
||||
If you no longer need those images, you should call IImage::drop() on each of them.
|
||||
See IReferenceCounted::drop() for more information. */
|
||||
virtual core::array<IImage*> createImagesFromFile(io::IReadFile* file, E_TEXTURE_TYPE* type = 0) = 0;
|
||||
|
||||
//! Creates a software image from a file.
|
||||
/** No hardware texture will be created for this image. This
|
||||
method is useful for example if you want to read a heightmap
|
||||
@ -990,15 +968,7 @@ namespace video
|
||||
\return The created image.
|
||||
If you no longer need the image, you should call IImage::drop().
|
||||
See IReferenceCounted::drop() for more information. */
|
||||
IImage* createImageFromFile(const io::path& filename)
|
||||
{
|
||||
core::array<IImage*> imageArray = createImagesFromFile(filename);
|
||||
|
||||
for (u32 i = 1; i < imageArray.size(); ++i)
|
||||
imageArray[i]->drop();
|
||||
|
||||
return (imageArray.size() > 0) ? imageArray[0] : 0;
|
||||
}
|
||||
virtual IImage* createImageFromFile(const io::path& filename) = 0;
|
||||
|
||||
//! Creates a software image from a file.
|
||||
/** No hardware texture will be created for this image. This
|
||||
@ -1008,15 +978,7 @@ namespace video
|
||||
\return The created image.
|
||||
If you no longer need the image, you should call IImage::drop().
|
||||
See IReferenceCounted::drop() for more information. */
|
||||
IImage* createImageFromFile(io::IReadFile* file)
|
||||
{
|
||||
core::array<IImage*> imageArray = createImagesFromFile(file);
|
||||
|
||||
for (u32 i = 1; i < imageArray.size(); ++i)
|
||||
imageArray[i]->drop();
|
||||
|
||||
return (imageArray.size() > 0) ? imageArray[0] : 0;
|
||||
}
|
||||
virtual IImage* createImageFromFile(io::IReadFile* file) = 0;
|
||||
|
||||
//! Writes the provided image to a file.
|
||||
/** Requires that there is a suitable image writer registered
|
||||
|
@ -553,39 +553,21 @@ ITexture* CNullDriver::getTexture(io::IReadFile* file)
|
||||
//! opens the file and loads it into the surface
|
||||
video::ITexture* CNullDriver::loadTextureFromFile(io::IReadFile* file, const io::path& hashName )
|
||||
{
|
||||
ITexture* texture = 0;
|
||||
ITexture *texture = nullptr;
|
||||
|
||||
E_TEXTURE_TYPE type = ETT_2D;
|
||||
|
||||
core::array<IImage*> imageArray = createImagesFromFile(file, &type);
|
||||
|
||||
if (checkImage(imageArray))
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case ETT_2D:
|
||||
texture = createDeviceDependentTexture(hashName.size() ? hashName : file->getFileName(), imageArray[0]);
|
||||
break;
|
||||
case ETT_CUBEMAP:
|
||||
if (imageArray.size() >= 6 && imageArray[0] && imageArray[1] && imageArray[2] && imageArray[3] && imageArray[4] && imageArray[5])
|
||||
{
|
||||
texture = createDeviceDependentTextureCubemap(hashName.size() ? hashName : file->getFileName(), imageArray);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
_IRR_DEBUG_BREAK_IF(true);
|
||||
break;
|
||||
}
|
||||
IImage *image = createImageFromFile(file);
|
||||
if (!image)
|
||||
return nullptr;
|
||||
|
||||
core::array<IImage*> imageArray;
|
||||
imageArray.push_back(image);
|
||||
if (checkImage(imageArray)) {
|
||||
texture = createDeviceDependentTexture(hashName.size() ? hashName : file->getFileName(), image);
|
||||
if (texture)
|
||||
os::Printer::log("Loaded texture", file->getFileName(), ELL_DEBUG);
|
||||
}
|
||||
|
||||
for (u32 i = 0; i < imageArray.size(); ++i)
|
||||
{
|
||||
if (imageArray[i])
|
||||
imageArray[i]->drop();
|
||||
}
|
||||
image->drop();
|
||||
|
||||
return texture;
|
||||
}
|
||||
@ -1168,36 +1150,26 @@ bool CNullDriver::getTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag) const
|
||||
return (TextureCreationFlags & flag)!=0;
|
||||
}
|
||||
|
||||
core::array<IImage*> CNullDriver::createImagesFromFile(const io::path& filename, E_TEXTURE_TYPE* type)
|
||||
IImage *CNullDriver::createImageFromFile(const io::path& filename)
|
||||
{
|
||||
// TO-DO -> use 'move' feature from C++11 standard.
|
||||
if (!filename.size())
|
||||
return nullptr;
|
||||
|
||||
core::array<IImage*> imageArray;
|
||||
|
||||
if (filename.size() > 0)
|
||||
{
|
||||
io::IReadFile* file = FileSystem->createAndOpenFile(filename);
|
||||
|
||||
if (file)
|
||||
{
|
||||
imageArray = createImagesFromFile(file, type);
|
||||
file->drop();
|
||||
}
|
||||
else
|
||||
if (!file) {
|
||||
os::Printer::log("Could not open file of image", filename, ELL_WARNING);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return imageArray;
|
||||
IImage *image = createImageFromFile(file);
|
||||
file->drop();
|
||||
return image;
|
||||
}
|
||||
|
||||
core::array<IImage*> CNullDriver::createImagesFromFile(io::IReadFile* file, E_TEXTURE_TYPE* type)
|
||||
IImage *CNullDriver::createImageFromFile(io::IReadFile* file)
|
||||
{
|
||||
// TO-DO -> use 'move' feature from C++11 standard.
|
||||
|
||||
core::array<IImage*> imageArray;
|
||||
|
||||
if (!file)
|
||||
return imageArray;
|
||||
return nullptr;
|
||||
|
||||
// try to load file based on file extension
|
||||
for (int i = SurfaceLoader.size() - 1; i >= 0; --i) {
|
||||
@ -1205,10 +1177,8 @@ core::array<IImage*> CNullDriver::createImagesFromFile(io::IReadFile* file, E_TE
|
||||
continue;
|
||||
|
||||
file->seek(0); // reset file position which might have changed due to previous loadImage calls
|
||||
if (IImage *image = SurfaceLoader[i]->loadImage(file)) {
|
||||
imageArray.push_back(image);
|
||||
return imageArray;
|
||||
}
|
||||
if (IImage *image = SurfaceLoader[i]->loadImage(file))
|
||||
return image;
|
||||
}
|
||||
|
||||
// try to load file based on what is in it
|
||||
@ -1220,13 +1190,11 @@ core::array<IImage*> CNullDriver::createImagesFromFile(io::IReadFile* file, E_TE
|
||||
continue;
|
||||
|
||||
file->seek(0);
|
||||
if (IImage *image = SurfaceLoader[i]->loadImage(file)) {
|
||||
imageArray.push_back(image);
|
||||
return imageArray;
|
||||
}
|
||||
if (IImage *image = SurfaceLoader[i]->loadImage(file))
|
||||
return image;
|
||||
}
|
||||
|
||||
return imageArray;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
@ -314,9 +314,9 @@ namespace video
|
||||
//! Returns if a texture creation flag is enabled or disabled.
|
||||
bool getTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag) const override;
|
||||
|
||||
core::array<IImage*> createImagesFromFile(const io::path& filename, E_TEXTURE_TYPE* type = 0) override;
|
||||
IImage *createImageFromFile(const io::path& filename) override;
|
||||
|
||||
core::array<IImage*> createImagesFromFile(io::IReadFile* file, E_TEXTURE_TYPE* type = 0) override;
|
||||
IImage *createImageFromFile(io::IReadFile* file) override;
|
||||
|
||||
//! Creates a software image from a byte array.
|
||||
/** \param useForeignMemory: If true, the image will use the data pointer
|
||||
|
Loading…
Reference in New Issue
Block a user