Browse Source

Renamed the internal OpenGL buffer class from VertexBuffer to GLBuffer.

Alex Szpakowski 10 years ago
parent
commit
8277eb9abd

+ 2 - 2
CMakeLists.txt

@@ -284,6 +284,8 @@ set(LOVE_SRC_MODULE_GRAPHICS_OPENGL
 	src/modules/graphics/opengl/Canvas.h
 	src/modules/graphics/opengl/Font.cpp
 	src/modules/graphics/opengl/Font.h
+	src/modules/graphics/opengl/GLBuffer.cpp
+	src/modules/graphics/opengl/GLBuffer.h
 	src/modules/graphics/opengl/Graphics.cpp
 	src/modules/graphics/opengl/Graphics.h
 	src/modules/graphics/opengl/Image.cpp
@@ -302,8 +304,6 @@ set(LOVE_SRC_MODULE_GRAPHICS_OPENGL
 	src/modules/graphics/opengl/SpriteBatch.h
 	src/modules/graphics/opengl/Text.cpp
 	src/modules/graphics/opengl/Text.h
-	src/modules/graphics/opengl/VertexBuffer.cpp
-	src/modules/graphics/opengl/VertexBuffer.h
 	src/modules/graphics/opengl/wrap_Canvas.cpp
 	src/modules/graphics/opengl/wrap_Canvas.h
 	src/modules/graphics/opengl/wrap_Font.cpp

+ 10 - 10
platform/xcode/liblove.xcodeproj/project.pbxproj

@@ -424,9 +424,9 @@
 		FA0B7D511A95902C000E1D17 /* Text.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA0B7BA11A95902C000E1D17 /* Text.cpp */; };
 		FA0B7D521A95902C000E1D17 /* Text.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA0B7BA11A95902C000E1D17 /* Text.cpp */; };
 		FA0B7D531A95902C000E1D17 /* Text.h in Headers */ = {isa = PBXBuildFile; fileRef = FA0B7BA21A95902C000E1D17 /* Text.h */; };
-		FA0B7D551A95902C000E1D17 /* VertexBuffer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA0B7BA41A95902C000E1D17 /* VertexBuffer.cpp */; };
-		FA0B7D561A95902C000E1D17 /* VertexBuffer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA0B7BA41A95902C000E1D17 /* VertexBuffer.cpp */; };
-		FA0B7D571A95902C000E1D17 /* VertexBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = FA0B7BA51A95902C000E1D17 /* VertexBuffer.h */; };
+		FA0B7D551A95902C000E1D17 /* GLBuffer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA0B7BA41A95902C000E1D17 /* GLBuffer.cpp */; };
+		FA0B7D561A95902C000E1D17 /* GLBuffer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA0B7BA41A95902C000E1D17 /* GLBuffer.cpp */; };
+		FA0B7D571A95902C000E1D17 /* GLBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = FA0B7BA51A95902C000E1D17 /* GLBuffer.h */; };
 		FA0B7D581A95902C000E1D17 /* wrap_Canvas.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA0B7BA61A95902C000E1D17 /* wrap_Canvas.cpp */; };
 		FA0B7D591A95902C000E1D17 /* wrap_Canvas.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA0B7BA61A95902C000E1D17 /* wrap_Canvas.cpp */; };
 		FA0B7D5A1A95902C000E1D17 /* wrap_Canvas.h in Headers */ = {isa = PBXBuildFile; fileRef = FA0B7BA71A95902C000E1D17 /* wrap_Canvas.h */; };
@@ -1186,8 +1186,8 @@
 		FA0B7BA01A95902C000E1D17 /* SpriteBatch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SpriteBatch.h; sourceTree = "<group>"; };
 		FA0B7BA11A95902C000E1D17 /* Text.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Text.cpp; sourceTree = "<group>"; };
 		FA0B7BA21A95902C000E1D17 /* Text.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Text.h; sourceTree = "<group>"; };
-		FA0B7BA41A95902C000E1D17 /* VertexBuffer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VertexBuffer.cpp; sourceTree = "<group>"; };
-		FA0B7BA51A95902C000E1D17 /* VertexBuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VertexBuffer.h; sourceTree = "<group>"; };
+		FA0B7BA41A95902C000E1D17 /* GLBuffer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GLBuffer.cpp; sourceTree = "<group>"; };
+		FA0B7BA51A95902C000E1D17 /* GLBuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GLBuffer.h; sourceTree = "<group>"; };
 		FA0B7BA61A95902C000E1D17 /* wrap_Canvas.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = wrap_Canvas.cpp; sourceTree = "<group>"; };
 		FA0B7BA71A95902C000E1D17 /* wrap_Canvas.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = wrap_Canvas.h; sourceTree = "<group>"; };
 		FA0B7BA81A95902C000E1D17 /* wrap_Font.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = wrap_Font.cpp; sourceTree = "<group>"; };
@@ -2188,6 +2188,8 @@
 				FA0B7B8E1A95902C000E1D17 /* Canvas.h */,
 				FA0B7B8F1A95902C000E1D17 /* Font.cpp */,
 				FA0B7B901A95902C000E1D17 /* Font.h */,
+				FA0B7BA41A95902C000E1D17 /* GLBuffer.cpp */,
+				FA0B7BA51A95902C000E1D17 /* GLBuffer.h */,
 				FA0B7B911A95902C000E1D17 /* Graphics.cpp */,
 				FA0B7B921A95902C000E1D17 /* Graphics.h */,
 				FA0B7B931A95902C000E1D17 /* Image.cpp */,
