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.
This commit is contained in:
Joel Teichroeb 2014-01-17 09:48:06 -08:00
parent 4af2b19577
commit 91f4e2681b
3 changed files with 15 additions and 3 deletions

View File

@ -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;
}

View File

@ -261,6 +261,7 @@ private:
uint32 _currentPrimitive;
void drawGenericPrimitive(const float *vertices, uint32 numVertices, const PrimitiveObject *primitive);
GLuint _irisVBO;
GLuint _blastVBO;
};
}
#endif

View File

@ -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; }