LibWeb/WebGL: Return null from getUniformLocation if uniform isn't found

This commit is contained in:
Luke Wilde 2025-10-23 20:22:48 +01:00 committed by Andreas Kling
parent 5632a52531
commit 008699c129
Notes: github-actions[bot] 2025-10-25 10:57:42 +00:00
2 changed files with 18 additions and 2 deletions

View file

@ -1649,7 +1649,15 @@ GC::Root<WebGLUniformLocation> WebGLRenderingContextImpl::get_uniform_location(G
}
auto name_null_terminated = null_terminated_string(name);
return WebGLUniformLocation::create(m_realm, glGetUniformLocation(program_handle, name_null_terminated.data()));
// "This function returns -1 if name does not correspond to an active uniform variable in program or if name starts
// with the reserved prefix "gl_"."
// WebGL Spec: The return value is null if name does not correspond to an active uniform variable in the passed program.
auto location = glGetUniformLocation(program_handle, name_null_terminated.data());
if (location == -1)
return nullptr;
return WebGLUniformLocation::create(m_realm, location);
}
void WebGLRenderingContextImpl::hint(WebIDL::UnsignedLong target, WebIDL::UnsignedLong mode)