@@ -2206,8 +2208,6 @@
 				FA0B7BA01A95902C000E1D17 /* SpriteBatch.h */,
 				FA0B7BA11A95902C000E1D17 /* Text.cpp */,
 				FA0B7BA21A95902C000E1D17 /* Text.h */,
-				FA0B7BA41A95902C000E1D17 /* VertexBuffer.cpp */,
-				FA0B7BA51A95902C000E1D17 /* VertexBuffer.h */,
 				FA0B7BA61A95902C000E1D17 /* wrap_Canvas.cpp */,
 				FA0B7BA71A95902C000E1D17 /* wrap_Canvas.h */,
 				FA0B7BA81A95902C000E1D17 /* wrap_Font.cpp */,
@@ -2815,7 +2815,7 @@
 				FA0B79231A958E3B000E1D17 /* EnumMap.h in Headers */,
 				FA0B7A371A958EA3000E1D17 /* b2Distance.h in Headers */,
 				FA0B7E681A95902C000E1D17 /* wrap_PrismaticJoint.h in Headers */,
-				FA0B7D571A95902C000E1D17 /* VertexBuffer.h in Headers */,
+				FA0B7D571A95902C000E1D17 /* GLBuffer.h in Headers */,
 				FA0B7ED71A95902D000E1D17 /* Timer.h in Headers */,
 				FA0B7AC31A958EA3000E1D17 /* list.h in Headers */,
 				FA0B7B2D1A958EA3000E1D17 /* core.h in Headers */,
@@ -3325,7 +3325,7 @@
 				FA0B7D6E1A95902C000E1D17 /* wrap_Shader.cpp in Sources */,
 				FA0B7E861A95902C000E1D17 /* CoreAudioDecoder.cpp in Sources */,
 				FA0B7E761A95902C000E1D17 /* wrap_WeldJoint.cpp in Sources */,
-				FA0B7D561A95902C000E1D17 /* VertexBuffer.cpp in Sources */,
+				FA0B7D561A95902C000E1D17 /* GLBuffer.cpp in Sources */,
 				FA0B7A6C1A958EA3000E1D17 /* b2World.cpp in Sources */,
 				FA0B7E221A95902C000E1D17 /* PolygonShape.cpp in Sources */,
 				FA0B7A651A958EA3000E1D17 /* b2Fixture.cpp in Sources */,
@@ -3604,7 +3604,7 @@
 				FA0B7D6D1A95902C000E1D17 /* wrap_Shader.cpp in Sources */,
 				FA0B7E851A95902C000E1D17 /* CoreAudioDecoder.cpp in Sources */,
 				FA0B7E751A95902C000E1D17 /* wrap_WeldJoint.cpp in Sources */,
-				FA0B7D551A95902C000E1D17 /* VertexBuffer.cpp in Sources */,
+				FA0B7D551A95902C000E1D17 /* GLBuffer.cpp in Sources */,
 				FA0B7AFF1A958EA3000E1D17 /* options.c in Sources */,
 				FA0B7E211A95902C000E1D17 /* PolygonShape.cpp in Sources */,
 				FA0B7AE41A958EA3000E1D17 /* buffer.c in Sources */,

+ 1 - 1
src/modules/graphics/opengl/Font.cpp

@@ -531,7 +531,7 @@ void Font::drawVertices(const std::vector<DrawCommand> &drawcommands)
 	const GLenum gltype = indexBuffer.getType();
 	const size_t elemsize = indexBuffer.getElementSize();
 
-	VertexBuffer::Bind bind(*indexBuffer.getVertexBuffer());
+	GLBuffer::Bind bind(*indexBuffer.getBuffer());
 
 	// We need a separate draw call for every section of the text which uses a
 	// different texture than the previous section.

+ 1 - 1
src/modules/graphics/opengl/Font.h

@@ -35,7 +35,7 @@
 #include "font/Rasterizer.h"
 #include "graphics/Texture.h"
 #include "graphics/Volatile.h"
-#include "VertexBuffer.h"
+#include "GLBuffer.h"
 
 #include "OpenGL.h"
 

+ 28 - 28
src/modules/graphics/opengl/VertexBuffer.cpp → src/modules/graphics/opengl/GLBuffer.cpp

@@ -18,7 +18,7 @@
  * 3. This notice may not be removed or altered from any source distribution.
  **/
 
-#include "VertexBuffer.h"
+#include "GLBuffer.h"
 
 #include "common/Exception.h"
 
@@ -34,14 +34,14 @@ namespace graphics
 namespace opengl
 {
 
-// VertexBuffer
+// GLBuffer
 
-VertexBuffer *VertexBuffer::Create(size_t size, GLenum target, GLenum usage)
+GLBuffer *GLBuffer::Create(size_t size, GLenum target, GLenum usage)
 {
-	return new VertexBuffer(size, target, usage);
+	return new GLBuffer(size, target, usage);
 }
 
-VertexBuffer::VertexBuffer(size_t size, GLenum target, GLenum usage)
+GLBuffer::GLBuffer(size_t size, GLenum target, GLenum usage)
 	: is_bound(false)
 	, is_mapped(false)
 	, size(size)
@@ -68,7 +68,7 @@ VertexBuffer::VertexBuffer(size_t size, GLenum target, GLenum usage)
 	}
 }
 
