From 9c4926b7da7c90b06789484057d7a65219f96fc4 Mon Sep 17 00:00:00 2001 From: rude Date: Sat, 20 Feb 2010 18:19:16 +0100 Subject: [PATCH] Fixed double-transform spritebatch bug. --- src/modules/graphics/opengl/SpriteBatch.cpp | 18 ++++++------------ src/modules/graphics/opengl/SpriteBatch.h | 2 +- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/modules/graphics/opengl/SpriteBatch.cpp b/src/modules/graphics/opengl/SpriteBatch.cpp index 51457a568..053f64ced 100644 --- a/src/modules/graphics/opengl/SpriteBatch.cpp +++ b/src/modules/graphics/opengl/SpriteBatch.cpp @@ -117,7 +117,7 @@ namespace opengl t.setTransformation(x, y, a, sx, sy, ox, oy); t.transform(v, v, 4); - addv(t, v); + addv(v); // Increment counter. next++; @@ -138,9 +138,9 @@ namespace opengl // Transform. Matrix t; t.setTransformation(x, y, a, sx, sy, ox, oy); - t.transform(v, quad->getVertices(), 4); + t.transform(v, v, 4); - addv(t, v); + addv(v); // Increment counter. next++; @@ -207,24 +207,18 @@ namespace opengl glPopMatrix(); } - void SpriteBatch::addv(const Matrix & t, const vertex * v) + void SpriteBatch::addv(const vertex * v) { - // Get a pointer to the correct insertion position. - vertex * dst = vertices + next*4; - - // Transform. - t.transform(dst, dst, 4); - if(lockp != 0) { // Copy into mapped memory if buffer is locked. - memcpy(lockp + (next*4), dst, sizeof(vertex)*4); + memcpy(lockp + (next*4), v, sizeof(vertex)*4); } else { // ... use glBufferSubData otherwise. glBindBuffer(GL_ARRAY_BUFFER, vbo[0]); - glBufferSubData(GL_ARRAY_BUFFER, (next*4)*sizeof(vertex), sizeof(vertex)*4, dst); + glBufferSubData(GL_ARRAY_BUFFER, (next*4)*sizeof(vertex), sizeof(vertex)*4, v); glBindBuffer(GL_ARRAY_BUFFER, 0); } } diff --git a/src/modules/graphics/opengl/SpriteBatch.h b/src/modules/graphics/opengl/SpriteBatch.h index 56f4bb223..6a92fb410 100644 --- a/src/modules/graphics/opengl/SpriteBatch.h +++ b/src/modules/graphics/opengl/SpriteBatch.h @@ -101,7 +101,7 @@ namespace opengl private: - void addv(const Matrix & t, const vertex * v); + void addv(const vertex * v); }; // SpriteBatch