Hello all,
I have some problems with picking. I hope, this is the correct thread to post it.
The picking mechanism basically works, but I have no depth-information in the
picking buffer. The picked objects are correct, but they always have a
z-min and z-max of 2147483648. I marked it in the sourcecode-fragment.
My environment is MinGW and Eclipse on Windows.
This is the relevant code of my program
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
…
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
…
glSelectBuffer(PICKING_BUFSIZE, m_arPickingBuffer);
glRenderMode(GL_SELECT);
…
glMatrixMode(GL_PROJECTION);
gluPickMatrix(dPickX, dPickY, iPickRadius, iPickRadius, arTibasVp);
gluPerspective(45, dRatio, 1, 1000);
glMatrixMode(GL_MODELVIEW);
gluLookAt(vEye.x, vEye.y, vEye.z, // eye position
vView.x, vView.y, vView.z, // look at position
0.0f, 1.0f, 0.0f); // up-vector
…
DrawTheScene()…
…
iHits = glRenderMode (GL_RENDER);
ProcessHits(iHits);
void TibasVpOgl::ProcessHits(const GLint _iHits)
{
// pActHit[0] := hit count for hit 0
// pActHit[1] := Minimum depth for hit
// pActHit[2] := Maximum depth for hit
// pActHit[3] := name for 1. hit in this group
// pActHit[4] := name for 2. hit in this group… until hit count
// pActHit[5] := hit count for hit 1 // ... // ... until _iHits
s32 s32ActHit; s32 s32ActName; GLuint *pActValue = m_arPickingBuffer; GLuint uiNamesCount; GLuint uiZ1, uiZ2, uiName; RefPtr<TreeItem> pTI;
qDebug() << "//////////////// hits:" << _iHits; !!! result is correct !!!
// iter over all hits for (s32ActHit=0; s32ActHit<_iHits; s32ActHit++) { // number of names for this hit uiNamesCount = *pActValue++; !!! result is correct !!! qDebug() << "number of names for this hit: " << uiNamesCount;
// z1 uiZ1 = *pActValue++; !!! result is wrong, always 2147483648 !!! qDebug() << "z1: " << uiZ1;
// z2 uiZ2 = *pActValue++; !!! result is wrong, always 2147483648 !!! qDebug() << "z2: " << uiZ2; !!! always 2147483648 !!!
// iter over all names qDebug() << "names for hit " << s32ActHit << ": "; for (s32ActName = 0; s32ActName < (s32) uiNamesCount; s32ActName++) { // get the next name uiName = *pActValue++; qDebug() << "uiName: " << uiName; !!! result is correct !!! } }
} // TibasVpOgl::ProcessHits
Does anybody have an idea?
thanks for your help in advance
Andreas