diff --git a/src/component/CCharacterComponent.cpp b/src/component/CCharacterComponent.cpp index e96330e..4bc82e1 100644 --- a/src/component/CCharacterComponent.cpp +++ b/src/component/CCharacterComponent.cpp @@ -2,6 +2,7 @@ #include "component/Texture.hpp" #include "component/Util.hpp" #include "db/Db.hpp" +#include "gx/Device.hpp" #include "gx/Texture.hpp" #include "model/CM2Model.hpp" #include "object/Types.hpp" @@ -78,10 +79,37 @@ void CCharacterComponent::InitDbData() { // TODO CountFacialFeatures(varArrayLength, &CCharacterComponent::s_characterFacialHairStylesList); } -void CCharacterComponent::CreateBaseTexture() { +void CCharacterComponent::UpdateBaseTexture(EGxTexCommand cmd, uint32_t width, uint32_t height, uint32_t depth, uint32_t mipLevel, void* userArg, uint32_t& texelStrideInBytes, const void*& texels) { // TODO } +void CCharacterComponent::CreateBaseTexture() { + auto dataFormat = this->m_textureFormat == GxTex_Dxt1 + ? GxTex_Dxt1 + : GxTex_Argb8888; + + CGxTexFlags flags = CGxTexFlags(GxTex_LinearMipLinear, 0, 0, 0, 0, 0, 1); + if (GxDevApi() == GxApi_GLL) { + flags.m_bit15 = 1; + } + + auto baseTexture = TextureCreate( + CCharacterComponent::s_textureSize, + CCharacterComponent::s_textureSize, + this->m_textureFormat, + dataFormat, + flags, + this, + &CCharacterComponent::UpdateBaseTexture, + "CharacterBaseSkin", + 1 + ); + + this->m_baseTexture = baseTexture; + + // TODO this->m_data->m_model->ReplaceTexture(1, this->m_baseTexture); +} + void CCharacterComponent::GeosRenderPrep() { // TODO diff --git a/src/component/CCharacterComponent.hpp b/src/component/CCharacterComponent.hpp index f0cb545..92f173f 100644 --- a/src/component/CCharacterComponent.hpp +++ b/src/component/CCharacterComponent.hpp @@ -63,10 +63,12 @@ class CCharacterComponent { static void Initialize(); static void Initialize(EGxTexFormat textureFormat, uint32_t textureLevel, int32_t thread, int32_t compress); static void InitDbData(); + static void UpdateBaseTexture(EGxTexCommand cmd, uint32_t width, uint32_t height, uint32_t depth, uint32_t mipLevel, void* userArg, uint32_t& texelStrideInBytes, const void*& texels); // Member variables uint32_t m_flags = 0x1 | 0x2 | 0x4; uint32_t m_sections = 0xFFFFFFFF; + EGxTexFormat m_textureFormat = CCharacterComponent::s_gxFormat; ComponentData m_data; HTEXTURE m_baseTexture = nullptr; void* m_texture[NUM_COMPONENT_VARIATIONS * 3] = {};