[Feat] (MG_State/Program): glGetUniformLocation

This commit is contained in:
2025-08-13 23:32:33 +08:00
parent 5422dcf164
commit aa2aefac28
3 changed files with 10 additions and 3 deletions
@@ -5,7 +5,7 @@
namespace MobileGL {
namespace MG_Impl::GLImpl {
static bool CheckShaderNameValidity(Uint shader) {
if (!MG_State::pGLContext->ValidateShaderName(shader)) {
if (shader == 0 || !MG_State::pGLContext->ValidateShaderName(shader)) {
MG_State::pGLContext->RecordError(
ErrorCode::InvalidValue,
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", __func__,
@@ -216,7 +216,10 @@ namespace MobileGL {
GLint GetUniformLocation_State(GLuint program, const GLchar* name) {
THROW_UNIMPL_EXCEPTION;
auto programObject = TryToGetProgramObject(program);
if (!programObject)
return -1;
return programObject->GetUniformLocation(name);
}
void GetUniformfv_State(GLuint program, GLint location, GLfloat* params) {
@@ -15,6 +15,10 @@ namespace MobileGL {
void MarkAsDeleted();
Vector<SharedPtr<ShaderObject>>& GetAttachedShaders();
const String& GetInfoLog() const { return m_infoLog; }
Int GetUniformLocation(const String& name) {
const auto it = m_uniforms.find(name);
return (it == m_uniforms.end()) ? -1 : it->second;
}
private:
void PreLink();
void PostLink();
@@ -67,7 +67,7 @@ namespace MobileGL {
const String& GetShaderSource() const { return m_source; }
SharedPtr<glslang::TShader> GetCompiledShader() const { return m_shader; }
const String& GetInfoLog() const { return m_infoLog; }
const UnorderedMap<String, Uint> GetUniformLocations() const { return m_uniforms; }
const UnorderedMap<String, Uint>& GetUniformLocations() const { return m_uniforms; }
private:
bool DoReflection();
const Uint m_id = 0;