diff options
| author | Luke Street <luke@street.dev> | 2026-03-01 15:35:36 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-01 14:35:36 -0800 |
| commit | 9649319ec4926457ef85e6094f8207474c977c2d (patch) | |
| tree | 1c5cd4c7cc4c1aee03f28921213da47f2775444d /libs/JSystem/src/J3DGraphBase/J3DTexture.cpp | |
| parent | 6e149819e13b1f70ecbf8a4c66b030c17ffed2bb (diff) | |
Reorganize library code into `libs/` (#3119)
* Reorganize files into libs/{dolphin,JSystem,PowerPC_EABI_Support,revolution,TRK_MINNOW_DOLPHIN}
* Update configure.py and project.py for new libs structure
* Refactor `#include <dolphin/x.h>` -> `<x.h>`
* Remove `__REVOLUTION_SDK__` forwards from dolphin
* Fix dolphin/ references in revolution
* Wrap `#include <dolphin.h>` in `!__REVOLUTION_SDK__`
* Always build TRK against dolphin headers
* Resolve revolution SDK header resolution issues
Diffstat (limited to 'libs/JSystem/src/J3DGraphBase/J3DTexture.cpp')
| -rw-r--r-- | libs/JSystem/src/J3DGraphBase/J3DTexture.cpp | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/libs/JSystem/src/J3DGraphBase/J3DTexture.cpp b/libs/JSystem/src/J3DGraphBase/J3DTexture.cpp new file mode 100644 index 0000000000..70d9a69031 --- /dev/null +++ b/libs/JSystem/src/J3DGraphBase/J3DTexture.cpp @@ -0,0 +1,66 @@ +#include "JSystem/JSystem.h" // IWYU pragma: keep + +#include "JSystem/J3DGraphBase/J3DTexture.h" +#include "JSystem/J3DAssert.h" + +void J3DTexture::loadGX(u16 idx, GXTexMapID texMapID) const { + J3D_ASSERT_RANGE(29, idx < mNum); + + ResTIMG* timg = getResTIMG(idx); + GXTexObj texObj; + GXTlutObj tlutObj; + + if (!timg->indexTexture) { + GXInitTexObj(&texObj, ((u8*)timg) + timg->imageOffset, timg->width, timg->height, + (GXTexFmt)timg->format, (GXTexWrapMode)timg->wrapS, (GXTexWrapMode)timg->wrapT, + timg->mipmapEnabled); + } else { + GXInitTexObjCI(&texObj, ((u8*)timg) + timg->imageOffset, timg->width, timg->height, + (GXCITexFmt)timg->format, (GXTexWrapMode)timg->wrapS, + (GXTexWrapMode)timg->wrapT, timg->mipmapEnabled, (u32)texMapID); + GXInitTlutObj(&tlutObj, ((u8*)timg) + timg->paletteOffset, (GXTlutFmt)timg->colorFormat, + timg->numColors); + GXLoadTlut(&tlutObj, texMapID); + } + + const f32 kLODClampScale = 1.0f / 8.0f; + const f32 kLODBiasScale = 1.0f / 100.0f; + GXInitTexObjLOD(&texObj, (GXTexFilter)timg->minFilter, (GXTexFilter)timg->magFilter, + timg->minLOD * kLODClampScale, timg->maxLOD * kLODClampScale, + timg->LODBias * kLODBiasScale, timg->biasClamp, timg->doEdgeLOD, + (GXAnisotropy)timg->maxAnisotropy); + GXLoadTexObj(&texObj, texMapID); +} + +void J3DTexture::entryNum(u16 num) { + J3D_ASSERT_NONZEROARG(79, num != 0); + + mNum = num; + mpRes = new ResTIMG[num]; + J3D_ASSERT_ALLOCMEM(83, mpRes != NULL); + + for (int i = 0; i < mNum; i++) { + mpRes[i].paletteOffset = 0; + mpRes[i].imageOffset = 0; + } +} + +void J3DTexture::addResTIMG(u16 newNum, const ResTIMG* newRes) { + if (newNum == 0) + return; + + J3D_ASSERT_NULLPTR(105, newRes != NULL); + + u16 oldNum = mNum; + ResTIMG* oldRes = mpRes; + + entryNum(mNum + newNum); + + for (u16 i = 0; i < oldNum; i++) { + setResTIMG(i, oldRes[i]); + } + + for (u16 i = oldNum; i < mNum; i++) { + setResTIMG(i, newRes[i]); + } +} |
