[Improvement] (ProgramState): Rename AttributeBindings -> AttributeLocations.

This commit is contained in:
BZLZHH
2025-06-08 16:01:31 +08:00
parent 3c98bc5eca
commit f3497bd2fa
5 changed files with 20 additions and 20 deletions
@@ -353,7 +353,7 @@ namespace MG_GL::GL {
void BindAttribLocation(GLuint program, GLuint index, const GLchar* name) {
MG_Util::Debug::LogD("glBindAttribLocation, program: %u, index: %u, name: %s", program, index, name);
GLenum result = MG_State::DefineProgramAttributeBinding(program, index, name);
GLenum result = MG_State::DefineProgramAttributeLocation(program, index, name);
if (result == GL_NO_ERROR) return;
MG_State::SetError(result);
MG_Util::Debug::LogE("Error binding attribute: %s", MG_Util::Debug::GLEnumToString(result));
@@ -361,7 +361,7 @@ namespace MG_GL::GL {
GLint GetAttribLocation(GLuint program, const GLchar* name) {
MG_Util::Debug::LogD("glGetAttribLocation, program: %u, name: %s", program, name);
GLint location = MG_State::QueryProgramAttributeBinding(program, name);
GLint location = MG_State::QueryProgramAttributeLocation(program, name);
if (location != -1) return location;
MG_State::SetError(GL_INVALID_OPERATION);
MG_Util::Debug::LogE("Attribute not found: %s", name);
+4 -4
View File
@@ -298,12 +298,12 @@ namespace MG_State {
return MG_State_T::programState->ActivateRenderProgram(program);
}
GLenum DefineProgramAttributeBinding(GLuint program, GLuint index, const GLchar* name) {
return MG_State_T::programState->DefineProgramAttributeBinding(program, index, name);
GLenum DefineProgramAttributeLocation(GLuint program, GLuint index, const GLchar* name) {
return MG_State_T::programState->DefineProgramAttributeLocation(program, index, name);
}
GLint QueryProgramAttributeBinding(GLuint program, const GLchar* name) {
return MG_State_T::programState->QueryProgramAttributeBinding(program, name);
GLint QueryProgramAttributeLocation(GLuint program, const GLchar* name) {
return MG_State_T::programState->QueryProgramAttributeLocation(program, name);
}
GLint QueryProgramUniformLocation(GLuint program, const GLchar* name) {
+2 -2
View File
@@ -96,8 +96,8 @@ namespace MG_State {
GLenum BuildShaderStage(GLuint shader);
GLenum FinalizeProgramPipeline(GLuint program);
GLenum ActivateRenderProgram(GLuint program);
GLenum DefineProgramAttributeBinding(GLuint program, GLuint index, const GLchar* name);
GLint QueryProgramAttributeBinding(GLuint program, const GLchar* name);
GLenum DefineProgramAttributeLocation(GLuint program, GLuint index, const GLchar* name);
GLint QueryProgramAttributeLocation(GLuint program, const GLchar* name);
GLint QueryProgramUniformLocation(GLuint program, const GLchar* name);
GLenum QueryProgramStateIntVector(GLuint program, GLenum pname, GLint* params);
GLenum QueryShaderStateIntVector(GLuint shader, GLenum pname, GLint* params);
+10 -10
View File
@@ -145,28 +145,28 @@ GLenum ProgramState::ActivateRenderProgram(GLuint program) {
return GL_NO_ERROR;
}
GLenum ProgramState::DefineProgramAttributeBinding(GLuint program, GLuint index, const GLchar* name) {
MG_Util::Debug::LogD("MG_State: Program: DefineProgramAttributeBinding called, program=%u, index=%u, name=%s",
GLenum ProgramState::DefineProgramAttributeLocation(GLuint program, GLuint index, const GLchar* name) {
MG_Util::Debug::LogD("MG_State: Program: DefineProgramAttributeLocation called, program=%u, index=%u, name=%s",
program, index, name);
if (!ValidateProgram_(program)) {
MG_Util::Debug::LogE("MG_State: Program: DefineProgramAttributeBinding error: invalid program id %u", program);
MG_Util::Debug::LogE("MG_State: Program: DefineProgramAttributeLocation error: invalid program id %u", program);
return GL_INVALID_VALUE;
}
if (index >= GL_MAX_VERTEX_ATTRIBS) {
MG_Util::Debug::LogE("MG_State: Program: DefineProgramAttributeBinding error: index %u out of range", index);
MG_Util::Debug::LogE("MG_State: Program: DefineProgramAttributeLocation error: index %u out of range", index);
return GL_INVALID_VALUE;
}
programs_[program].attribLocations[name] = index;
MG_Util::Debug::LogD("MG_State: Program: DefineProgramAttributeBinding success: %s -> %u", name, index);
MG_Util::Debug::LogD("MG_State: Program: DefineProgramAttributeLocation success: %s -> %u", name, index);
return GL_NO_ERROR;
}
GLint ProgramState::QueryProgramAttributeBinding(GLuint program, const GLchar* name) {
MG_Util::Debug::LogD("MG_State: Program: QueryProgramAttributeBinding called, program=%u, name=%s",
GLint ProgramState::QueryProgramAttributeLocation(GLuint program, const GLchar* name) {
MG_Util::Debug::LogD("MG_State: Program: QueryProgramAttributeLocation called, program=%u, name=%s",
program, name);
if (!ValidateProgram_(program)) {
MG_Util::Debug::LogE("MG_State: Program: QueryProgramAttributeBinding error: invalid program id %u", program);
MG_Util::Debug::LogE("MG_State: Program: QueryProgramAttributeLocation error: invalid program id %u", program);
return -1;
}
@@ -174,10 +174,10 @@ GLint ProgramState::QueryProgramAttributeBinding(GLuint program, const GLchar* n
auto it = prog.attribLocations.find(name);
if (it != prog.attribLocations.end()) {
GLint loc = it->second;
MG_Util::Debug::LogD("MG_State: Program: QueryProgramAttributeBinding success: %s -> %d", name, loc);
MG_Util::Debug::LogD("MG_State: Program: QueryProgramAttributeLocation success: %s -> %d", name, loc);
return loc;
}
MG_Util::Debug::LogW("MG_State: Program: QueryProgramAttributeBinding warning: name '%s' not found", name);
MG_Util::Debug::LogW("MG_State: Program: QueryProgramAttributeLocation warning: name '%s' not found", name);
return -1;
}
+2 -2
View File
@@ -71,8 +71,8 @@ public:
GLenum BuildShaderStage(GLuint shader);
GLenum FinalizeProgramPipeline(GLuint program);
GLenum ActivateRenderProgram(GLuint program);
GLenum DefineProgramAttributeBinding(GLuint program, GLuint index, const GLchar* name);
GLint QueryProgramAttributeBinding(GLuint program, const GLchar* name);
GLenum DefineProgramAttributeLocation(GLuint program, GLuint index, const GLchar* name);
GLint QueryProgramAttributeLocation(GLuint program, const GLchar* name);
GLint QueryProgramUniformLocation(GLuint program, const GLchar* name);
GLenum QueryProgramStateIntVector(GLuint program, GLenum pname, GLint* params);
GLenum QueryShaderStateIntVector(GLuint shader, GLenum pname, GLint* params);