iDevGames Forums
Text rendering problem with VBOs on - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Graphics & Audio Programming (/forum-9.html)
+--- Thread: Text rendering problem with VBOs on (/thread-2747.html)



Text rendering problem with VBOs on - myfeng - Feb 28, 2008 02:07 PM

Hi,

All my text rendering are lost if I use VBOs to render the 3D surface. Did any one has the same problem? Thanks,

myfeng


Text rendering problem with VBOs on - ThemsAllTook - Feb 28, 2008 02:57 PM

We'll need a little bit more information than that to be able to give you a helpful answer. How are you rendering text? What, very specifically, do you mean by "All my text rendering are lost"?


Text rendering problem with VBOs on - myfeng - Feb 28, 2008 03:38 PM

Thanks for your response. I actually QT QGLWdiget::renderText to render the text and my own OpenGL code to render the mesh. The entire scene rendering includes mesh and backgroud. The text rendering is the part of the backgound. so now the problem is that I don't see text rendering if render the mesh using VBOs. It's fine when I turn VBO off for mesh rendering. Hope you understand my problem better. Thanks,

This is how I render the text:
glViewport( 0, 0, (GLint)m_width, (GLint)m_height );
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
glOrtho (0.0, m_width, 0.0, m_height, -1.0, 1.0);
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
getViewModeAsText (strData);
glColor4f (0.0f, 0.0f, 0.0f, 1.0f);
renderText(0.0, 5.0, 0.0, strData, font);-->QT function.

Render mesh:
BuildVBOs()
{
glGenBuffers( 1, &m_nVBOVertices ); // Get A Valid Name
glBindBuffer( LI_GL_ARRAY_BUFFER, m_nVBOVertices );
.....
}
//render:
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
if (m_bVBOLoaded && m_nVBOVertices && m_nVBONormals)
{
glBindBuffer( LI_GL_ARRAY_BUFFER, m_nVBOVertices );
glVertexPointer( 3, GL_FLOAT, 0, (GLfloat *)NULL );
glBindBuffer( LI_GL_ARRAY_BUFFER, m_nVBONormals );
glNormalPointer( GL_FLOAT, 0, (GLfloat *)NULL );
}
else
{
glVertexPointer(3, GL_FLOAT, (sizeof(GLfloat)*3), m_vertices);
glNormalPointer(GL_FLOAT, (sizeof(GLfloat)*3), m_vnormals);
}
for(j = 0; j < pFace->m_primCount; j++)
{
glDrawElements(primMode, pFace->m_primLengths[j], GL_UNSIGNED_INT, &pFace->m_primVerts[n]);
n += pFace->m_primLengths[j];
}
glDisableClientState(GL_NORMAL_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY)

Thanks a lot
myfeng.


Text rendering problem with VBOs on - OneSadCookie - Feb 28, 2008 03:51 PM

You'll need to look at the source for QGLWidget::renderText to find out what GL calls it's making and why you're conflicting with it.

My guess is that a glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0) would probably do the trick, if having a bound VBO really is the problem.

Please use code tags and indentation.


Text rendering problem with VBOs on - myfeng - Feb 28, 2008 04:35 PM

Thanks for your reply. When should I call glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0)?

My render logic is :
1. backgournd: text and so on.
2. mesh.

should I put this after mesh has been rendered?

Sorry for my messy code posting and i will use code tages in future. Thanks.


Text rendering problem with VBOs on - OneSadCookie - Feb 28, 2008 11:13 PM

it's safest to unbind the buffer as soon as you're done with it, just after the gl*Pointer calls should be fine.


Text rendering problem with VBOs on - myfeng - Feb 28, 2008 11:48 PM

This sounds like going back to the issue I posted in my another thread. It crashes when I mix the VBO and no-VBO rendering. I can't unbind the buffer after the mesh is rendered, because I need to constantly render the mesh( mesh can be roated, translated.. and so on). Text need to be always rendered as well. By the way, I used glDeleteBuffers to delete the buffer and I don't call glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0).what's the difference of them? There is no extral argument in glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0). Does it mean all the buffer is unbinded after it get called? Thanks a lot.


Text rendering problem with VBOs on - OneSadCookie - Feb 29, 2008 12:31 AM

You only need the buffer bound during the gl*Pointer calls, it can be unbound at any other time. Unbinding the buffer does not delete it, it only affects the behavior of gl*Pointer.


Text rendering problem with VBOs on - myfeng - Feb 29, 2008 11:18 AM

Hi OneSadCookie,

Thanks for your help. your suggestion fixes my problem.

BTW, do you have an idea about picking model with VBOs on? My laptop has NVIDIA Quadro NVS 140M vedio card and picking is fast when VBOs are on, but my desktop who has ATI card picking crawls. Do you have any suggestion to fix this? Any suggestions will be appreciated.

Regards,
myfeng


Text rendering problem with VBOs on - OneSadCookie - Feb 29, 2008 04:54 PM

Picking probably implies software rendering, so VBOs might have to be sucked back from VRAM.

Realistically, I wouldn't ever expect picking to be fast, and wouldn't use it for anything serious.