Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gx: add GX_GetTexObjLOD() #173

Merged
merged 1 commit into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions gc/ogc/gx.h
Original file line number Diff line number Diff line change
Expand Up @@ -4095,6 +4095,21 @@ u16 GX_GetTexObjHeight(const GXTexObj* obj);
*/
u16 GX_GetTexObjWidth(const GXTexObj* obj);

/*!
* \fn void GX_GetTexObjLOD(const GXTexObj* obj, f32 *minlod, f32 *maxlod)
* \brief Returns the min and max LOD values for the texture object \a obj.
*
* \note Use GX_InitTexObjLOD(), GX_InitTexObjMinLOD() or GX_InitTexObjMaxLOD()
* to initialize the texture minimum and maximum LOD.
*
* \param[in] obj ptr to a texture object
* \param[out] minlod minimum LOD value from 0.0 - 10.0 inclusive
* \param[out] maxlod maximum LOD value from 0.0 - 10.0 inclusive
*
* \return none
*/
void GX_GetTexObjLOD(const GXTexObj* obj, f32 *minlod, f32 *maxlod);

/*!
* \fn void GX_GetTexObjAll(const GXTexObj* obj, void** image_ptr, u16* width, u16* height, u8* format, u8* wrap_s, u8* wrap_t, u8* mipmap);
* \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().
Expand Down
6 changes: 6 additions & 0 deletions libogc/gx.c
Original file line number Diff line number Diff line change
Expand Up @@ -3027,6 +3027,12 @@ u16 GX_GetTexObjWidth(const GXTexObj *obj)
return (((const struct __gx_texobj*)obj)->tex_size & 0x3ff) + 1;
}

void GX_GetTexObjLOD(const GXTexObj *obj, f32 *minlod, f32 *maxlod)
{
const struct __gx_texobj *ptr = (const struct __gx_texobj*)obj;
*minlod = (ptr->tex_lod & 0xff) / 16.0f;
*maxlod = _SHIFTR(ptr->tex_lod, 8, 8) / 16.0f;
}

void GX_GetTexObjAll(const GXTexObj *obj, void** image_ptr, u16* width, u16* height,
u8* format, u8* wrap_s, u8* wrap_t, u8* mipmap)
Expand Down
Loading