[Scummvm-git-logs] scummvm master -> fb1db0e94fdb20e1d9df22b2ce64ace168bffb54

ccawley2011 noreply at scummvm.org
Wed Jun 29 13:16:12 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:
fb1db0e94f OPENGL: Allow enabling vertex attributes without using a VBO


Commit: fb1db0e94fdb20e1d9df22b2ce64ace168bffb54
    https://github.com/scummvm/scummvm/commit/fb1db0e94fdb20e1d9df22b2ce64ace168bffb54
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2022-06-29T14:15:46+01:00

Commit Message:
OPENGL: Allow enabling vertex attributes without using a VBO

Changed paths:
    graphics/opengl/shader.cpp
    graphics/opengl/shader.h


diff --git a/graphics/opengl/shader.cpp b/graphics/opengl/shader.cpp
index c2b19f1158c..cadd2bdf683 100644
--- a/graphics/opengl/shader.cpp
+++ b/graphics/opengl/shader.cpp
@@ -296,7 +296,7 @@ void Shader::use(bool forceReload) {
 		if (attrib._enabled) {
 			glEnableVertexAttribArray(i);
 			glBindBuffer(GL_ARRAY_BUFFER, attrib._vbo);
-			glVertexAttribPointer(i, attrib._size, attrib._type, attrib._normalized, attrib._stride, (const GLvoid *)attrib._offset);
+			glVertexAttribPointer(i, attrib._size, attrib._type, attrib._normalized, attrib._stride, attrib._pointer);
 		} else {
 			glDisableVertexAttribArray(i);
 			switch (attrib._size) {
@@ -341,6 +341,17 @@ VertexAttrib &Shader::getAttribute(const char *attrib) {
 	return _attributes[0];
 }
 
+void Shader::enableVertexAttribute(const char *attrib, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer) {
+	VertexAttrib &va = getAttribute(attrib);
+	va._enabled = true;
+	va._vbo = 0;
+	va._size = size;
+	va._type = type;
+	va._normalized = normalized;
+	va._stride = stride;
+	va._pointer = pointer;
+}
+
 void Shader::enableVertexAttribute(const char *attrib, GLuint vbo, GLint size, GLenum type, GLboolean normalized, GLsizei stride, uint32 offset) {
 	VertexAttrib &va = getAttribute(attrib);
 	va._enabled = true;
@@ -349,7 +360,7 @@ void Shader::enableVertexAttribute(const char *attrib, GLuint vbo, GLint size, G
 	va._type = type;
 	va._normalized = normalized;
 	va._stride = stride;
-	va._offset = offset;
+	va._pointer = (const void *)offset;
 }
 
 void Shader::disableVertexAttribute(const char *attrib, int size, const float *data) {
diff --git a/graphics/opengl/shader.h b/graphics/opengl/shader.h
index ed3647d8751..4e1d2fe8d20 100644
--- a/graphics/opengl/shader.h
+++ b/graphics/opengl/shader.h
@@ -39,7 +39,7 @@ namespace OpenGL {
 struct VertexAttrib {
 	VertexAttrib(uint32 idx, const char *name) :
 		_enabled(false), _idx(idx), _name(name), _vbo(0), _size(0),
-		_type(GL_FLOAT), _normalized(false), _stride(0), _offset(0) {}
+		_type(GL_FLOAT), _normalized(false), _stride(0), _pointer(nullptr) {}
 	bool _enabled;
 	uint32 _idx;
 	Common::String _name;
@@ -48,7 +48,7 @@ struct VertexAttrib {
 	GLenum _type;
 	bool _normalized;
 	GLsizei _stride;
-	size_t _offset;
+	const void *_pointer;
 	float _const[4];
 };
 
@@ -152,6 +152,7 @@ public:
 		}
 	}
 
+	void enableVertexAttribute(const char *attrib, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer);
 	void enableVertexAttribute(const char *attrib, GLuint vbo, GLint size, GLenum type, GLboolean normalized, GLsizei stride, uint32 offset);
 	void disableVertexAttribute(const char *attrib, int size, const float *data);
 	template <int r>




More information about the Scummvm-git-logs mailing list