glRenderMode(GL_RENDER) is slow with VBO.

Hello,

I am using VBO as my rendering method and i have lots of object to draw with lakhs of triangles.
now my issuse is if I select any object using mouse by glRenderMode method it works slow.

GL_RENDER is the default value for glRenderMode. So calling glRenderMode(GL_RENDER) should have absolutely no effect on performance.

Can you clarify what your problem is? From your description, it sounds like you might be using selection mode, which would be glRenderMode(GL_SELECT)? Is selection mode slow? Or are you saying that rendering is slower after you use selection mode, and switch back to rendering mode?

I am rendering 1000 mesh in opengl 4.4.0 version using VBO now issue came from selecting or say picking object from opengl screen.
below is my code.

DWORD dwTime = GetTickCount();
float m_fLen = 28.0f;
float m_fAspectRatio = 1.3f;
int viewportCoords[4] = {0};
memset(m_uiSelectedBuffer,0,200);
glSelectBuffer(200,m_uiSelectedBuffer);
glRenderMode(GL_SELECT);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glGetIntegerv(GL_VIEWPORT, viewportCoords);
gluPickMatrix(x,y,5,5, viewportCoords);
glOrtho((-m_fLen * m_fAspectRatio), (m_fLen * m_fAspectRatio), -m_fLen, m_fLen, -m_fLen100.0f, m_fLen100.0f);
m_iObjectsFound = glRenderMode(GL_RENDER);
DWORD dwEndTime = GetTickCount()-dwTime;
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);

dwEndTime = 1300 average time for my selecting objects using mouse event.

I figure you draw your objectsfor picking between the glOrtho() call and the glRenderMode(GL_RENDER) call?

I’m not really sure what realistic expectations are for performance of selection. It’s such an old and obsolete feature that I doubt it’s heavily optimized in drivers. I don’t think any modern hardware has support for it, so I would expect it to be running completely in software. If you have a lot of primitives/triangles, I’m not surprised if it takes a while.

You mean you didn’t see any drawing in the code? :slight_smile:
So, yes this code does nothing.

Second, GetTickCount() is very imprecise function. Error is about 15ms. Useless for this purpose.

Third, every glGet*() function is expensive.

Forth, I have never noticed performance problem with legacy picking since it is a very rare action. Picking occurs once in several seconds and probably for some stationary objects/scene. Pick matrix creates a very narrow viewing frustum which excludes most of the scene from drawing. Maybe it is not fully HW accelerated, but it works pretty well.