-VertexBuffer::~VertexBuffer()
+GLBuffer::~GLBuffer()
 {
 	if (vbo != 0)
 		unload();
@@ -76,7 +76,7 @@ VertexBuffer::~VertexBuffer()
 	delete[] memory_map;
 }
 
-void *VertexBuffer::map()
+void *GLBuffer::map()
 {
 	if (is_mapped)
 		return memory_map;
@@ -86,13 +86,13 @@ void *VertexBuffer::map()
 	return memory_map;
 }
 
-void VertexBuffer::unmapStatic(size_t offset, size_t size)
+void GLBuffer::unmapStatic(size_t offset, size_t size)
 {
 	// Upload the mapped data to the buffer.
 	glBufferSubData(getTarget(), (GLintptr) offset, (GLsizeiptr) size, memory_map + offset);
 }
 
-void VertexBuffer::unmapStream()
+void GLBuffer::unmapStream()
 {
 	// "orphan" current buffer to avoid implicit synchronisation on the GPU:
 	// http://www.seas.upenn.edu/~pcozzi/OpenGLInsights/OpenGLInsights-AsynchronousBufferTransfers.pdf
@@ -100,7 +100,7 @@ void VertexBuffer::unmapStream()
 	glBufferData(getTarget(), (GLsizeiptr) getSize(), memory_map, getUsage());
 }
 
-void VertexBuffer::unmap(size_t usedOffset, size_t usedSize)
+void GLBuffer::unmap(size_t usedOffset, size_t usedSize)
 {
 	if (!is_mapped)
 		return;
@@ -138,7 +138,7 @@ void VertexBuffer::unmap(size_t usedOffset, size_t usedSize)
 	is_mapped = false;
 }
 
-void VertexBuffer::bind()
+void GLBuffer::bind()
 {
 	if (!is_mapped)
 	{
@@ -147,7 +147,7 @@ void VertexBuffer::bind()
 	}
 }
 
-void VertexBuffer::unbind()
+void GLBuffer::unbind()
 {
 	if (is_bound)
 		glBindBuffer(getTarget(), 0);
@@ -155,7 +155,7 @@ void VertexBuffer::unbind()
 	is_bound = false;
 }
 
-void VertexBuffer::fill(size_t offset, size_t size, const void *data)
+void GLBuffer::fill(size_t offset, size_t size, const void *data)
 {
 	memcpy(memory_map + offset, data, size);
 
@@ -163,26 +163,26 @@ void VertexBuffer::fill(size_t offset, size_t size, const void *data)
 		glBufferSubData(getTarget(), (GLintptr) offset, (GLsizeiptr) size, data);
 }
 
-const void *VertexBuffer::getPointer(size_t offset) const
+const void *GLBuffer::getPointer(size_t offset) const
 {
 	return BUFFER_OFFSET(offset);
 }
 
-bool VertexBuffer::loadVolatile()
+bool GLBuffer::loadVolatile()
 {
 	return load(true);
 }
 
-void VertexBuffer::unloadVolatile()
+void GLBuffer::unloadVolatile()
 {
 	unload();
 }
 
-bool VertexBuffer::load(bool restore)
+bool GLBuffer::load(bool restore)
 {
 	glGenBuffers(1, &vbo);
 
-	VertexBuffer::Bind bind(*this);
+	GLBuffer::Bind bind(*this);
 
 	// Copy the old buffer only if 'restore' was requested.
 	const GLvoid *src = restore ? memory_map : nullptr;
@@ -193,7 +193,7 @@ bool VertexBuffer::load(bool restore)
 	return true;
 }
 
-void VertexBuffer::unload()
+void GLBuffer::unload()
 {
 	is_mapped = false;
 
@@ -207,7 +207,7 @@ void VertexBuffer::unload()
 size_t VertexIndex::maxSize = 0;
 size_t VertexIndex::elementSize = 0;
 std::list<size_t> VertexIndex::sizeRefs;
-VertexBuffer *VertexIndex::element_array = NULL;
+GLBuffer *VertexIndex::element_array = NULL;
 
 VertexIndex::VertexIndex(size_t size)
 	: size(size)
@@ -264,7 +264,7 @@ size_t VertexIndex::getElementSize()
 	return elementSize;
 }
 
-VertexBuffer *VertexIndex::getVertexBuffer() const
+GLBuffer *VertexIndex::getBuffer() const
 {
 	return element_array;
 }
@@ -318,7 +318,7 @@ void VertexIndex::resize(size_t size)
 		return;
 	}
 
-	VertexBuffer *new_element_array;
+	GLBuffer *new_element_array;
 	
 	// Depending on the size, a switch to int and more memory is needed.
 	GLenum target_type = getType(size);
@@ -327,18 +327,18 @@ void VertexIndex::resize(size_t size)
 	size_t array_size = elem_size * 6 * size;
 
 	// Create may throw out-of-memory exceptions.
-	// VertexIndex will propagate the exception and keep the old VertexBuffer.
+	// VertexIndex will propagate the exception and keep the old GLBuffer.
 	try
 	{
-		new_element_array = VertexBuffer::Create(array_size, GL_ELEMENT_ARRAY_BUFFER, GL_STATIC_DRAW);
+		new_element_array = GLBuffer::Create(array_size, GL_ELEMENT_ARRAY_BUFFER, GL_STATIC_DRAW);
 	}
 	catch (std::bad_alloc &)
 	{
 		throw love::Exception("Out of memory.");
 	}
 
