mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-06 17:41:04 +00:00
Split up tile.cpp/h
This commit is contained in:
parent
cdce33dd05
commit
aaf77025b6
34 changed files with 2851 additions and 2801 deletions
|
@ -272,3 +272,40 @@ void imageScaleNNAA(video::IImage *src, const core::rect<s32> &srcrect, video::I
|
|||
dest->setPixel(dx, dy, pxl);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check and align image to npot2 if required by hardware
|
||||
* @param image image to check for npot2 alignment
|
||||
* @param driver driver to use for image operations
|
||||
* @return image or copy of image aligned to npot2
|
||||
*/
|
||||
video::IImage *Align2Npot2(video::IImage *image,
|
||||
video::IVideoDriver *driver)
|
||||
{
|
||||
if (image == NULL)
|
||||
return image;
|
||||
|
||||
if (driver->queryFeature(video::EVDF_TEXTURE_NPOT))
|
||||
return image;
|
||||
|
||||
core::dimension2d<u32> dim = image->getDimension();
|
||||
unsigned int height = npot2(dim.Height);
|
||||
unsigned int width = npot2(dim.Width);
|
||||
|
||||
if (dim.Height == height && dim.Width == width)
|
||||
return image;
|
||||
|
||||
if (dim.Height > height)
|
||||
height *= 2;
|
||||
if (dim.Width > width)
|
||||
width *= 2;
|
||||
|
||||
video::IImage *targetimage =
|
||||
driver->createImage(video::ECF_A8R8G8B8,
|
||||
core::dimension2d<u32>(width, height));
|
||||
|
||||
if (targetimage != NULL)
|
||||
image->copyToScaling(targetimage);
|
||||
image->drop();
|
||||
return targetimage;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue