[Scummvm-git-logs] scummvm master -> 884c3aa7951346cc8a75e2020286d4cb44529eda

lephilousophe noreply at scummvm.org
Sun Oct 9 16:31:33 UTC 2022


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
884c3aa795 OPENGL: Use the correct index when attribute is added after link


Commit: 884c3aa7951346cc8a75e2020286d4cb44529eda
    https://github.com/scummvm/scummvm/commit/884c3aa7951346cc8a75e2020286d4cb44529eda
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2022-10-09T18:30:29+02:00

Commit Message:
OPENGL: Use the correct index when attribute is added after link

Changed paths:
    graphics/opengl/shader.cpp


diff --git a/graphics/opengl/shader.cpp b/graphics/opengl/shader.cpp
index e1b159612a5..d622ef35181 100644
--- a/graphics/opengl/shader.cpp
+++ b/graphics/opengl/shader.cpp
@@ -415,6 +415,8 @@ void Shader::freeBuffer(GLuint vbo) {
 }
 
 bool Shader::addAttribute(const char *attrib) {
+	// Once we are linked we can't rebind the attribute so we have to deal with its place defined by OpenGL
+	// As we store attribute at its OpenGL index, we will end up with empty attributes in the middle
 	uint32 i;
 	for (i = 0; i < _attributes.size(); ++i)
 		if (_attributes[i]._name.equals(attrib))
@@ -422,11 +424,19 @@ bool Shader::addAttribute(const char *attrib) {
 
 	GLint result = -1;
 	GL_ASSIGN(result, glGetAttribLocation(*_shaderNo, attrib));
-	if (result == -1)
+	if (result < 0)
 		return false;
 
-	GL_CALL(glBindAttribLocation(*_shaderNo, i, attrib));
-	_attributes.push_back(VertexAttrib(i, attrib));
+
+	// Make sure we can store our new attribute
+	if (_attributes.size() <= (uint)result) {
+		for(; i < (uint)result; i++) {
+			_attributes.push_back(VertexAttrib(i, ""));
+		}
+		_attributes.push_back(VertexAttrib(result, attrib));
+	}
+
+	_attributes[result] = VertexAttrib(result, attrib);
 	return true;
 }
 




More information about the Scummvm-git-logs mailing list