-	// Allocation of the new VertexBuffer succeeded.
-	// The old VertexBuffer can now be deleted.
+	// Allocation of the new GLBuffer succeeded.
+	// The old GLBuffer can now be deleted.
 	delete element_array;
 	element_array = new_element_array;
 	maxSize = size;
@@ -358,8 +358,8 @@ void VertexIndex::resize(size_t size)
 template <typename T>
 void VertexIndex::fill()
 {
-	VertexBuffer::Bind bind(*element_array);
-	VertexBuffer::Mapper mapper(*element_array);
+	GLBuffer::Bind bind(*element_array);
+	GLBuffer::Mapper mapper(*element_array);
 
 	T *indices = (T *) mapper.get();
 

+ 50 - 52
src/modules/graphics/opengl/VertexBuffer.h → src/modules/graphics/opengl/GLBuffer.h

@@ -19,8 +19,8 @@
  **/
 
 
-#ifndef LOVE_GRAPHICS_OPENGL_VERTEX_BUFFER_H
-#define LOVE_GRAPHICS_OPENGL_VERTEX_BUFFER_H
+#ifndef LOVE_GRAPHICS_OPENGL_GL_BUFFER_H
+#define LOVE_GRAPHICS_OPENGL_GL_BUFFER_H
 
 // LOVE
 #include "common/config.h"
@@ -40,45 +40,43 @@ namespace opengl
 {
 
 /**
- * VertexBuffer is a thin abstraction over VBOs (Vertex Buffer Objects) and
- * other OpenGL Buffer Objects.
- *
- * The class is (for now) meant for internal use.
+ * GLBuffer is a thin abstraction over OpenGL's Buffer Objects.
+ * The class is meant for internal use.
  */
-class VertexBuffer : public Volatile
+class GLBuffer : public Volatile
 {
 public:
 
 	/**
-	 * Create a new VertexBuffer.
+	 * Create a new GLBuffer.
 	 *
-	 * @param size The size of the VertexBuffer (in bytes).
+	 * @param size The size of the GLBuffer (in bytes).
 	 * @param target GL_ARRAY_BUFFER, GL_ELEMENT_ARRAY_BUFFER.
 	 * @param usage GL_DYNAMIC_DRAW, etc.
 	 * @param backing Determines what guarantees are placed on the data.
-	 * @return A new VertexBuffer.
+	 * @return A new GLBuffer.
 	 */
-	static VertexBuffer *Create(size_t size, GLenum target, GLenum usage);
+	static GLBuffer *Create(size_t size, GLenum target, GLenum usage);
 
 	/**
 	 * Constructor.
 	 *
-	 * @param size The size of the VertexBuffer in bytes.
-	 * @param target The target VertexBuffer object, e.g. GL_ARRAY_BUFFER.
+	 * @param size The size of the GLBuffer in bytes.
+	 * @param target The target GLBuffer object, e.g. GL_ARRAY_BUFFER.
 	 * @param usage Usage hint, e.g. GL_DYNAMIC_DRAW.
 	 * @param backing Determines what guarantees are placed on the data.
 	 */
-	VertexBuffer(size_t size, GLenum target, GLenum usage);
+	GLBuffer(size_t size, GLenum target, GLenum usage);
 
 	/**
 	 * Destructor.
 	 */
-	virtual ~VertexBuffer();
+	virtual ~GLBuffer();
 
 	/**
-	 * Get the size of the VertexBuffer, in bytes.
+	 * Get the size of the GLBuffer, in bytes.
 	 *
-	 * @return The size of the VertexBuffer.
+	 * @return The size of the GLBuffer.
 	 */
 	size_t getSize() const
 	{
@@ -96,7 +94,7 @@ public:
 	}
 
 	/**
-	 * Get the usage hint for this VertexBuffer.
+	 * Get the usage hint for this GLBuffer.
 	 *
 	 * @return The usage hint, e.g. GL_DYNAMIC_DRAW.
 	 */
@@ -116,22 +114,22 @@ public:
 	}
 
 	/**
-	 * Map the VertexBuffer to client memory.
+	 * Map the GLBuffer to client memory.
 	 *
 	 * This can be faster for large changes to the buffer. For smaller
 	 * changes, see fill().
 	 *
-	 * The VertexBuffer must be bound to use this function.
+	 * The GLBuffer must be bound to use this function.
 	 *
 	 * @return A pointer to memory which represents the buffer.
 	 */
 	virtual void *map();
 
 	/**
-	 * Unmap a previously mapped VertexBuffer. The buffer must be unmapped
+	 * Unmap a previously mapped GLBuffer. The buffer must be unmapped
 	 * when used to draw elements.
 	 *
-	 * The VertexBuffer must be bound to use this function.
+	 * The GLBuffer must be bound to use this function.
 	 *
 	 * @param usedOffset The offset into the mapped buffer indicating the
 	 *                   sub-range of data modified. Optional.
@@ -140,22 +138,22 @@ public:
 	virtual void unmap(size_t usedOffset = 0, size_t usedSize = -1);
 
 	/**
-	 * Bind the VertexBuffer to its specified target.
+	 * Bind the GLBuffer to its specified target.
 	 * (GL_ARRAY_BUFFER, GL_ELEMENT_ARRAY_BUFFER, etc).
 	 */
 	virtual void bind();
 
 	/**
-	 * Unbind a prevously bound VertexBuffer.
+	 * Unbind a prevously bound GLBuffer.
 	 */
 	virtual void unbind();
 
 	/**
 	 * Fill a portion of the buffer with data.
 	 *
-	 * The VertexBuffer must be bound to use this function.
+	 * The GLBuffer must be bound to use this function.
 	 *
-	 * @param offset The offset in the VertexBuffer to store the data.
+	 * @param offset The offset in the GLBuffer to store the data.
 	 * @param size The size of the incoming data.
 	 * @param data Pointer to memory to copy data from.
 	 */
@@ -174,7 +172,7 @@ public:
 	virtual void unloadVolatile();
 
 	/**
-	 * This helper class can bind a VertexArray temporarily, and
+	 * This helper class can bind a GLBuffer temporarily, and
 	 * automatically un-bind when it's destroyed.
 	 */
 	class Bind
@@ -182,16 +180,16 @@ public:
 	public:
 
 		/**
-		 * Bind a VertexBuffer.
+		 * Bind a GLBuffer.
 		 */
-		Bind(VertexBuffer &buf)
+		Bind(GLBuffer &buf)
 			: buf(buf)
 		{
 			buf.bind();
 		}
 
 		/**
-		 * Unbinds a VertexBuffer.
+		 * Unbinds a GLBuffer.
 		 */
 		~Bind()
 		{
@@ -200,8 +198,8 @@ public:
 
 	private:
 
-		// VertexBuffer to work on.
-		VertexBuffer &buf;
+		// GLBuffer to work on.
+		GLBuffer &buf;
 
 	}; // Bind
 
@@ -210,9 +208,9 @@ public:
 	public:
 
 		/**
-		 * Memory-maps a VertexBuffer.
+		 * Memory-maps a GLBuffer.
 		 */
-		Mapper(VertexBuffer &buffer)
+		Mapper(GLBuffer &buffer)
 			: buf(buffer)
 		{
 			elems = buf.map();
@@ -236,7 +234,7 @@ public:
 
 	private:
 
-		VertexBuffer &buf;
+		GLBuffer &buf;
 		void *elems;
 
 	}; // Mapper
@@ -276,11 +274,11 @@ private:
 	// A pointer to mapped memory.
 	char *memory_map;
 
-}; // VertexBuffer
+}; // GLBuffer
 
 
 /**
- * VertexIndex manages one shared VertexBuffer that stores the indices for an
+ * VertexIndex manages one shared GLBuffer that stores the indices for an
  * element array. Vertex arrays using the vertex structure (or anything else
  * that can use the pattern below) can request a size and use it for the
  * drawElements call.
@@ -293,19 +291,19 @@ private:
  *  indices[i*6 + 4] = i*4 + 2;
  *  indices[i*6 + 5] = i*4 + 3;
  *
- * There will always be a large enough VertexBuffer around until all
+ * There will always be a large enough GLBuffer around until all
  * VertexIndex instances have been deleted.
  *
  * Q: Why have something like VertexIndex?
  * A: The indices for the SpriteBatch do not change, only the array size
- * varies. Using one VertexBuffer for all element arrays removes this
+ * varies. Using one GLBuffer for all element arrays removes this
  * duplicated data and saves some memory.
  */
 class VertexIndex
 {
 public:
 	/**
-	 * Adds an entry to the list of sizes and resizes the VertexBuffer
+	 * Adds an entry to the list of sizes and resizes the GLBuffer
 	 * if needed. A size of 1 allocates a group of 6 indices for 4 vertices
 	 * creating 1 face.
 	 *
@@ -317,7 +315,7 @@ public:
 	VertexIndex &operator = (const VertexIndex &other);
 
 	/**
-	 * Removes an entry from the list of sizes and resizes the VertexBuffer
+	 * Removes an entry from the list of sizes and resizes the GLBuffer
 	 * if needed.
 	 */
 	~VertexIndex();
@@ -364,14 +362,14 @@ public:
 	size_t getElementSize();
 
 	/**
-	 * Returns the pointer to the VertexBuffer.
+	 * Returns the pointer to the GLBuffer.
 	 * The pointer will change if a new size request or removal causes
-	 * a VertexBuffer resize. It is recommended to retrieve the pointer
+	 * a GLBuffer resize. It is recommended to retrieve the pointer
 	 * value directly before the drawing call.
 	 *
-	 * @return The pointer to the VertexBuffer.
+	 * @return The pointer to the GLBuffer.
 	 */
-	VertexBuffer *getVertexBuffer() const;
+	GLBuffer *getBuffer() const;
 
 	/**
 	 * Returns a pointer which represents the specified byte offset.
@@ -398,12 +396,12 @@ private:
 	void removeSize(size_t oldSize);
 
 	/**
-	 * Resizes the VertexBuffer to the requested size.
+	 * Resizes the GLBuffer to the requested size.
 	 * This function takes care of choosing the correct integer type and
-	 * allocating and deleting the VertexBuffer instance. It also has some
+	 * allocating and deleting the GLBuffer instance. It also has some
 	 * fallback logic in case the memory ran out.
 	 *
-	 * @param size The requested VertexBuffer size. Passing 0 deletes the VertexBuffer without allocating a new one.
+	 * @param size The requested GLBuffer size. Passing 0 deletes the GLBuffer without allocating a new one.
 	 */
 	void resize(size_t size);
 
@@ -419,16 +417,16 @@ private:
 
 	// The size in bytes of an element in the element array.
 	static size_t elementSize;
-	// The current VertexBuffer size. 0 means no VertexBuffer.
+	// The current GLBuffer size. 0 means no GLBuffer.
 	static size_t maxSize;
 	// The list of sizes. Needs to be kept sorted in ascending order.
 	static std::list<size_t> sizeRefs;
-	// The VertexBuffer for the element array. Can be NULL.
-	static VertexBuffer *element_array;
+	// The GLBuffer for the element array. Can be NULL.
+	static GLBuffer *element_array;
 };
 
 } // opengl
 } // graphics
 } // love
 
