From bd158faaaad86472efa09ed9c6dd6f13293d65dc Mon Sep 17 00:00:00 2001 From: Bart van Strien Date: Fri, 10 Jun 2011 14:40:37 +0200 Subject: [PATCH] Revise spritebatch locking (binding now) (issue #231) --- src/modules/graphics/opengl/SpriteBatch.cpp | 2 ++ src/modules/graphics/opengl/wrap_SpriteBatch.cpp | 12 ++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/modules/graphics/opengl/SpriteBatch.cpp b/src/modules/graphics/opengl/SpriteBatch.cpp index ca5762f13..1b32cdc1d 100644 --- a/src/modules/graphics/opengl/SpriteBatch.cpp +++ b/src/modules/graphics/opengl/SpriteBatch.cpp @@ -161,11 +161,13 @@ namespace opengl glBindBuffer(GL_ARRAY_BUFFER, vbo[0]); lockp = (vertex *)glMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE); + glBindBuffer(GL_ARRAY_BUFFER, 0); return lockp; } void SpriteBatch::unlock() { + glBindBuffer(GL_ARRAY_BUFFER, vbo[0]); glUnmapBuffer(GL_ARRAY_BUFFER); lockp = 0; glBindBuffer(GL_ARRAY_BUFFER, 0); diff --git a/src/modules/graphics/opengl/wrap_SpriteBatch.cpp b/src/modules/graphics/opengl/wrap_SpriteBatch.cpp index f9f6122b2..5214b8442 100644 --- a/src/modules/graphics/opengl/wrap_SpriteBatch.cpp +++ b/src/modules/graphics/opengl/wrap_SpriteBatch.cpp @@ -67,14 +67,14 @@ namespace opengl return 0; } - int w_SpriteBatch_lock(lua_State * L) + int w_SpriteBatch_bind(lua_State * L) { SpriteBatch * t = luax_checkspritebatch(L, 1); - lua_pushlightuserdata(L, t->lock()); - return 1; + t->lock(); + return 0; } - int w_SpriteBatch_unlock(lua_State * L) + int w_SpriteBatch_unbind(lua_State * L) { SpriteBatch * t = luax_checkspritebatch(L, 1); t->unlock(); @@ -93,8 +93,8 @@ namespace opengl { "add", w_SpriteBatch_add }, { "addq", w_SpriteBatch_addq }, { "clear", w_SpriteBatch_clear }, - { "lock", w_SpriteBatch_lock }, - { "unlock", w_SpriteBatch_unlock }, + { "bind", w_SpriteBatch_bind }, + { "unbind", w_SpriteBatch_unbind }, { "setImage", w_SpriteBatch_setImage }, { 0, 0 } };