Skip to content

Commit

Permalink
Add workaround for IOS/emscripten NPOT Textures
Browse files Browse the repository at this point in the history
Mitigation.
  • Loading branch information
m4xw committed Oct 15, 2024
1 parent e0957ec commit 75d5a44
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,8 @@ namespace opengl {
glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GLint(_parameters.minFilter));
(*m_texparams)[u32(_parameters.handle)].minFilter = GLint(_parameters.minFilter);
}

#if !defined(IOS) && !defined(EMSCRIPTEN)
if (_parameters.wrapS.isValid() && !(iterValid && iter->second.wrapS == GLint(_parameters.wrapS))) {
glTexParameteri(target, GL_TEXTURE_WRAP_S, GLint(_parameters.wrapS));
(*m_texparams)[u32(_parameters.handle)].wrapS = GLint(_parameters.wrapS);
Expand All @@ -289,6 +291,13 @@ namespace opengl {
glTexParameteri(target, GL_TEXTURE_WRAP_T, GLint(_parameters.wrapT));
(*m_texparams)[u32(_parameters.handle)].wrapT = GLint(_parameters.wrapT);
}
#else // !IOS && !EMSCRIPTEN
// HACK: Emscripten & IOS only support NPOT textures for GL_CLAMP_TO_EDGE
glTexParameteri(target, GL_TEXTURE_WRAP_S, GLint(graphics::textureParameters::WRAP_CLAMP_TO_EDGE));
(*m_texparams)[u32(_parameters.handle)].wrapS = GLint(graphics::textureParameters::WRAP_CLAMP_TO_EDGE);
glTexParameteri(target, GL_TEXTURE_WRAP_T, GLint(graphics::textureParameters::WRAP_CLAMP_TO_EDGE));
(*m_texparams)[u32(_parameters.handle)].wrapT = GLint(graphics::textureParameters::WRAP_CLAMP_TO_EDGE);
#endif // IOS || EMSCRIPTEN
if (m_supportMipmapLevel && _parameters.maxMipmapLevel.isValid() && !(iterValid && iter->second.maxMipmapLevel == GLint(_parameters.maxMipmapLevel))) {
glTexParameteri(target, GL_TEXTURE_MAX_LEVEL, GLint(_parameters.maxMipmapLevel));
(*m_texparams)[u32(_parameters.handle)].maxMipmapLevel = GLint(_parameters.maxMipmapLevel);
Expand Down

0 comments on commit 75d5a44

Please sign in to comment.