-#endif // LOVE_GRAPHICS_OPENGL_SPRITE_BATCH_H
+#endif // LOVE_GRAPHICS_OPENGL_GL_BUFFER_H

+ 13 - 13
src/modules/graphics/opengl/Mesh.cpp

@@ -97,12 +97,12 @@ void Mesh::setVertices(const std::vector<Vertex> &verts)
 	}
 
 	if (!vbo)
-		vbo = VertexBuffer::Create(size, GL_ARRAY_BUFFER, GL_DYNAMIC_DRAW);
+		vbo = GLBuffer::Create(size, GL_ARRAY_BUFFER, GL_DYNAMIC_DRAW);
 
 	vertex_count = verts.size();
 
-	VertexBuffer::Bind vbo_bind(*vbo);
-	VertexBuffer::Mapper vbo_mapper(*vbo);
+	GLBuffer::Bind vbo_bind(*vbo);
+	GLBuffer::Mapper vbo_mapper(*vbo);
 
 	// Fill the buffer with the vertices.
 	memcpy(vbo_mapper.get(), &verts[0], size);
@@ -112,7 +112,7 @@ const Vertex *Mesh::getVertices() const
 {
 	if (vbo)
 	{
-		VertexBuffer::Bind vbo_bind(*vbo);
+		GLBuffer::Bind vbo_bind(*vbo);
 		return (Vertex *) vbo->map();
 	}
 
@@ -124,7 +124,7 @@ void Mesh::setVertex(size_t index, const Vertex &v)
 	if (index >= vertex_count)
 		throw love::Exception("Invalid vertex index: %ld", index + 1);
 
-	VertexBuffer::Bind vbo_bind(*vbo);
+	GLBuffer::Bind vbo_bind(*vbo);
 
 	// We unmap the vertex buffer in Mesh::draw. This lets us coalesce the
 	// buffer transfer calls into just one.
@@ -137,7 +137,7 @@ Vertex Mesh::getVertex(size_t index) const
 	if (index >= vertex_count)
 		throw love::Exception("Invalid vertex index: %ld", index + 1);
 
-	VertexBuffer::Bind vbo_bind(*vbo);
+	GLBuffer::Bind vbo_bind(*vbo);
 
 	// We unmap the vertex buffer in Mesh::draw.
 	Vertex *vertices = (Vertex *) vbo->map();
@@ -153,7 +153,7 @@ size_t Mesh::getVertexCount() const
  * Copies index data from a vector to a mapped index buffer.
  **/
 template <typename T>
-static void copyToIndexBuffer(const std::vector<uint32> &indices, VertexBuffer::Mapper &buffermap, size_t maxval)
+static void copyToIndexBuffer(const std::vector<uint32> &indices, GLBuffer::Mapper &buffermap, size_t maxval)
 {
 	T *elems = (T *) buffermap.get();
 
@@ -180,15 +180,15 @@ void Mesh::setVertexMap(const std::vector<uint32> &map)
 	}
 
 	if (!ibo && size > 0)
-		ibo = VertexBuffer::Create(size, GL_ELEMENT_ARRAY_BUFFER, GL_DYNAMIC_DRAW);
+		ibo = GLBuffer::Create(size, GL_ELEMENT_ARRAY_BUFFER, GL_DYNAMIC_DRAW);
 
 	element_count = map.size();
 
 	if (!ibo || element_count == 0)
 		return;
 
-	VertexBuffer::Bind ibo_bind(*ibo);
-	VertexBuffer::Mapper ibo_map(*ibo);
+	GLBuffer::Bind ibo_bind(*ibo);
+	GLBuffer::Mapper ibo_map(*ibo);
 
 	// Fill the buffer with the index values from the vector.
 	switch (datatype)
@@ -227,7 +227,7 @@ void Mesh::getVertexMap(std::vector<uint32> &map) const
 	map.clear();
 	map.reserve(element_count);
 
-	VertexBuffer::Bind ibo_bind(*ibo);
+	GLBuffer::Bind ibo_bind(*ibo);
 
 	// We unmap the buffer in Mesh::draw and Mesh::setVertexMap.
 	void *buffer = ibo->map();
@@ -328,7 +328,7 @@ void Mesh::draw(float x, float y, float angle, float sx, float sy, float ox, flo
 	OpenGL::TempTransform transform(gl);
 	transform.get() *= m;
 
-	VertexBuffer::Bind vbo_bind(*vbo);
+	GLBuffer::Bind vbo_bind(*vbo);
 
 	// Make sure the VBO isn't mapped when we draw (sends data to GPU if needed.)
 	vbo->unmap();
@@ -353,7 +353,7 @@ void Mesh::draw(float x, float y, float angle, float sx, float sy, float ox, flo
 	if (ibo && element_count > 0)
 	{
 		// Use the custom vertex map (index buffer) to draw the vertices.
-		VertexBuffer::Bind ibo_bind(*ibo);
+		GLBuffer::Bind ibo_bind(*ibo);
 
 		// Make sure the index buffer isn't mapped (sends data to GPU if needed.)
 		ibo->unmap();

+ 3 - 3
src/modules/graphics/opengl/Mesh.h

@@ -28,7 +28,7 @@
 #include "common/StringMap.h"
 #include "graphics/Drawable.h"
 #include "graphics/Texture.h"
-#include "VertexBuffer.h"
+#include "GLBuffer.h"
 
 // C++
 #include <vector>
@@ -165,11 +165,11 @@ private:
 	size_t getGLDataTypeSize(GLenum datatype) const;
 
 	// Vertex buffer.
-	VertexBuffer *vbo;
+	GLBuffer *vbo;
 	size_t vertex_count;
 
 	// Element (vertex index) buffer, for the vertex map.
-	VertexBuffer *ibo;
+	GLBuffer *ibo;
 	size_t element_count;
 	GLenum element_data_type;
 

+ 3 - 6
src/modules/graphics/opengl/OpenGL.cpp

@@ -633,9 +633,8 @@ const char *OpenGL::debugSeverityString(GLenum severity)
 	case GL_DEBUG_SEVERITY_LOW:
 		return "low";
 	default:
-		break;
+		return "unknown";
 	}
-	return "unknown";
 }
 
 const char *OpenGL::debugSourceString(GLenum source)
@@ -655,9 +654,8 @@ const char *OpenGL::debugSourceString(GLenum source)
 	case GL_DEBUG_SOURCE_OTHER:
 		return "other";
 	default:
-		break;
+		return "unknown";
 	}
-	return "unknown";
 }
 
 const char *OpenGL::debugTypeString(GLenum type)
