don't stream in rasterfont

mapping blocks on nvidia workstation, so use glBufferData
This commit is contained in:
degasus 2013-01-31 11:30:44 +01:00
parent afb5be10d9
commit 01d8c21e1d
1 changed files with 12 additions and 6 deletions

View File

@ -208,11 +208,7 @@ RasterFont::~RasterFont()
void RasterFont::printMultilineText(const char *text, double start_x, double start_y, double z, int bbWidth, int bbHeight, u32 color)
{
size_t length = strlen(text);
glBindVertexArray(VAO);
glBindBuffer(GL_ARRAY_BUFFER, VBO);
glBufferData(GL_ARRAY_BUFFER, length*4*6*sizeof(GLfloat), NULL, GL_STREAM_DRAW);
GLfloat *vertices = (GLfloat*)glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
GLfloat *vertices = new GLfloat[length*6*4];
int usage = 0;
GLfloat delta_x = GLfloat(2*char_width)/GLfloat(bbWidth);
@ -272,7 +268,17 @@ void RasterFont::printMultilineText(const char *text, double start_x, double sta
x += delta_x + border_x;
}
glUnmapBuffer(GL_ARRAY_BUFFER);
if(!usage) {
delete [] vertices;
return;
}
glBindVertexArray(VAO);
glBindBuffer(GL_ARRAY_BUFFER, VBO);
glBufferData(GL_ARRAY_BUFFER, usage*sizeof(GLfloat), vertices, GL_STREAM_DRAW);
delete [] vertices;
ProgramShaderCache::SetBothShaders(s_fragmentShader.glprogid, s_vertexShader.glprogid);