mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-12 06:08:30 +09:00
[Feat] (MG_State/Program): glGetUniformLocation
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
namespace MobileGL {
|
namespace MobileGL {
|
||||||
namespace MG_Impl::GLImpl {
|
namespace MG_Impl::GLImpl {
|
||||||
static bool CheckShaderNameValidity(Uint shader) {
|
static bool CheckShaderNameValidity(Uint shader) {
|
||||||
if (!MG_State::pGLContext->ValidateShaderName(shader)) {
|
if (shader == 0 || !MG_State::pGLContext->ValidateShaderName(shader)) {
|
||||||
MG_State::pGLContext->RecordError(
|
MG_State::pGLContext->RecordError(
|
||||||
ErrorCode::InvalidValue,
|
ErrorCode::InvalidValue,
|
||||||
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", __func__,
|
MakeShared<GenericErrorInfo>("MG_Impl/GLImpl", __func__,
|
||||||
@@ -216,7 +216,10 @@ namespace MobileGL {
|
|||||||
|
|
||||||
|
|
||||||
GLint GetUniformLocation_State(GLuint program, const GLchar* name) {
|
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) {
|
void GetUniformfv_State(GLuint program, GLint location, GLfloat* params) {
|
||||||
|
|||||||
@@ -15,6 +15,10 @@ namespace MobileGL {
|
|||||||
void MarkAsDeleted();
|
void MarkAsDeleted();
|
||||||
Vector<SharedPtr<ShaderObject>>& GetAttachedShaders();
|
Vector<SharedPtr<ShaderObject>>& GetAttachedShaders();
|
||||||
const String& GetInfoLog() const { return m_infoLog; }
|
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:
|
private:
|
||||||
void PreLink();
|
void PreLink();
|
||||||
void PostLink();
|
void PostLink();
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ namespace MobileGL {
|
|||||||
const String& GetShaderSource() const { return m_source; }
|
const String& GetShaderSource() const { return m_source; }
|
||||||
SharedPtr<glslang::TShader> GetCompiledShader() const { return m_shader; }
|
SharedPtr<glslang::TShader> GetCompiledShader() const { return m_shader; }
|
||||||
const String& GetInfoLog() const { return m_infoLog; }
|
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:
|
private:
|
||||||
bool DoReflection();
|
bool DoReflection();
|
||||||
const Uint m_id = 0;
|
const Uint m_id = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user