@@ -677,9 +675,8 @@ const char *OpenGL::debugTypeString(GLenum type)
 	case GL_DEBUG_TYPE_OTHER:
 		return "other";
 	default:
-		break;
+		return "unknown";
 	}
-	return "unknown";
 }
 
 

+ 1 - 1
src/modules/graphics/opengl/ParticleSystem.cpp

@@ -888,7 +888,7 @@ void ParticleSystem::draw(float x, float y, float angle, float sx, float sy, flo
 	glVertexAttribPointer(ATTRIB_TEXCOORD, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), &particleVerts[0].s);
 
 	{
-		VertexBuffer::Bind ibo_bind(*ibo.getVertexBuffer());
+		GLBuffer::Bind ibo_bind(*ibo.getBuffer());
 		gl.drawElements(GL_TRIANGLES, (GLsizei) ibo.getIndexCount(pCount), ibo.getType(), ibo.getPointer(0));
 	}
 

+ 1 - 1
src/modules/graphics/opengl/ParticleSystem.h

@@ -29,7 +29,7 @@
 #include "graphics/Color.h"
 #include "graphics/Quad.h"
 #include "graphics/Texture.h"
-#include "VertexBuffer.h"
+#include "GLBuffer.h"
 
 // STL
 #include <vector>

+ 13 - 13
src/modules/graphics/opengl/SpriteBatch.cpp

