Text rendering problem with VBOs on

Apprentice
Posts: 13
Joined: 2007.10
Post: #1
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
Quote this message in a reply
Moderator
Posts: 1,560
Joined: 2003.10
Post: #2
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"?
Quote this message in a reply
Apprentice
Posts: 13
Joined: 2007.10
Post: #3
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.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #4
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.
Quote this message in a reply
Apprentice
Posts: 13
Joined: 2007.10
Post: #5
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.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #6
it's safest to unbind the buffer as soon as you're done with it, just after the gl*Pointer calls should be fine.
Quote this message in a reply
Apprentice
Posts: 13
Joined: 2007.10
Post: #7
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.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #8
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.
Quote this message in a reply
Apprentice
Posts: 13
Joined: 2007.10
Post: #9
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
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #10
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.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Opengl/Cocoa text rendering tesil 15 17,429 Mar 20, 2012 11:16 AM
Last Post: OneSadCookie
  SDL/OpenGL fullscreen text rendering StealthyCoin 2 6,531 Mar 26, 2009 09:47 AM
Last Post: StealthyCoin
  Font rendering problem wadesworld 5 3,601 Mar 18, 2009 11:11 PM
Last Post: AnotherJake
  OpenGL Text Rendering (in Cocoa) daveh84 5 7,896 Feb 19, 2009 12:44 PM
Last Post: TomorrowPlusX
  VBOs and Vertex Arrays in OpenGL not working Talyn 6 6,499 Jul 8, 2008 01:14 PM
Last Post: Fenris