Skip to content

Commit 2cb532d

Browse files
authored
gx: add GX_GetTexObjLOD() (#173)
These values are written into the texture object by GX_InitTexObjLOD(), GX_InitTexObjMinLOD() and GX_InitTexObjMaxLOD() but there was no getter for them.
1 parent 0ea7278 commit 2cb532d

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

gc/ogc/gx.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4095,6 +4095,21 @@ u16 GX_GetTexObjHeight(const GXTexObj* obj);
40954095
*/
40964096
u16 GX_GetTexObjWidth(const GXTexObj* obj);
40974097

4098+
/*!
4099+
* \fn void GX_GetTexObjLOD(const GXTexObj* obj, f32 *minlod, f32 *maxlod)
4100+
* \brief Returns the min and max LOD values for the texture object \a obj.
4101+
*
4102+
* \note Use GX_InitTexObjLOD(), GX_InitTexObjMinLOD() or GX_InitTexObjMaxLOD()
4103+
* to initialize the texture minimum and maximum LOD.
4104+
*
4105+
* \param[in] obj ptr to a texture object
4106+
* \param[out] minlod minimum LOD value from 0.0 - 10.0 inclusive
4107+
* \param[out] maxlod maximum LOD value from 0.0 - 10.0 inclusive
4108+
*
4109+
* \return none
4110+
*/
4111+
void GX_GetTexObjLOD(const GXTexObj* obj, f32 *minlod, f32 *maxlod);
4112+
40984113
/*!
40994114
* \fn void GX_GetTexObjAll(const GXTexObj* obj, void** image_ptr, u16* width, u16* height, u8* format, u8* wrap_s, u8* wrap_t, u8* mipmap);
41004115
* \brief Returns the parameters described by a texture object. Texture objects are used to describe all the parameters associated with a texture, including size, format, wrap modes, filter modes, etc. Texture objects are initialized using either GX_InitTexObj() or, for color index format textures, GX_InitTexObjCI().

libogc/gx.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3027,6 +3027,12 @@ u16 GX_GetTexObjWidth(const GXTexObj *obj)
30273027
return (((const struct __gx_texobj*)obj)->tex_size & 0x3ff) + 1;
30283028
}
30293029

3030+
void GX_GetTexObjLOD(const GXTexObj *obj, f32 *minlod, f32 *maxlod)
3031+
{
3032+
const struct __gx_texobj *ptr = (const struct __gx_texobj*)obj;
3033+
*minlod = (ptr->tex_lod & 0xff) / 16.0f;
3034+
*maxlod = _SHIFTR(ptr->tex_lod, 8, 8) / 16.0f;
3035+
}
30303036

30313037
void GX_GetTexObjAll(const GXTexObj *obj, void** image_ptr, u16* width, u16* height,
30323038
u8* format, u8* wrap_s, u8* wrap_t, u8* mipmap)

0 commit comments

Comments
 (0)