[rtextures] ImageDraw(): Implement drawing to mipmaps
This commit is contained in:
parent
2ddb21dc3a
commit
db3e68605f
|
|
@ -3916,7 +3916,6 @@ void ImageDraw(Image *dst, Image src, Rectangle srcRec, Rectangle dstRec, Color
|
||||||
if ((dst->data == NULL) || (dst->width == 0) || (dst->height == 0) ||
|
if ((dst->data == NULL) || (dst->width == 0) || (dst->height == 0) ||
|
||||||
(src.data == NULL) || (src.width == 0) || (src.height == 0)) return;
|
(src.data == NULL) || (src.width == 0) || (src.height == 0)) return;
|
||||||
|
|
||||||
if (dst->mipmaps > 1) TRACELOG(LOG_WARNING, "Image drawing only applied to base mipmap level");
|
|
||||||
if (dst->format >= PIXELFORMAT_COMPRESSED_DXT1_RGB) TRACELOG(LOG_WARNING, "Image drawing not supported for compressed formats");
|
if (dst->format >= PIXELFORMAT_COMPRESSED_DXT1_RGB) TRACELOG(LOG_WARNING, "Image drawing not supported for compressed formats");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -4029,6 +4028,34 @@ void ImageDraw(Image *dst, Image src, Rectangle srcRec, Rectangle dstRec, Color
|
||||||
}
|
}
|
||||||
|
|
||||||
if (useSrcMod) UnloadImage(srcMod); // Unload source modified image
|
if (useSrcMod) UnloadImage(srcMod); // Unload source modified image
|
||||||
|
|
||||||
|
if (dst->mipmaps > 1 && src.mipmaps > 1) {
|
||||||
|
Image mipmapDst = *dst;
|
||||||
|
mipmapDst.data = (char *) mipmapDst.data + GetPixelDataSize(mipmapDst.width, mipmapDst.height, mipmapDst.format);
|
||||||
|
mipmapDst.width /= 2;
|
||||||
|
mipmapDst.height /= 2;
|
||||||
|
mipmapDst.mipmaps--;
|
||||||
|
|
||||||
|
Image mipmapSrc = src;
|
||||||
|
mipmapSrc.data = (char *) mipmapSrc.data + GetPixelDataSize(mipmapSrc.width, mipmapSrc.height, mipmapSrc.format);
|
||||||
|
mipmapSrc.width /= 2;
|
||||||
|
mipmapSrc.height /= 2;
|
||||||
|
mipmapSrc.mipmaps--;
|
||||||
|
|
||||||
|
Rectangle mipmapSrcRec = srcRec;
|
||||||
|
mipmapSrcRec.width /= 2;
|
||||||
|
mipmapSrcRec.height /= 2;
|
||||||
|
mipmapSrcRec.x /= 2;
|
||||||
|
mipmapSrcRec.y /= 2;
|
||||||
|
|
||||||
|
Rectangle mipmapDstRec = dstRec;
|
||||||
|
mipmapDstRec.width /= 2;
|
||||||
|
mipmapDstRec.height /= 2;
|
||||||
|
mipmapDstRec.x /= 2;
|
||||||
|
mipmapDstRec.y /= 2;
|
||||||
|
|
||||||
|
ImageDraw(&mipmapDst, mipmapSrc, mipmapSrcRec, mipmapDstRec, tint);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user