@@ -25,7 +25,7 @@
 #include "OpenGL.h"
 
 // LOVE
-#include "VertexBuffer.h"
+#include "GLBuffer.h"
 #include "graphics/Texture.h"
 
 // C++
@@ -73,7 +73,7 @@ SpriteBatch::SpriteBatch(Texture *texture, int size, int usage)
 
 	try
 	{
-		array_buf = VertexBuffer::Create(vertex_size, GL_ARRAY_BUFFER, gl_usage);
+		array_buf = GLBuffer::Create(vertex_size, GL_ARRAY_BUFFER, gl_usage);
 	}
 	catch (love::Exception &)
 	{
@@ -135,7 +135,7 @@ void SpriteBatch::clear()
 
 void SpriteBatch::flush()
 {
-	VertexBuffer::Bind bind(*array_buf);
+	GLBuffer::Bind bind(*array_buf);
 	array_buf->unmap(buffer_used_offset, buffer_used_size);
 
 	buffer_used_offset = buffer_used_size = 0;
@@ -183,22 +183,22 @@ void SpriteBatch::setBufferSize(int newsize)
 	if (newsize == size)
 		return;
 
-	// Map the old VertexBuffer to get a pointer to its data.
+	// Map the old GLBuffer to get a pointer to its data.
 	void *old_data = nullptr;
 	{
-		VertexBuffer::Bind bind(*array_buf);
+		GLBuffer::Bind bind(*array_buf);
 		old_data = array_buf->map();
 	}
 
 	size_t vertex_size = sizeof(Vertex) * 4 * newsize;
-	VertexBuffer *new_array_buf = nullptr;
+	GLBuffer *new_array_buf = nullptr;
 
 	try
 	{
-		new_array_buf = VertexBuffer::Create(vertex_size, array_buf->getTarget(), array_buf->getUsage());
+		new_array_buf = GLBuffer::Create(vertex_size, array_buf->getTarget(), array_buf->getUsage());
 
-		// Copy as much of the old data into the new VertexBuffer as can fit.
-		VertexBuffer::Bind bind(*new_array_buf);
+		// Copy as much of the old data into the new GLBuffer as can fit.
+		GLBuffer::Bind bind(*new_array_buf);
 		void *new_data = new_array_buf->map();
 		memcpy(new_data, old_data, sizeof(Vertex) * 4 * std::min(newsize, size));
 
@@ -210,7 +210,7 @@ void SpriteBatch::setBufferSize(int newsize)
 		throw;
 	}
 
-	// We don't need to unmap the old VertexBuffer since we're deleting it.
+	// We don't need to unmap the old GLBuffer since we're deleting it.
 	delete array_buf;
 
 	array_buf = new_array_buf;
@@ -240,8 +240,8 @@ void SpriteBatch::draw(float x, float y, float angle, float sx, float sy, float
 
 	gl.bindTexture(*(GLuint *) texture->getHandle());
 
-	VertexBuffer::Bind array_bind(*array_buf);
-	VertexBuffer::Bind element_bind(*element_buf.getVertexBuffer());
+	GLBuffer::Bind array_bind(*array_buf);
+	GLBuffer::Bind element_bind(*element_buf.getBuffer());
 
 	// Make sure the VBO isn't mapped when we draw (sends data to GPU if needed.)
 	array_buf->unmap(buffer_used_offset, buffer_used_size);
@@ -286,7 +286,7 @@ void SpriteBatch::addv(const Vertex *v, const Matrix &m, int index)
 	if (color)
 		setColorv(sprite, *color);
 
-	VertexBuffer::Bind bind(*array_buf);
+	GLBuffer::Bind bind(*array_buf);
 
 	// Always keep the VBO mapped when adding data for now (it'll be unmapped
 	// on draw.)

+ 2 - 2
src/modules/graphics/opengl/SpriteBatch.h

@@ -32,7 +32,7 @@
 #include "graphics/Volatile.h"
 #include "graphics/Color.h"
 #include "graphics/Quad.h"
-#include "VertexBuffer.h"
+#include "GLBuffer.h"
 
 namespace love
 {
@@ -137,7 +137,7 @@ private:
 	// added sprite.
 	Color *color;
 
-	VertexBuffer *array_buf;
+	GLBuffer *array_buf;
 	VertexIndex element_buf;
 
 	// The portion of the vertex buffer that's been modified while mapped.

+ 5 - 5
src/modules/graphics/opengl/Text.cpp

@@ -59,13 +59,13 @@ void Text::uploadVertices(const std::vector<Font::GlyphVertex> &vertices, size_t
 		if (vbo != nullptr)
 			newsize = std::max(size_t(vbo->getSize() * 1.5), newsize);
 
-		VertexBuffer *new_vbo = VertexBuffer::Create(newsize, GL_ARRAY_BUFFER, GL_DYNAMIC_DRAW);
+		GLBuffer *new_vbo = GLBuffer::Create(newsize, GL_ARRAY_BUFFER, GL_DYNAMIC_DRAW);
 
 		if (vbo != nullptr)
 		{
 			try
 			{
-				VertexBuffer::Bind bind(*vbo);
+				GLBuffer::Bind bind(*vbo);
 				vbodata = (uint8 *) vbo->map();
 			}
 			catch (love::Exception &)
@@ -74,7 +74,7 @@ void Text::uploadVertices(const std::vector<Font::GlyphVertex> &vertices, size_t
 				throw;
 			}
 
-			VertexBuffer::Bind bind(*new_vbo);
+			GLBuffer::Bind bind(*new_vbo);
 			new_vbo->fill(0, vbo->getSize(), vbodata);
 		}
 
@@ -84,7 +84,7 @@ void Text::uploadVertices(const std::vector<Font::GlyphVertex> &vertices, size_t
 
 	if (vbo != nullptr)
 	{
-		VertexBuffer::Bind bind(*vbo);
+		GLBuffer::Bind bind(*vbo);
 		vbodata = (uint8 *) vbo->map();
 		memcpy(vbodata + offset, &vertices[0], datasize);
 		// We unmap when we draw, to avoid unnecessary full map()/unmap() calls.
@@ -237,7 +237,7 @@ void Text::draw(float x, float y, float angle, float sx, float sy, float ox, flo
 	transform.get() *= t;
 
 	{
-		VertexBuffer::Bind bind(*vbo);
+		GLBuffer::Bind bind(*vbo);
 		vbo->unmap(); // Make sure all pending data is flushed to the GPU.
 
 		// Font::drawVertices expects AttribPointer calls to be done already.

+ 2 - 2
src/modules/graphics/opengl/Text.h

@@ -25,7 +25,7 @@
 #include "common/config.h"
 #include "graphics/Drawable.h"
 #include "Font.h"
-#include "VertexBuffer.h"
+#include "GLBuffer.h"
 
 namespace love
 {
@@ -81,7 +81,7 @@ private:
 	void addTextData(const TextData &s);
 
 	StrongRef<Font> font;
-	VertexBuffer *vbo;
+	GLBuffer *vbo;
 
 	std::vector<Font::DrawCommand> draw_commands;