mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-07 19:58:32 +09:00
[Feat] (MG_State/Program): glGetUniformLocation
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user