From 91f4e2681bd076de71fda1cb91f9412af9927ceb Mon Sep 17 00:00:00 2001 From: Joel Teichroeb Date: Fri, 17 Jan 2014 09:48:06 -0800 Subject: [PATCH] GRIM: Add a vertex buffer object for blast text drawing This makes it so that we don't have to destroy the VBO that a blast text object uses. This fixes what is probably a driver bug with the windows nvidia drivers. --- engines/grim/gfx_opengl_shaders.cpp | 16 +++++++++++++--- engines/grim/gfx_opengl_shaders.h | 1 + engines/grim/textobject.h | 1 + 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/engines/grim/gfx_opengl_shaders.cpp b/engines/grim/gfx_opengl_shaders.cpp index e905f75046f..19064c3304e 100644 --- a/engines/grim/gfx_opengl_shaders.cpp +++ b/engines/grim/gfx_opengl_shaders.cpp @@ -291,6 +291,8 @@ void GfxOpenGLS::setupShaders() { setupTexturedQuad(); setupTexturedCenteredQuad(); setupPrimitives(); + + _blastVBO = Graphics::Shader::createBuffer(GL_ARRAY_BUFFER, 128 * 16 * sizeof(float), NULL, GL_DYNAMIC_DRAW); } byte *GfxOpenGLS::setupScreen(int screenW, int screenH, bool fullscreen) { @@ -1069,8 +1071,14 @@ void GfxOpenGLS::createTextObject(TextObject *text) { x += font->getCharWidth(character); } } - - GLuint vbo = Graphics::Shader::createBuffer(GL_ARRAY_BUFFER, numCharacters * 16 * sizeof(float), bufData, GL_STATIC_DRAW); + GLuint vbo; + if (text->isBlastDraw()) { + vbo = _blastVBO; + glBindBuffer(GL_ARRAY_BUFFER, vbo); + glBufferSubData(GL_ARRAY_BUFFER, 0, numCharacters * 16 * sizeof(float), bufData); + } else { + vbo = Graphics::Shader::createBuffer(GL_ARRAY_BUFFER, numCharacters * 16 * sizeof(float), bufData, GL_STATIC_DRAW); + } Graphics::Shader * textShader = _textProgram->clone(); glBindBuffer(GL_ARRAY_BUFFER, vbo); @@ -1107,7 +1115,9 @@ void GfxOpenGLS::drawTextObject(const TextObject *text) { void GfxOpenGLS::destroyTextObject(TextObject *text) { const TextUserData * td = (const TextUserData *) text->getUserData(); - glDeleteBuffers(1, &td->shader->getAttributeAt(0)._vbo); + if (!text->isBlastDraw()) { + glDeleteBuffers(1, &td->shader->getAttributeAt(0)._vbo); + } text->setUserData(NULL); delete td; } diff --git a/engines/grim/gfx_opengl_shaders.h b/engines/grim/gfx_opengl_shaders.h index 3123c0f2f1b..977ef89a4dc 100644 --- a/engines/grim/gfx_opengl_shaders.h +++ b/engines/grim/gfx_opengl_shaders.h @@ -261,6 +261,7 @@ private: uint32 _currentPrimitive; void drawGenericPrimitive(const float *vertices, uint32 numVertices, const PrimitiveObject *primitive); GLuint _irisVBO; + GLuint _blastVBO; }; } #endif diff --git a/engines/grim/textobject.h b/engines/grim/textobject.h index 5982bc0dd18..3a8224e7023 100644 --- a/engines/grim/textobject.h +++ b/engines/grim/textobject.h @@ -101,6 +101,7 @@ public: void setIsSpeech() { _isSpeech = true; } void setBlastDraw() { _blastDraw = true; } + bool isBlastDraw() { return _blastDraw; } const void *getUserData() const { return _userData; } void setUserData(void *data) { _userData = data; }