From 0f3ef7ff3fad57b6a61d9700fe707ad0a97c844e Mon Sep 17 00:00:00 2001 From: hyzboy Date: Sun, 25 Oct 2020 15:07:01 +0800 Subject: [PATCH] add GetMipLevel functions. --- inc/hgl/TypeFunc.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/inc/hgl/TypeFunc.h b/inc/hgl/TypeFunc.h index fd28ad4..b5c1be9 100644 --- a/inc/hgl/TypeFunc.h +++ b/inc/hgl/TypeFunc.h @@ -472,6 +472,21 @@ namespace hgl return(value); } + inline const uint GetMipLevel(const uint size) + { + return static_cast(floor(log2(size)))+1; + } + + inline const uint GetMipLevel(const uint width,const uint height) + { + return GetMipLevel(hgl_max(width,height)); + } + + inline const uint GetMipLevel(const uint width,const uint height,const uint depth) + { + return GetMipLevel(hgl_max(hgl_max(width,height),depth)); + } + /** * 角度转弧度 */